libmuscle.native_instantiator.run_script module

libmuscle.native_instantiator.run_script.cluster_command(program: Program, enable_debug: bool) str[source]

Make a format string for the command to run.

This interprets the execution_model and produces an appropriate shell command to start the program. This function produces commands for running on a cluster, with processes distributed across nodes and CPU pinning enabled.

Parameters:
  • program – The program to start.

  • enable_debug – Whether to produce extra debug output.

Returns:

A string with the command to use to start the program.

libmuscle.native_instantiator.run_script.direct_prep_resources(resources: ResourceAssignment) Tuple[str, Dict[str, str]][source]

Create resources for a non-MPI program with taskset.

Taskset expects a set of hwthreads on the command line, either as a comma-separated list or as a hexadecimal mask. We generate both here and set two environment variables.

Parameters:

resources – The resource assignment to describe

Returns:

No rank file, and a set of environment variables.

libmuscle.native_instantiator.run_script.impi_prep_resources(resources: ResourceAssignment) Tuple[str, Dict[str, str]][source]

Create resource description for Intel MPI mpirun

Parameters:

resources – The resource assignment to describe

Returns:

The contents of the machinefile, and a set of environment variables

libmuscle.native_instantiator.run_script.local_command(program: Program, enable_debug: bool) str[source]

Make a format string for the command to run.

This interprets the execution_model and produces an appropriate shell command to start the program. This function produces commands for running locally: pinning is disabled and there’s only one node.

Parameters:
  • program – The program to start.

  • enable_debug – Whether to produce extra debug output.

Returns:

A format string with embedded {ntasks} and {rankfile}.

libmuscle.native_instantiator.run_script.make_script(program: Program, res_req: ResourceRequirements, work_dir: Path, local: bool, rankfile: Path | None = None) str[source]

Make a run script for a given program.

Parameters:
  • program – The program to launch

  • res_req – The job’s resource requirements

  • work_dir – The directory to start the instance in

  • local – Whether this is to run locally (True) or on a cluster (False)

  • rankfile – Location of the rankfile, if any

Returns:

A string with embedded newlines containing the shell script.

libmuscle.native_instantiator.run_script.mpich_prep_resources(resources: ResourceAssignment) Tuple[str, Dict[str, str]][source]

Create resource description for MPICH mpirun

Parameters:

resources – The resource assignment to describe

Returns:

The contents of the machinefile, and a set of environment variables

libmuscle.native_instantiator.run_script.num_mpi_tasks(res_req: ResourceRequirements) int[source]

Determine the number of MPI tasks to be started.

For non-MPI resource requirements, returns 1.

Parameters:

res_req – Resource requirements to analyse.

libmuscle.native_instantiator.run_script.openmpi_prep_resources(resources: ResourceAssignment) Tuple[str, Dict[str, str]][source]

Create resource description for OpenMPI mpirun

Parameters:

resources – The resource assignment to describe

Returns:

The contents of the rankfile, and a set of environment variables

libmuscle.native_instantiator.run_script.prep_resources(model: ExecutionModel, resources: ResourceAssignment, rankfile_location: Path) Tuple[str, Dict[str, str]][source]

Create resource description for the given execution model.

Parameters:
  • model – The execution model to generate a description for

  • resources – The resource assignment to describe

  • rankfile_location – Path to where the rankfile will be written

Returns:

The contents of the rank/machine/hostfile, and a set of environment variables.

libmuscle.native_instantiator.run_script.srun_prep_resources(resources: ResourceAssignment, rankfile_location: Path) Tuple[str, Dict[str, str]][source]

Create resource description for srun

Parameters:
  • resources – The resources to describe

  • rankfile_location – Location where the rankfile will be written

Returns:

The contents of the hostfile, and a set of environment variables