From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.120; helo=mga04.intel.com; envelope-from=yunhuax.feng@intel.com; receiver=edk2-devel@lists.01.org Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 731982035D324 for ; Mon, 8 Jan 2018 18:08:36 -0800 (PST) X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 08 Jan 2018 18:13:46 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,333,1511856000"; d="dat'59?scan'59,208,59";a="8320045" Received: from fmsmsx104.amr.corp.intel.com ([10.18.124.202]) by fmsmga008.fm.intel.com with ESMTP; 08 Jan 2018 18:13:46 -0800 Received: from fmsmsx118.amr.corp.intel.com (10.18.116.18) by fmsmsx104.amr.corp.intel.com (10.18.124.202) with Microsoft SMTP Server (TLS) id 14.3.319.2; Mon, 8 Jan 2018 18:13:46 -0800 Received: from shsmsx101.ccr.corp.intel.com (10.239.4.153) by fmsmsx118.amr.corp.intel.com (10.18.116.18) with Microsoft SMTP Server (TLS) id 14.3.319.2; Mon, 8 Jan 2018 18:13:45 -0800 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.189]) by SHSMSX101.ccr.corp.intel.com ([169.254.1.159]) with mapi id 14.03.0319.002; Tue, 9 Jan 2018 10:13:43 +0800 From: "Feng, YunhuaX" To: "edk2-devel@lists.01.org" CC: "Feng, YunhuaX" , "Zhu, Yonghong" , "Gao, Liming" Thread-Topic: [PATCH] BaseTools: Enable MAX_CONCURRENT_THREAD_NUMBER = 0 feature Thread-Index: AdOI7vrsrX91X5TkRSqLZ78xTbEIFQ== Date: Tue, 9 Jan 2018 02:13:42 +0000 Message-ID: <47C64442C08CCD4089DC43B6B5E46BC4818F51@shsmsx102.ccr.corp.intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: <47C64442C08CCD4089DC43B6B5E46BC4818F51@shsmsx102.ccr.corp.intel.com> x-originating-ip: [10.239.127.40] MIME-Version: 1.0 X-Mailman-Approved-At: Tue, 09 Jan 2018 03:09:43 -0800 X-Content-Filtered-By: Mailman/MimeDel 2.1.23 Subject: [PATCH] BaseTools: Enable MAX_CONCURRENT_THREAD_NUMBER = 0 feature X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 09 Jan 2018 02:08:36 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Adding 'MAX_CONCURRENT_THREAD_NUMBER=3D0' option for user to enable 'auto-detect thread number' feature, and changing default value=20 to '0' when initial build environment is configured. Fixes: https://bugzilla.tianocore.org/show_bug.cgi?id=3D775 Cc: Liming Gao Cc: Yonghong Zhu Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Yunhua Feng --- 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 =3D MYTOOLS =20 # MAX_CONCURRENT_THREAD_NUMBER NUMBER Optional The number of concurrent= threads. Recommend to set this # value to one more than t= he number of your compurter -# cores or CPUs. Less than= 2 means disable multithread build. -MAX_CONCURRENT_THREAD_NUMBER =3D 1 +# cores or CPUs. automatic= ally detect number of processor threads +# when 'MAX_CONCURRENT_THR= EAD_NUMBER=3D0' +MAX_CONCURRENT_THREAD_NUMBER =3D 0 =20 =20 # 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/b= uild/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 =20 from struct import * from threading import * @@ -936,7 +937,10 @@ class Build(): self.ThreadNumber =3D int(self.ThreadNumber, 0) =20 if self.ThreadNumber =3D=3D 0: - self.ThreadNumber =3D 1 + try: + self.ThreadNumber =3D multiprocessing.cpu_count() + except (ImportError, NotImplementedError): + self.ThreadNumber =3D 1 =20 if not self.PlatformFile: PlatformFile =3D self.TargetTxt.TargetTxtDictionary[DataType.T= AB_TAT_DEFINES_ACTIVE_PLATFORM] --=20 2.12.2.windows.2