def test_format_env(): env_vars = {"OMP_NUM_THREADS": 20, "LOGGING": "verbose"} settings = AprunSettings("python", env_vars=env_vars) settings.update_env({"OMP_NUM_THREADS": 10}) formatted = settings.format_env_vars() result = ["-e", "OMP_NUM_THREADS=10", "-e", "LOGGING=verbose"] assert formatted == result
def test_aprun_args(): run_args = { "z": None, # single letter no value "sync-output": None, # long no value "wdir": "/some/path", # restricted var "pes": 5, } settings = AprunSettings("python", run_args=run_args) formatted = settings.format_run_args() result = ["-z", "--sync-output", "--pes=5"] assert formatted == result
def test_aprun_settings(): settings = AprunSettings("python") settings.set_cpus_per_task(2) settings.set_tasks(100) settings.set_tasks_per_node(20) formatted = settings.format_run_args() result = ["--cpus-per-pe=2", "--pes=100", "--pes-per-node=20"] assert formatted == result
def create_throughput_session(nodes, tasks, db, _bytes): """Create a scaling session using the C++ driver with the SmartRedis client :param nodes: number of nodes for the client driver :type nodes: int :param tasks: number of tasks for each client driver :type tasks: int :param db: number of database nodes :type db: int :param bytes: the tensor size in bytes :type bytes: int :return: created Model instance :rtype: Model """ if WLM == "pbs": run = AprunSettings("./build/throughput", str(_bytes)) run.set_tasks(nodes * tasks) elif WLM == "slurm": run = SrunSettings("./build/throughput", str(_bytes)) run.set_tasks_per_node(tasks) else: raise Exception("WLM not supported") name = "-".join( ("throughput-sess", str(nodes), str(tasks), str(_bytes), str(db))) model = exp.create_model(name, run) model.attach_generator_files(to_copy=["./process_results.py"]) exp.generate(model, overwrite=True) return model
def get_run_settings(exe, args, nodes=1, ntasks=1, **kwargs): if test_launcher == "slurm": run_args = {"nodes": nodes, "ntasks": ntasks, "time": "00:10:00"} run_args.update(kwargs) settings = SrunSettings(exe, args, run_args=run_args) return settings elif test_launcher == "pbs": run_args = {"pes": ntasks} run_args.update(kwargs) settings = AprunSettings(exe, args, run_args=run_args) return settings # TODO allow user to pick aprun vs MPIrun elif test_launcher == "cobalt": run_args = {"pes": ntasks} run_args.update(kwargs) settings = AprunSettings(exe, args, run_args=run_args) return settings else: return RunSettings(exe, args)
def test_launch_pbs_mpmd(): """test the launch of a aprun MPMD workload this test will obtain an allocation as a batch workload. Aprun MPMD workloads share an output file for all processes and they share MPI_COMM_WORLDs. Prior to running this test, hw_mpi.c in test_configs needs to be compiled. #TODO write a script for this. """ exp = Experiment("pbs-test", launcher="pbs") run_args = {"pes": 1, "pes-per-node": 1} aprun = AprunSettings("./hellow", run_args=run_args) aprun2 = AprunSettings("./hellow", run_args=run_args) aprun.make_mpmd(aprun2) model = exp.create_model("hello_world", run_settings=aprun) qsub = QsubBatchSettings(nodes=2, ppn=1, time="1:00:00") ensemble = exp.create_ensemble("ensemble", batch_settings=qsub) ensemble.add_model(model) exp.start(ensemble)
def create_post_process(model_path, name): """Create a Model to post process the throughput results :param model_path: path to model output data :type model_path: str :param name: name of the model :type name: str :return: created post processing model :rtype: Model """ exe_args = f"process_results.py --path={model_path} --name={name}" if WLM == "pbs": run = AprunSettings("python", exe_args=exe_args) run.set_tasks(1) elif WLM == "slurm": run = SrunSettings("python", exe_args=exe_args) run.set_tasks(1) else: raise Exception("WLM not supported") pp_name = "-".join(("post", name)) post_process = exp.create_model(pp_name, run, path=model_path) return post_process
def test_aprun_add_mpmd(): settings = AprunSettings("python") settings_2 = AprunSettings("python") settings.make_mpmd(settings_2) assert len(settings.mpmd) > 0 assert settings.mpmd[0] == settings_2