public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Bob Feng" <bob.c.feng@intel.com>
To: devel@edk2.groups.io
Cc: Liming Gao <liming.gao@intel.com>, Bob Feng <bob.c.feng@intel.com>
Subject: [Patch 6/9] BaseTools: Add shared data for processes
Date: Thu, 18 Jul 2019 14:14:20 +0800	[thread overview]
Message-ID: <20190718061423.30612-7-bob.c.feng@intel.com> (raw)
In-Reply-To: <20190718061423.30612-1-bob.c.feng@intel.com>

BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=1875

Add shared data for autogen processes.

Cc: Liming Gao <liming.gao@intel.com>
Signed-off-by: Bob Feng <bob.c.feng@intel.com>
---
 BaseTools/Source/Python/AutoGen/AutoGenWorker.py |  3 ++-
 BaseTools/Source/Python/build/build.py           | 10 ++++++----
 2 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/BaseTools/Source/Python/AutoGen/AutoGenWorker.py b/BaseTools/Source/Python/AutoGen/AutoGenWorker.py
index a0415f0d3420..150de0891c6e 100644
--- a/BaseTools/Source/Python/AutoGen/AutoGenWorker.py
+++ b/BaseTools/Source/Python/AutoGen/AutoGenWorker.py
@@ -52,18 +52,19 @@ class AutoGenManager(threading.Thread):
         for w in self.autogen_workers:
             if w.is_alive():
                 w.terminate()
 
 class AutoGenWorkerInProcess(mp.Process):
-    def __init__(self,module_queue,data_pipe_file_path,feedback_q,file_lock):
+    def __init__(self,module_queue,data_pipe_file_path,feedback_q,file_lock, share_data):
         mp.Process.__init__(self)
         self.module_queue = module_queue
         self.data_pipe_file_path =data_pipe_file_path
         self.data_pipe = None
         self.feedback_q = feedback_q
         self.PlatformMetaFileSet = {}
         self.file_lock = file_lock
+        self.share_data = share_data
     def GetPlatformMetaFile(self,filepath,root):
         try:
             return self.PlatformMetaFileSet[(filepath,root)]
         except:
             self.PlatformMetaFileSet[(filepath,root)]  = filepath
diff --git a/BaseTools/Source/Python/build/build.py b/BaseTools/Source/Python/build/build.py
index b4916a32171a..46aed15bd9d1 100644
--- a/BaseTools/Source/Python/build/build.py
+++ b/BaseTools/Source/Python/build/build.py
@@ -50,10 +50,11 @@ from GenPatchPcdTable.GenPatchPcdTable import PeImageClass,parsePcdInfoFromMapFi
 from PatchPcdValue.PatchPcdValue import PatchBinaryFile
 
 import Common.GlobalData as GlobalData
 from GenFds.GenFds import GenFds, GenFdsApi
 import multiprocessing as mp
+from multiprocessing import Manager
 
 # Version and Copyright
 VersionNumber = "0.60" + ' ' + gBUILD_VERSION
 __version__ = "%prog Version " + VersionNumber
 __copyright__ = "Copyright (c) 2007 - 2018, Intel Corporation  All rights reserved."
@@ -825,16 +826,17 @@ class Build():
             self.InitBuild()
 
         self.AutoGenMgr = None
         EdkLogger.info("")
         os.chdir(self.WorkspaceDir)
-    def StartAutoGen(self,mqueue, DataPipe,SkipAutoGen,PcdMaList):
+        self.share_data = Manager().dict()
+    def StartAutoGen(self,mqueue, DataPipe,SkipAutoGen,PcdMaList,share_data):
         if SkipAutoGen:
             return
         feedback_q = mp.Queue()
         file_lock = mp.Lock()
-        auto_workers = [AutoGenWorkerInProcess(mqueue,DataPipe.dump_file,feedback_q,file_lock) for _ in range(mp.cpu_count()//2)]
+        auto_workers = [AutoGenWorkerInProcess(mqueue,DataPipe.dump_file,feedback_q,file_lock,share_data) for _ in range(mp.cpu_count()//2)]
         self.AutoGenMgr = AutoGenManager(auto_workers,feedback_q)
         self.AutoGenMgr.start()
         for w in auto_workers:
             w.start()
         if PcdMaList is not None:
@@ -1227,11 +1229,11 @@ class Build():
 
             AutoGenObject.DataPipe.DataContainer = {"FfsCommand":FfsCommand}
             self.Progress.Start("Generating makefile and code")
             data_pipe_file = os.path.join(self.WorkspaceDir, "GlobalVar_%s_%s.bin" % (str(AutoGenObject.Guid),AutoGenObject.Arch))
             AutoGenObject.DataPipe.dump(data_pipe_file)
-            autogen_rt = self.StartAutoGen(mqueue, AutoGenObject.DataPipe, self.SkipAutoGen, PcdMaList)
+            autogen_rt = self.StartAutoGen(mqueue, AutoGenObject.DataPipe, self.SkipAutoGen, PcdMaList,self.share_data)
             self.Progress.Stop("done!")
             return autogen_rt
         else:
             # always recreate top/platform makefile when clean, just in case of inconsistency
             AutoGenObject.CreateCodeFile(False)
@@ -2059,11 +2061,11 @@ class Build():
                     for m in Pa.GetAllModuleInfo:
                         mqueue.put(m)
                     Pa.DataPipe.DataContainer = {"FfsCommand":CmdListDict}
                     data_pipe_file = os.path.join(self.WorkspaceDir, "GlobalVar_%s_%s.bin" % (str(Pa.Guid),Pa.Arch))
                     Pa.DataPipe.dump(data_pipe_file)
-                    autogen_rt = self.StartAutoGen(mqueue, Pa.DataPipe, self.SkipAutoGen, PcdMaList)
+                    autogen_rt = self.StartAutoGen(mqueue, Pa.DataPipe, self.SkipAutoGen, PcdMaList,self.share_data)
                     self.Progress.Stop("done!")
                     self.AutoGenTime += int(round((time.time() - AutoGenStart)))
                     if not autogen_rt:
                         return
                 for Arch in Wa.ArchList:
-- 
2.20.1.windows.1


  parent reply	other threads:[~2019-07-18  6:14 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-18  6:14 [Patch 0/9] Enable multiple process AutoGen Bob Feng
2019-07-18  6:14 ` [Patch 1/9] BaseTools: Singleton the object to handle build conf file Bob Feng
2019-07-18  6:14 ` [Patch 2/9] BaseTools: Split WorkspaceAutoGen._InitWorker into multiple functions Bob Feng
2019-07-18  6:14 ` [Patch 3/9] BaseTools: Add functions to get platform scope build options Bob Feng
2019-07-18  6:14 ` [Patch 4/9] BaseTools: Decouple AutoGen Objects Bob Feng
2019-07-18  6:14 ` [Patch 5/9] BaseTools: Enable Multiple Process AutoGen Bob Feng
2019-07-18  6:14 ` Bob Feng [this message]
2019-07-18  6:14 ` [Patch 7/9] BaseTools: Add LogAgent to support multiple process Autogen Bob Feng
2019-07-18  6:14 ` [Patch 8/9] BaseTools: Move BuildOption parser out of build.py Bob Feng
2019-07-18  6:14 ` [Patch 9/9] BaseTools: Add the support for python 2 Bob Feng
2019-07-21 12:26 ` [edk2-devel] [Patch 0/9] Enable multiple process AutoGen Laszlo Ersek
2019-07-21 15:55   ` Steven Shi
2019-07-22  9:11   ` Bob Feng
2019-07-22 19:50     ` Laszlo Ersek

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190718061423.30612-7-bob.c.feng@intel.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox