Skip to content

Commit

Permalink
foresee the use of MPI also in serial run
Browse files Browse the repository at this point in the history
  • Loading branch information
dodu94 committed Feb 19, 2025
1 parent b0610c7 commit 819cf01
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions src/jade/run/benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,11 +157,7 @@ def run(self, env_vars: EnvironmentVariables, sim_folder: PathLike) -> bool:

flagnotrun = False
if env_vars.run_mode == RunMode.JOB_SUMISSION:
if env_vars.mpi_tasks is not None and env_vars.mpi_tasks > 1:
if env_vars.mpi_prefix is None:
raise ConfigError(
"MPI prefix is needed for MPI job submission, please provide one"
)
if self._is_mpi_run(env_vars):
run_command.insert(0, env_vars.mpi_prefix)
self._submit_job(env_vars, sim_folder, run_command, lib_data_command)

Expand All @@ -170,6 +166,9 @@ def run(self, env_vars: EnvironmentVariables, sim_folder: PathLike) -> bool:
# in case of run in console dump the prints to a file
# to get the code version in the metadata
run_command.append(" > dump.out")
if self._is_mpi_run(env_vars):
run_command.insert(0, f"-np {env_vars.mpi_tasks}")
run_command.insert(0, env_vars.mpi_prefix)
if not sys.platform.startswith("win"):
unix.configure(env_vars.code_configurations[self.code])
print(" ".join(run_command))
Expand All @@ -188,6 +187,15 @@ def run(self, env_vars: EnvironmentVariables, sim_folder: PathLike) -> bool:

return flagnotrun

def _is_mpi_run(self, env_vars: EnvironmentVariables) -> bool:
if env_vars.mpi_tasks is not None and env_vars.mpi_tasks > 1:
if env_vars.mpi_prefix is None:
raise ConfigError(
"MPI prefix is needed for MPI job submission, please provide one"
)
return True
return False

def _submit_job(
self,
env_vars: EnvironmentVariables,
Expand Down

0 comments on commit 819cf01

Please sign in to comment.