BaseTools/Conf/target.template | 5 +++-- BaseTools/Source/Python/build/build.py | 6 +++++- 2 files changed, 8 insertions(+), 3 deletions(-)
Adding 'MAX_CONCURRENT_THREAD_NUMBER=0' option for user to
enable 'auto-detect thread number' feature, and changing default value
to '0' when initial build environment is configured.
Fixes: https://bugzilla.tianocore.org/show_bug.cgi?id=775
Cc: Liming Gao <liming.gao@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Yunhua Feng <yunhuax.feng@intel.com>
---
BaseTools/Conf/target.template | 5 +++--
BaseTools/Source/Python/build/build.py | 6 +++++-
2 files changed, 8 insertions(+), 3 deletions(-)
diff --git BaseTools/Conf/target.template BaseTools/Conf/target.template
index 787fc64fb1..ee8745610f 100644
--- BaseTools/Conf/target.template
+++ BaseTools/Conf/target.template
@@ -61,8 +61,9 @@ TOOL_CHAIN_TAG = MYTOOLS
# MAX_CONCURRENT_THREAD_NUMBER NUMBER Optional The number of concurrent threads. Recommend to set this
# value to one more than the number of your compurter
-# cores or CPUs. Less than 2 means disable multithread build.
-MAX_CONCURRENT_THREAD_NUMBER = 1
+# cores or CPUs. automatically detect number of processor threads
+# when 'MAX_CONCURRENT_THREAD_NUMBER=0'
+MAX_CONCURRENT_THREAD_NUMBER = 0
# BUILD_RULE_CONF Filename Optional Specify the file name to use for the build rules that are followed
diff --git BaseTools/Source/Python/build/build.py BaseTools/Source/Python/build/build.py
index 38498046d7..fd2681e05d 100644
--- BaseTools/Source/Python/build/build.py
+++ BaseTools/Source/Python/build/build.py
@@ -26,6 +26,7 @@ import platform
import traceback
import encodings.ascii
import itertools
+import multiprocessing
from struct import *
from threading import *
@@ -936,7 +937,10 @@ class Build():
self.ThreadNumber = int(self.ThreadNumber, 0)
if self.ThreadNumber == 0:
- self.ThreadNumber = 1
+ try:
+ self.ThreadNumber = multiprocessing.cpu_count()
+ except (ImportError, NotImplementedError):
+ self.ThreadNumber = 1
if not self.PlatformFile:
PlatformFile = self.TargetTxt.TargetTxtDictionary[DataType.TAB_TAT_DEFINES_ACTIVE_PLATFORM]
--
2.12.2.windows.2
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel
Hi Yunhua, Please separate this patch into two. And remember to update copyright year. Best Regards, Zhu Yonghong -----Original Message----- From: Feng, YunhuaX Sent: Tuesday, January 09, 2018 10:14 AM To: edk2-devel@lists.01.org Cc: Feng, YunhuaX <yunhuax.feng@intel.com>; Zhu, Yonghong <yonghong.zhu@intel.com>; Gao, Liming <liming.gao@intel.com> Subject: [PATCH] BaseTools: Enable MAX_CONCURRENT_THREAD_NUMBER = 0 feature Adding 'MAX_CONCURRENT_THREAD_NUMBER=0' option for user to enable 'auto-detect thread number' feature, and changing default value to '0' when initial build environment is configured. Fixes: https://bugzilla.tianocore.org/show_bug.cgi?id=775 Cc: Liming Gao <liming.gao@intel.com> Cc: Yonghong Zhu <yonghong.zhu@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Yunhua Feng <yunhuax.feng@intel.com> --- BaseTools/Conf/target.template | 5 +++-- BaseTools/Source/Python/build/build.py | 6 +++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git BaseTools/Conf/target.template BaseTools/Conf/target.template index 787fc64fb1..ee8745610f 100644 --- BaseTools/Conf/target.template +++ BaseTools/Conf/target.template @@ -61,8 +61,9 @@ TOOL_CHAIN_TAG = MYTOOLS # MAX_CONCURRENT_THREAD_NUMBER NUMBER Optional The number of concurrent threads. Recommend to set this # value to one more than the number of your compurter -# cores or CPUs. Less than 2 means disable multithread build. -MAX_CONCURRENT_THREAD_NUMBER = 1 +# cores or CPUs. automatically detect number of processor threads +# when 'MAX_CONCURRENT_THREAD_NUMBER=0' +MAX_CONCURRENT_THREAD_NUMBER = 0 # BUILD_RULE_CONF Filename Optional Specify the file name to use for the build rules that are followed diff --git BaseTools/Source/Python/build/build.py BaseTools/Source/Python/build/build.py index 38498046d7..fd2681e05d 100644 --- BaseTools/Source/Python/build/build.py +++ BaseTools/Source/Python/build/build.py @@ -26,6 +26,7 @@ import platform import traceback import encodings.ascii import itertools +import multiprocessing from struct import * from threading import * @@ -936,7 +937,10 @@ class Build(): self.ThreadNumber = int(self.ThreadNumber, 0) if self.ThreadNumber == 0: - self.ThreadNumber = 1 + try: + self.ThreadNumber = multiprocessing.cpu_count() + except (ImportError, NotImplementedError): + self.ThreadNumber = 1 if not self.PlatformFile: PlatformFile = self.TargetTxt.TargetTxtDictionary[DataType.TAB_TAT_DEFINES_ACTIVE_PLATFORM] -- 2.12.2.windows.2 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
© 2016 - 2024 Red Hat, Inc.