Skip to content

Commit 45d8f28

Browse files
authored
Merge pull request #3557 from Flamefire/parallel_prop
Update easyblocks to use `EasyConfig.parallel` property
2 parents 4edfdbe + 4d490fc commit 45d8f28

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+88
-128
lines changed

easybuild/easyblocks/a/adf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def install_step(self):
8080
except OSError as err:
8181
raise EasyBuildError("Failed to copy %s to %s: %s", src_init_path, target_init_path, err)
8282

83-
cmd = "./bin/foray -j %d" % self.cfg['parallel']
83+
cmd = f"./bin/foray -j {self.cfg.parallel}"
8484
run_shell_cmd(cmd)
8585

8686
def sanity_check_step(self):

easybuild/easyblocks/a/aomp.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,7 @@ def configure_step(self):
8585
'AOMP_APPLY_ROCM_PATCHES=0',
8686
'AOMP_STANDALONE_BUILD=1',
8787
]
88-
if self.cfg['parallel']:
89-
install_options.append(
90-
'NUM_THREADS={!s}'.format(self.cfg['parallel']))
91-
else:
92-
install_options.append('NUM_THREADS=1')
88+
install_options.append(f'NUM_THREADS={self.cfg.parallel}')
9389
# Check if CUDA is loaded and alternatively build CUDA backend
9490
if get_software_root('CUDA') or get_software_root('CUDAcore'):
9591
cuda_root = get_software_root('CUDA') or get_software_root('CUDAcore')

easybuild/easyblocks/b/bazel.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ def configure_step(self):
158158
])
159159

160160
# enable building in parallel
161-
bazel_args = '--jobs=%d' % self.cfg['parallel']
161+
bazel_args = f'--jobs={self.cfg.parallel}'
162162

163163
# Bazel provides a JDK by itself for some architectures
164164
# We want to enforce it using the JDK we provided via modules
@@ -206,7 +206,7 @@ def test_step(self):
206206
# Avoid bazel using $HOME
207207
'--output_user_root=%s' % self.output_user_root,
208208
runtest,
209-
'--jobs=%d' % self.cfg['parallel'],
209+
f'--jobs={self.cfg.parallel}',
210210
'--host_javabase=@local_jdk//:jdk',
211211
# Be more verbose
212212
'--subcommands', '--verbose_failures',

easybuild/easyblocks/b/berkeleygw.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def configure_step(self):
6262
def build_step(self):
6363
"""Custom build step for BerkeleyGW."""
6464

65-
self.cfg['parallel'] = 1
65+
self.cfg.parallel = 1
6666

6767
self.cfg['buildopts'] = 'all-flavors'
6868

easybuild/easyblocks/b/boost.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,8 +227,8 @@ def build_step(self):
227227
self.bjamoptions += " -s%s_INCLUDE=%s/include" % (lib.upper(), libroot)
228228
self.bjamoptions += " -s%s_LIBPATH=%s/lib" % (lib.upper(), libroot)
229229

230-
if self.cfg['parallel']:
231-
self.paracmd = "-j %s" % self.cfg['parallel']
230+
if self.cfg.parallel > 1:
231+
self.paracmd = f"-j {self.cfg.parallel}"
232232
else:
233233
self.paracmd = ''
234234

easybuild/easyblocks/c/clang.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,6 @@ def __init__(self, *args, **kwargs):
124124
self.llvm_obj_dir_stage1 = None
125125
self.llvm_obj_dir_stage2 = None
126126
self.llvm_obj_dir_stage3 = None
127-
self.make_parallel_opts = ""
128127
self.runtime_lib_path = "lib"
129128

130129
# Bypass the .mod file check for GCCcore installs
@@ -404,9 +403,6 @@ def configure_step(self):
404403

405404
self.cfg.update('configopts', '-DLLVM_TARGETS_TO_BUILD="%s"' % ';'.join(build_targets))
406405

407-
if self.cfg['parallel']:
408-
self.make_parallel_opts = "-j %s" % self.cfg['parallel']
409-
410406
# If hwloc is included as a dep, use it in OpenMP runtime for affinity
411407
hwloc_root = get_software_root('hwloc')
412408
if hwloc_root:
@@ -554,7 +550,7 @@ def build_with_prev_stage(self, prev_obj, next_obj):
554550
run_shell_cmd("cmake %s %s" % (' '.join(options), self.llvm_src_dir))
555551

556552
self.log.info("Building")
557-
run_shell_cmd("make %s VERBOSE=1" % self.make_parallel_opts)
553+
run_shell_cmd(f"make {self.parallel_flag} VERBOSE=1")
558554

559555
# restore $PATH
560556
setvar('PATH', orig_path)
@@ -581,7 +577,7 @@ def test_step(self):
581577
change_dir(self.llvm_obj_dir_stage3)
582578
else:
583579
change_dir(self.llvm_obj_dir_stage1)
584-
run_shell_cmd("make %s check-all" % self.make_parallel_opts)
580+
run_shell_cmd(f"make {self.parallel_flag} check-all")
585581

586582
def install_step(self):
587583
"""Install stage 3 binaries."""

easybuild/easyblocks/c/cp2k.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -669,18 +669,17 @@ def build_step(self):
669669
change_dir(makefiles)
670670

671671
# modify makefile for parallel build
672-
parallel = self.cfg['parallel']
673-
if parallel:
674-
672+
parallel = self.cfg.parallel
673+
if parallel > 1:
675674
try:
676675
for line in fileinput.input('Makefile', inplace=1, backup='.orig.patchictce'):
677-
line = re.sub(r"^PMAKE\s*=.*$", "PMAKE\t= $(SMAKE) -j %s" % parallel, line)
676+
line = re.sub(r"^PMAKE\s*=.*$", f"PMAKE\t= $(SMAKE) -j {parallel}", line)
678677
sys.stdout.write(line)
679678
except IOError as err:
680679
raise EasyBuildError("Can't modify/write Makefile in %s: %s", makefiles, err)
681680

682681
# update make options with MAKE
683-
self.cfg.update('buildopts', 'MAKE="make -j %s"' % self.cfg['parallel'])
682+
self.cfg.update('buildopts', f'MAKE="make -j {self.cfg.parallel}"')
684683

685684
# update make options with ARCH and VERSION
686685
self.cfg.update('buildopts', 'ARCH=%s VERSION=%s' % (self.typearch, self.cfg['type']))
@@ -757,7 +756,7 @@ def test_step(self):
757756
self.log.info("No reference output found for regression test, just continuing without it...")
758757

759758
# prefer using 4 cores, since some tests require/prefer square (n^2) numbers or powers of 2 (2^n)
760-
test_core_cnt = min(self.cfg['parallel'], 4)
759+
test_core_cnt = min(self.cfg.parallel, 4)
761760
if get_avail_core_count() < test_core_cnt:
762761
raise EasyBuildError("Cannot run MPI tests as not enough cores (< %s) are available", test_core_cnt)
763762
else:

easybuild/easyblocks/d/dm_reverb.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ def build_step(self, *args, **kwargs):
9191
# use JDK from EB
9292
bazel_build_opts += " --host_javabase=@local_jdk//:jdk"
9393
# explicitly set the number of processes
94-
bazel_build_opts += " --jobs=%d" % self.cfg['parallel']
94+
bazel_build_opts += f" --jobs={self.cfg.parallel}"
9595
# print full compilation commands
9696
bazel_build_opts += " --subcommands"
9797

easybuild/easyblocks/f/flook.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def __init__(self, *args, **kwargs):
5555
else:
5656
local_comp_flags = 'FFLAGS="$FFLAGS" CFLAGS="$CFLAGS"'
5757
self.cfg.update('buildopts', 'liball %s' % local_comp_flags)
58-
self.cfg['parallel'] = 1
58+
self.cfg.parallel = 1
5959

6060
def configure_step(self):
6161
# flook has no configure step

easybuild/easyblocks/g/gamess_us.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -427,11 +427,11 @@ def test_step(self):
427427
return
428428

429429
# MPI builds can only run tests that support parallel execution
430-
if int(self.cfg['parallel']) < 2:
430+
if self.cfg.parallel < 2:
431431
self.log.info("Skipping testing of GAMESS-US as MPI tests need at least 2 CPU cores to run")
432432
return
433433

434-
test_procs = str(self.cfg['parallel'])
434+
test_procs = str(self.cfg.parallel)
435435
target_tests = [exam for exam in target_tests if exam[0] not in GAMESS_SERIAL_TESTS]
436436

437437
if self.toolchain.mpi_family() == toolchain.INTELMPI:

0 commit comments

Comments
 (0)