13
13
from easybuild .tools .run import run_cmd
14
14
from easybuild .tools .systemtools import AARCH64 , POWER , X86_64 , get_cpu_architecture , get_cpu_features
15
15
from easybuild .tools .toolchain .compiler import OPTARCH_GENERIC
16
+ from easybuild .tools .version import VERSION as EASYBUILD_VERSION
16
17
17
18
# prefer importing LooseVersion from easybuild.tools, but fall back to distuils in case EasyBuild <= 4.7.0 is used
18
19
try :
@@ -126,9 +127,15 @@ def post_ready_hook(self, *args, **kwargs):
126
127
Post-ready hook: limit parallellism for selected builds based on software name and CPU target.
127
128
parallelism needs to be limited because some builds require a lot of memory per used core.
128
129
"""
129
- # 'parallel' easyconfig parameter is set via EasyBlock.set_parallel in ready step based on available cores.
130
+ # 'parallel' (EB4) or 'max_parallel' (EB5) easyconfig parameter is set via EasyBlock.set_parallel in ready step
131
+ # based on available cores.
132
+
133
+ # Check whether we have EasyBuild 4 or 5
134
+ parallel_param = 'parallel'
135
+ if EASYBUILD_VERSION >= '5' :
136
+ parallel_param = 'max_parallel'
130
137
# get current parallelism setting
131
- parallel = self .cfg ['parallel' ]
138
+ parallel = self .cfg [parallel_param ]
132
139
if parallel == 1 :
133
140
return # no need to limit if already using 1 core
134
141
@@ -152,7 +159,7 @@ def post_ready_hook(self, *args, **kwargs):
152
159
153
160
# apply the limit if it's different from current
154
161
if new_parallel != parallel :
155
- self .cfg ['parallel' ] = new_parallel
162
+ self .cfg [parallel_param ] = new_parallel
156
163
msg = "limiting parallelism to %s (was %s) for %s on %s to avoid out-of-memory failures during building/testing"
157
164
print_msg (msg % (new_parallel , parallel , self .name , cpu_target ), log = self .log )
158
165
0 commit comments