Simplified handling of parallel jobs during builds#11524
Simplified handling of parallel jobs during builds#11524tgamblin merged 14 commits intospack:developfrom
Conversation
`spack log-parse` still has its own argument, as it seems to have peculiar ways to set the default value
Apparently the config system has a number of well defined config scopes that can be used. To fix an error during smoke builds on Travis the 'package' and 'builtin' scope have both been changed to '_builtin'
citibeth
left a comment
There was a problem hiding this comment.
I like this! A couple of notes:
-
Looking over the code briefly, I'm not 100% sure how the level of parallelism is set, overridden, determined, etc; but it looks well thought out and should be a big improvement compared to what currently feels like a hack. I'm assuming docs will be added before merge?
-
(Out of scope): it would be great if someday there could be a way to set config parameters directly from the command line. Because right now it seems that command lines and config scopes are two parallel-but-different ways to change Spack's behavior.
adamjstewart
left a comment
There was a problem hiding this comment.
A lot of packages rely on Package.make_jobs:
$ grep make_jobs */package.py
bazel/package.py: elif dependent_spec.package.make_jobs:
bazel/package.py: jobs = dependent_spec.package.make_jobs
boost/package.py: jobs = make_jobs
cbench/package.py: build_env.set('JOBS', str(make_jobs))
charmpp/package.py: "-j%d" % make_jobs,
cmake/package.py: '--parallel={0}'.format(make_jobs)
foam-extend/package.py: os.environ['WM_NCOMPPROCS'] = str(make_jobs)
intel-xed/package.py: args = ['-j', str(make_jobs),
kahip/package.py: filter_file('NCORES=.*', 'NCORES={0}'.format(make_jobs), f)
ninja-fortran/package.py: ninja('-j{0}'.format(make_jobs), 'ninja_test')
ninja/package.py: ninja('-j{0}'.format(make_jobs), 'ninja_test')
of-adios-write/package.py: os.environ['WM_NCOMPPROCS'] = str(make_jobs)
of-precice/package.py: os.environ['WM_NCOMPPROCS'] = str(make_jobs)
openfoam-com/package.py: args.append('-j{0}'.format(make_jobs))
openfoam-org/package.py: os.environ['WM_NCOMPPROCS'] = str(make_jobs)
petsc/package.py: make('MAKE_NP=%s' % make_jobs, parallel=False)
py-numpy/package.py: args = ['-j', str(make_jobs)]
py-pyside/package.py: return ['--jobs={0}'.format(make_jobs)]
py-pytorch/package.py: build_env.set('MAX_JOBS', make_jobs)
py-scipy/package.py: args.extend(['-j', str(make_jobs)])
py-shiboken/package.py: return ['--jobs={0}'.format(make_jobs)]
qt/package.py: spack_env.set('MAKEFLAGS', '-j{0}'.format(make_jobs))
r/package.py: # Use the number of make_jobs set in spack. The make program will
r/package.py: spack_env.set('MAKEFLAGS', '-j{0}'.format(make_jobs))
slepc/package.py: make('MAKE_NP=%s' % make_jobs, parallel=False)
xios/package.py: '--job', str(make_jobs)]I just added another in #11494. I'm fine with removing it as long as there is some other way to access this info inside of a package.
Apparently I missed only spack/lib/spack/spack/build_environment.py Line 418 in 75607eb |
This comment has been minimized.
This comment has been minimized.
|
This doesn't necessarily need to be in the same PR, but something I've always wanted to do is replace |
Codecov Report
@@ Coverage Diff @@
## develop #11524 +/- ##
===========================================
+ Coverage 74.96% 75% +0.03%
===========================================
Files 213 213
Lines 23351 23352 +1
Branches 4578 4576 -2
===========================================
+ Hits 17505 17514 +9
Misses 4726 4726
+ Partials 1120 1112 -8
Continue to review full report at Codecov.
|
Completely agree with that. @tgamblin Let me know if you want me to do the refactoring above here, or if we should leave it for another PR. Also: I left |
tgamblin
left a comment
There was a problem hiding this comment.
looks great to me, modulo the two comments above! Thanks!
If jobs gets passed to the action it's already a valid integer. Once we ruled out that the number is not less than 1 we are ensured it's a good number to set in command line scope
|
Modifications done let me know if anything else is needed. |
|
Thanks @alalazo! |
This PR implements several refactors requested in spack#11373, specifically: - Config scopes are used to handle builtin defaults, command line overrides and package overrides (`parallel=False`) - `Package.make_jobs` attribute has been removed; `make_jobs` remains as a module-scope variable in the build environment. - The use of the argument `-j` has been rationalized across commands - move '-j'/'--jobs' argument into `spack.cmd.common.arguments` - Add unit tests to check that setting parallel jobs works as expected - add new test to ensure that build job setting is isolated to each build - Fix packages that used `Package.make_jobs` (i.e. `bazel`)
This PR implements the refactoring requests in #11373 (comment), in particular:
parallel=False)Package.make_jobsattribute has been removed-jhas been rationalized across commandsPackage.make_jobs(i.e.bazel)