Skip to content

Commit e52c5cf

Browse files
committed
EAMxx: allow non-contiguous set of cpus in test-all-scream
1 parent a269ef9 commit e52c5cf

File tree

1 file changed

+13
-15
lines changed

1 file changed

+13
-15
lines changed

components/eamxx/scripts/test_all_scream.py

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ def generate_cmake_config(self, test, for_ctest=False):
398398
return result
399399

400400
###############################################################################
401-
def get_taskset_range(self, test, for_compile=True):
401+
def get_taskset_resources(self, test, for_compile=True):
402402
###############################################################################
403403
res_name = "compile_res_count" if for_compile else "testing_res_count"
404404

@@ -419,13 +419,11 @@ def get_taskset_range(self, test, for_compile=True):
419419

420420
expect(offset < len(affinity_cp),
421421
f"Offset {offset} out of bounds (max={len(affinity_cp)}) for test {test}\naffinity_cp: {affinity_cp}")
422-
start = affinity_cp[offset]
423-
end = start
424-
for i in range(1, getattr(test, res_name)):
425-
expect(affinity_cp[offset+i] == start+i, f"Could not get contiguous range for test {test}")
426-
end = affinity_cp[offset+i]
422+
resources = []
423+
for i in range(0, getattr(test, res_name)):
424+
resources.append(affinity_cp[offset+i])
427425

428-
return start, end
426+
return resources
429427

430428
###############################################################################
431429
def create_ctest_resource_file(self, test, build_dir):
@@ -438,7 +436,7 @@ def create_ctest_resource_file(self, test, build_dir):
438436
# res group is where we usually bind an individual MPI rank.
439437
# The id of the res groups on is offset so that it is unique across all builds
440438

441-
start, end = self.get_taskset_range(test, for_compile=False)
439+
resources = self.get_taskset_resources(test, for_compile=False)
442440

443441
data = {}
444442

@@ -448,7 +446,7 @@ def create_ctest_resource_file(self, test, build_dir):
448446
# We add leading zeroes to ensure that ids will sort correctly
449447
# both alphabetically and numerically
450448
devices = []
451-
for res_id in range(start,end+1):
449+
for res_id in resources:
452450
devices.append({"id":f"{res_id:05d}"})
453451

454452
# Add resource groups
@@ -457,7 +455,7 @@ def create_ctest_resource_file(self, test, build_dir):
457455
with (build_dir/"ctest_resource_file.json").open("w", encoding="utf-8") as outfile:
458456
json.dump(data,outfile,indent=2)
459457

460-
return (end-start)+1
458+
return len(resources)
461459

462460
###############################################################################
463461
def generate_ctest_config(self, cmake_config, extra_configs, test):
@@ -498,11 +496,11 @@ def generate_ctest_config(self, cmake_config, extra_configs, test):
498496

499497
# Ctest can only competently manage test pinning across a single instance of ctest. For
500498
# multiple concurrent instances of ctest, we have to help it. It's OK to use the compile_res_count
501-
# taskset range even though the ctest script is also running the tests
499+
# taskset resources even though the ctest script is also running the tests
502500
if self._parallel:
503-
start, end = self.get_taskset_range(test)
501+
resources = self.get_taskset_resources(test)
504502
result = result.replace("'", r"'\''") # handle nested quoting
505-
result = f"taskset -c {start}-{end} sh -c '{result}'"
503+
result = f"taskset -c {','.join([str(r) for r in resources])} sh -c '{result}'"
506504

507505
return result
508506

@@ -539,8 +537,8 @@ def generate_baselines(self, test):
539537

540538
cmd = f"make -j{test.compile_res_count}"
541539
if self._parallel:
542-
start, end = self.get_taskset_range(test)
543-
cmd = f"taskset -c {start}-{end} sh -c '{cmd}'"
540+
resources = self.get_taskset_resources(test)
541+
cmd = f"taskset -c {','.join([str(r) for r in resources])} sh -c '{cmd}'"
544542

545543
stat, _, err = run_cmd(cmd, from_dir=test_dir, verbose=True)
546544

0 commit comments

Comments
 (0)