|
42 | 42 | from libensemble.sim_funcs.var_resources import gpu_variable_resources_from_gen as sim_f |
43 | 43 | from libensemble.tools import add_unique_random_streams, parse_args |
44 | 44 |
|
| 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 | + |
45 | 51 | # from libensemble import logger |
46 | 52 | # logger.set_level("DEBUG") # For testing the test |
47 | 53 |
|
|
100 | 106 | libE_specs["resource_info"] = {"cores_on_node": (nworkers * 2, nworkers * 4), "gpus_on_node": nworkers} |
101 | 107 |
|
102 | 108 | 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 | + ) |
128 | 136 |
|
129 | 137 | # All asserts are in gen and sim funcs |
0 commit comments