Skip to content

Commit 68b991a

Browse files
committed
run each of the test_GPU_gen_resources tests also with the gen running on manager
1 parent e7591b6 commit 68b991a

1 file changed

Lines changed: 33 additions & 25 deletions

File tree

libensemble/tests/functionality_tests/test_GPU_gen_resources.py

Lines changed: 33 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,12 @@
4242
from libensemble.sim_funcs.var_resources import gpu_variable_resources_from_gen as sim_f
4343
from libensemble.tools import add_unique_random_streams, parse_args
4444

45+
# TODO: multiple libE calls with gen-on-manager currently not supported with spawn on macOS
46+
if sys.platform == "darwin":
47+
from multiprocessing import set_start_method
48+
49+
set_start_method("fork", force=True)
50+
4551
# from libensemble import logger
4652
# logger.set_level("DEBUG") # For testing the test
4753

@@ -100,30 +106,32 @@
100106
libE_specs["resource_info"] = {"cores_on_node": (nworkers * 2, nworkers * 4), "gpus_on_node": nworkers}
101107

102108
base_libE_specs = libE_specs.copy()
103-
for run in range(5):
104-
# reset
105-
libE_specs = base_libE_specs.copy()
106-
persis_info = add_unique_random_streams({}, nworkers + 1)
107-
108-
if run == 0:
109-
libE_specs["gen_num_procs"] = 2
110-
elif run == 1:
111-
libE_specs["gen_num_gpus"] = 1
112-
elif run == 2:
113-
persis_info["gen_num_gpus"] = 1
114-
elif run == 3:
115-
# Two GPUs per resource set
116-
libE_specs["resource_info"]["gpus_on_node"] = nworkers * 2
117-
persis_info["gen_num_gpus"] = 1
118-
elif run == 4:
119-
# Two GPUs requested for gen
120-
persis_info["gen_num_procs"] = 2
121-
persis_info["gen_num_gpus"] = 2
122-
gen_specs["user"]["max_procs"] = max(nworkers - 2, 1)
123-
124-
# Perform the run
125-
H, persis_info, flag = libE(
126-
sim_specs, gen_specs, exit_criteria, persis_info, libE_specs=libE_specs, alloc_specs=alloc_specs
127-
)
109+
for gen_on_manager in [False, True]:
110+
for run in range(5):
111+
# reset
112+
libE_specs = base_libE_specs.copy()
113+
libE_specs["gen_on_manager"] = gen_on_manager
114+
persis_info = add_unique_random_streams({}, nworkers + 1)
115+
116+
if run == 0:
117+
libE_specs["gen_num_procs"] = 2
118+
elif run == 1:
119+
libE_specs["gen_num_gpus"] = 1
120+
elif run == 2:
121+
persis_info["gen_num_gpus"] = 1
122+
elif run == 3:
123+
# Two GPUs per resource set
124+
libE_specs["resource_info"]["gpus_on_node"] = nworkers * 2
125+
persis_info["gen_num_gpus"] = 1
126+
elif run == 4:
127+
# Two GPUs requested for gen
128+
persis_info["gen_num_procs"] = 2
129+
persis_info["gen_num_gpus"] = 2
130+
gen_specs["user"]["max_procs"] = max(nworkers - 2, 1)
131+
132+
# Perform the run
133+
H, persis_info, flag = libE(
134+
sim_specs, gen_specs, exit_criteria, persis_info, libE_specs=libE_specs, alloc_specs=alloc_specs
135+
)
128136

129137
# All asserts are in gen and sim funcs

0 commit comments

Comments
 (0)