15 import os, sys, logging
18 from .mpi_impl_base
import MPIMixed,CMDFGen
24 module_logger=logging.getLogger(
'lsf_cray_intel')
27 """!Runs the "sync" command as an exe()."""
28 if logger
is None: logger=module_logger
35 """!Adds OpenMP support to the provided object
37 @param arg An produtil.prog.Runner or
38 produtil.mpiprog.MPIRanksBase object tree
39 @param threads the number of threads, or threads per rank, an
41 if threads
is not None:
43 return arg.env(OMP_NUM_THREADS=threads,KMP_NUM_THREADS=threads,
44 KMP_AFFINITY=
'scatter')
50 """!Detects whether Intel MPI is available."""
51 logger=logging.getLogger(
'produtil.mpi_impl.impi')
52 if mpirun_path
is None:
return False
58 return version.find(
'Intel(R) MPI')>=0
59 except Exception
as e:
60 logger.error(
'ERROR in mpirun --version: %s\n'%(str(e),),
65 """!Does this module represent an MPI implementation? Returns True."""
69 """!Returns an ImmutableRunner that will run the specified program.
70 @returns an empty list
71 @param exe The executable to run on compute nodes.
72 @param kwargs Ignored."""
76 """!Turns a produtil.mpiprog.MPIRanksBase tree into a produtil.prog.Runner
77 @param arg a tree of produtil.mpiprog.MPIRanksBase objects
78 @param allranks if True, and only one rank is requested by arg, then
79 all MPI ranks will be used
80 @param kwargs passed to produtil.mpi_impl.mpi_impl_base.CMDFGen
81 when mpiserial is in use.
82 @returns a produtil.prog.Runner that will run the selected MPI program"""
84 (serial,parallel)=arg.check_serial()
85 if serial
and parallel:
86 raise MPIMixed(
'Cannot mix serial and parallel MPI ranks in the '
88 if arg.nranks()==1
and allranks:
89 arglist=[ a
for a
in arg.to_arglist(
91 before=[
'-np',os.environ[
'TOTAL_TASKS']],
95 raise MPIAllRanksError(
96 "When using allranks=True, you must provide an mpi program "
97 "specification with only one MPI rank (to be duplicated across "
100 lines=[a
for a
in arg.to_arglist(to_shell=
True,expand=
True)]
102 raise MPISerialMissing(
103 'Attempting to run a serial program via mpirun but the '
104 'mpiserial program is not in your $PATH.')
106 [mpirun_path,
'-np',
'%s'%(arg.nranks()),
'mpiserial'],
107 prerun=CMDFGen(
'serialcmdf',lines,**kwargs))
109 arglist=[ a
for a
in arg.to_arglist(
111 before=[
'-np',
'%(n)d'],
def can_run_mpi()
Does this module represent an MPI implementation? Returns True.
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 detect()
Detects whether Intel MPI is available.
This class is a wrapper around launch and manage.
Implements the produtil.run: provides the object tree for representing shell commands.
def runsync
Runs the "sync" command as an exe().
def make_bigexe(exe, kwargs)
Returns an ImmutableRunner that will run the specified program.
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 openmp(arg, threads)
Adds OpenMP support to the provided object.
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.