Add two-node MPI launch configuration
This commit is contained in:
@@ -71,6 +71,28 @@ def build_twopuncture_runtime_env():
|
||||
return runtime_env
|
||||
|
||||
|
||||
def build_mpi_launch_args():
|
||||
"""Build optional host-distribution arguments for mpirun."""
|
||||
hosts = list(getattr(input_data, "MPI_hosts", []))
|
||||
ppn = int(getattr(input_data, "MPI_processes_per_node", 0))
|
||||
|
||||
if not hosts:
|
||||
return ""
|
||||
|
||||
if ppn > 0:
|
||||
expected = len(hosts) * ppn
|
||||
if int(input_data.MPI_processes) != expected:
|
||||
raise ValueError(
|
||||
f"MPI_processes={input_data.MPI_processes} does not match "
|
||||
f"len(MPI_hosts) * MPI_processes_per_node = {expected}"
|
||||
)
|
||||
|
||||
launch_args = f"-hosts {','.join(hosts)}"
|
||||
if ppn > 0:
|
||||
launch_args += f" -ppn {ppn}"
|
||||
return launch_args
|
||||
|
||||
|
||||
##################################################################
|
||||
|
||||
|
||||
@@ -161,16 +183,26 @@ def run_ABE():
|
||||
print( " Running the AMSS-NCKU executable file ABE/ABEGPU " )
|
||||
print( )
|
||||
print( f" MPI processes = {input_data.MPI_processes}, OMP threads per process = {max(1, int(getattr(input_data, 'OMP_Threads', 1)))}" )
|
||||
if getattr(input_data, "MPI_hosts", []):
|
||||
print( f" MPI hosts = {getattr(input_data, 'MPI_hosts', [])}, MPI ranks per node = {int(getattr(input_data, 'MPI_processes_per_node', 0))}" )
|
||||
print( " Multi-node runs require the working directory to be visible on all MPI hosts. " )
|
||||
print( )
|
||||
|
||||
## Define the command to run; cast other values to strings as needed
|
||||
mpi_launch_args = build_mpi_launch_args()
|
||||
|
||||
if (input_data.GPU_Calculation == "no"):
|
||||
mpi_command = NUMACTL_CPU_BIND + " mpirun -np " + str(input_data.MPI_processes) + " ./ABE"
|
||||
mpi_command = NUMACTL_CPU_BIND + " mpirun "
|
||||
if mpi_launch_args:
|
||||
mpi_command += mpi_launch_args + " "
|
||||
mpi_command += "-np " + str(input_data.MPI_processes) + " ./ABE"
|
||||
#mpi_command = " mpirun -np " + str(input_data.MPI_processes) + " ./ABE"
|
||||
mpi_command_outfile = "ABE_out.log"
|
||||
elif (input_data.GPU_Calculation == "yes"):
|
||||
mpi_command = NUMACTL_CPU_BIND + " mpirun -np " + str(input_data.MPI_processes) + " ./ABEGPU"
|
||||
mpi_command = NUMACTL_CPU_BIND + " mpirun "
|
||||
if mpi_launch_args:
|
||||
mpi_command += mpi_launch_args + " "
|
||||
mpi_command += "-np " + str(input_data.MPI_processes) + " ./ABEGPU"
|
||||
mpi_command_outfile = "ABEGPU_out.log"
|
||||
|
||||
## Execute the MPI command and stream output
|
||||
|
||||
Reference in New Issue
Block a user