mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 21:14:14 +08:00
Simplify handling of max jobs in CMake builds (#145820)
Fixes #ISSUE_NUMBER Pull Request resolved: https://github.com/pytorch/pytorch/pull/145820 Approved by: https://github.com/malfet
This commit is contained in:
@ -377,15 +377,6 @@ class CMake:
|
||||
# os.sched_getaffinity(0) on platforms that support it.
|
||||
max_jobs = max_jobs or str(multiprocessing.cpu_count())
|
||||
|
||||
# This ``if-else'' clause would be unnecessary when cmake
|
||||
# 3.12 becomes minimum, which provides a '-j' option:
|
||||
# build_args += ['-j', max_jobs] would be sufficient by
|
||||
# then. Until then, we use "--" to pass parameters to the
|
||||
# underlying build system.
|
||||
build_args += ["--"]
|
||||
if IS_WINDOWS and not USE_NINJA:
|
||||
# We are likely using msbuild here
|
||||
build_args += [f"/p:CL_MPCount={max_jobs}"]
|
||||
else:
|
||||
build_args += ["-j", max_jobs]
|
||||
# CMake 3.12 provides a '-j' option.
|
||||
build_args += ["-j", max_jobs]
|
||||
self.run(build_args, my_env)
|
||||
|
@ -30,8 +30,8 @@ class TestCMake(unittest.TestCase):
|
||||
((None, False, False), ["-j", "13"]), # noqa: E201,E241
|
||||
(("6", True, True), ["-j", "6"]), # noqa: E201,E241
|
||||
((None, True, True), None), # noqa: E201,E241
|
||||
(("11", False, True), ["/p:CL_MPCount=11"]), # noqa: E201,E241
|
||||
((None, False, True), ["/p:CL_MPCount=13"]), # noqa: E201,E241
|
||||
(("11", False, True), ["-j", "11"]), # noqa: E201,E241
|
||||
((None, False, True), ["-j", "13"]), # noqa: E201,E241
|
||||
]
|
||||
for (max_jobs, use_ninja, is_windows), want in cases:
|
||||
with self.subTest(
|
||||
|
Reference in New Issue
Block a user