17 from .mpi_impl_base
import CMDFGen,MPIMixed
22 module_logger=logging.getLogger(
'lsf_cray_intel')
25 """!Runs the "sync" command as an exe()."""
26 if logger
is None: logger=module_logger
33 """!Adds OpenMP support to the provided object
35 @param arg An produtil.prog.Runner or
36 produtil.mpiprog.MPIRanksBase object tree
37 @param threads the number of threads, or threads per rank, an
39 if threads
is not None:
41 return arg.env(OMP_NUM_THREADS=threads)
47 """!Detects whether the SGI MPT is available by looking for mpiexec_mpt."""
48 return mpiexec_mpt_path
is not None
51 """!Tries to guess the number of threads in use
52 @param default the value to return if the function cannot guess"""
53 omp=int(os.environ.get(
'OMP_NUM_THREADS',
None))
54 mkl=int(os.environ.get(
'MKL_NUM_THREADS',
None))
55 if omp
is None and mkl
is None:
57 omp = (1
if omp
is None else omp)
58 mkl = (1
if mkl
is None else mkl)
62 """!Does this module represent an MPI implementation? Returns True."""
66 """!Returns an ImmutableRunner that will run the specified program.
67 @returns an empty list
68 @param exe The executable to run on compute nodes.
69 @param kwargs Ignored."""
73 """!Turns a produtil.mpiprog.MPIRanksBase tree into a produtil.prog.Runner
74 @param arg a tree of produtil.mpiprog.MPIRanksBase objects
75 @param allranks if True, and only one rank is requested by arg, then
76 all MPI ranks will be used
77 @param kwargs passed to produtil.mpi_impl.mpi_impl_base.CMDFGen
78 when mpiserial is in use.
79 @returns a produtil.prog.Runner that will run the selected MPI program
80 @warning Assumes the TOTAL_TASKS environment variable is set
83 (serial,parallel)=arg.check_serial()
84 if serial
and parallel:
85 raise MPIMixed(
'Cannot mix serial and parallel MPI ranks in the same MPI program.')
86 if arg.nranks()==1
and allranks:
87 arglist=[ a
for a
in arg.to_arglist(
88 pre=[mpiexec_mpt_path],
89 before=[
'-n',os.environ[
'TOTAL_TASKS']],
93 raise MPIAllRanksError(
"When using allranks=True, you must provide an mpi program specification with only one MPI rank (to be duplicated across all ranks).")
95 lines=[a
for a
in arg.to_arglist(to_shell=
True,expand=
True)]
97 raise MPISerialMissing(
'Attempting to run a serial program via mpiexec_mpt but the mpiserial program is not in your $PATH.')
99 [mpiexec_mpt_path,
'-n',
'%s'%(arg.nranks()),
'mpiserial'],
100 prerun=CMDFGen(
'serialcmdf',lines,**kwargs))
102 arglist=[ a
for a
in arg.to_arglist(
103 pre=[mpiexec_mpt_path],
104 before=[
'-n',
'%(n)d'],
107 runner=runner.env(MPI_TYPE_DEPTH=20,MPI_BUFS_PER_PROC=256,MPI_BUFS_PER_HOST=1024)
This module provides a set of utility functions to do filesystem operations.
def mpirunner(arg, allranks=False, kwargs)
Turns a produtil.mpiprog.MPIRanksBase tree into a produtil.prog.Runner.
def runsync
Runs the "sync" command as an exe().
This class is a wrapper around launch and manage.
Implements the produtil.run: provides the object tree for representing shell commands.
def guess_nthreads(default)
Tries to guess the number of threads in use.
def can_run_mpi()
Does this module represent an MPI implementation? Returns True.
Object structure for describing MPI programs.
This is the abstract superclass of all classes that represent one or more MPI ranks, including MPI ranks that are actually serial programs.
def detect()
Detects whether the SGI MPT is available by looking for mpiexec_mpt.
Represents a single stage of a pipeline to execute.
def find_exe
Searches the $PATH or a specified iterable of directory names to find an executable file with the giv...
Internal module that launches and monitors processes.
An copy-on-write version of Runner.
def make_bigexe(exe, kwargs)
Returns an ImmutableRunner that will run the specified program.
def openmp(arg, threads)
Adds OpenMP support to the provided object.