15 import os, socket, logging
18 from .mpi_impl_base
import MPIMixed,CMDFGen
23 module_logger=logging.getLogger(
'lsf_cray_intel')
26 """!Runs the "sync" command as an exe()."""
27 if logger
is None: logger=module_logger
34 """!Adds OpenMP support to the provided object
36 @param arg An produtil.prog.Runner or
37 produtil.mpiprog.MPIRanksBase object tree
38 @param threads the number of threads, or threads per rank, an
40 if threads
is not None:
42 return arg.env(OMP_NUM_THREADS=threads)
48 """!Determines if LSF+IBMPE should be used to run MPI programs by
49 looking for the mpirun.lsf program in $PATH"""
50 return mpirun_lsf_path
is not None
53 """!Does this module represent an MPI implementation? Returns True."""
57 """!Returns an ImmutableRunner that will run the specified program.
58 @returns an empty list
59 @param exe The executable to run on compute nodes.
60 @param kwargs Ignored."""
63 def mpirunner(arg,allranks=False,logger=None,**kwargs):
64 """!Turns a produtil.mpiprog.MPIRanksBase tree into a produtil.prog.Runner
65 @param arg a tree of produtil.mpiprog.MPIRanksBase objects
66 @param allranks if True, and only one rank is requested by arg, then
67 all MPI ranks will be used
68 @param logger a logging.Logger for log messages
69 @param kwargs passed to produtil.mpi_impl.mpi_impl_base.CMDFGen
70 when mpiserial is in use.
71 @returns a produtil.prog.Runner that will run the selected MPI program
72 @note LSF does not support modifying the number of MPI ranks
73 to use when running a program. You can only use all provided
74 ranks, or one rank."""
76 logger=logging.getLogger(
'mpirun_lsf')
78 (serial,parallel)=arg.check_serial()
79 if serial
and parallel:
81 'Cannot mix serial and parallel MPI ranks in the same '
83 if arg.nranks()==1
and allranks:
84 arglist=[ a
for a
in arg.to_arglist(
85 pre=[mpirun_lsf_path],
92 host=socket.gethostname()
94 [ a
for a
in arg.to_arglist(
95 pre=[mpirun_lsf_path],
96 before=[], between=[]) ])
98 LSB_PJL_TASK_GEOMETRY=
"{(0)}",LSB_HOSTS=host,
99 LSB_MCPU_HOSTS=host+
" 1", LSB_DJOB_NUMPROC=
'1',
100 LSB_MAX_NUM_PROCESSORS=
'1',MP_TASK_AFFINITY=
'core')
101 if logger
is not None:
103 'Using a hack to work around an LSF bug and run a one core '
104 'program: '+repr(runner))
107 raise MPIAllRanksError(
108 "When using allranks=True, you must provide an mpi program "
109 "specification with only one MPI rank (to be duplicated "
110 "across all ranks).")
112 lines=[a
for a
in arg.to_arglist(to_shell=
True,expand=
True)]
114 raise MPISerialMissing(
115 'Attempting to run a serial program via mpirun.lsf but '
116 'the mpiserial program is not in your $PATH.')
118 prerun=CMDFGen(
'serialcmdf',lines,
119 cmd_envar=
'MP_CMDFILE',
120 model_envar=
'MP_PGMMODEL',
123 lines=[a
for a
in arg.to_arglist(to_shell=
True,expand=
True)]
125 prerun=CMDFGen(
'mpirun_lsf_cmdf',lines,
126 cmd_envar=
'MP_CMDFILE',
127 model_envar=
'MP_PGMMODEL',
This module provides a set of utility functions to do filesystem operations.
def mpirunner(arg, allranks=False, logger=None, kwargs)
Turns a produtil.mpiprog.MPIRanksBase tree into a produtil.prog.Runner.
This class is a wrapper around launch and manage.
Implements the produtil.run: provides the object tree for representing shell commands.
def detect()
Determines if LSF+IBMPE should be used to run MPI programs by looking for the mpirun.lsf program in $PATH.
def runsync
Runs the "sync" command as an exe().
def openmp(arg, threads)
Adds OpenMP support to the provided object.
Object structure for describing MPI programs.
def can_run_mpi()
Does this module represent an MPI implementation? Returns True.
This is the abstract superclass of all classes that represent one or more MPI ranks, including MPI ranks that are actually serial programs.
def make_bigexe(exe, kwargs)
Returns an ImmutableRunner that will run the specified program.
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.