Debian Codegraph @

doc/example/compiler-etc-dependencies/tcllib/MpiUtils.tcl

raw
1 # ======= Utilities related to which MPI library is loaded, etc =========
2 # Author: Tom Payerle <[email protected]>
3
4 #--------------------------------------------------------------------
5 # RequireMPI:
6 #
7 # Does a module load of specified MPI library $mympi
8 # Includes special handling if $mympi is nompi or intelmpi (or one of its aliases)
9 # If $mympi is nompi, nothing is loaded.
10 # If the optional parameter noLoadIntel is set (default false), and if
11 # $mympi is intelmpi (or intel or impi), then we do not load module if
12 # the loaded compiler is intel (as we assume that provides intel MPI as well)
13 proc RequireMPI { mympi {noLoadIntel 0} } {
14 # We do not do anything if mympi is nompi
15 if { $mympi eq {nompi} } { return }
16 if { $noLoadIntel } {
17 # Get the basename of requested MPI library
18 set mympiSplit [ split $mympi / ]
19 set mympiBase [ lindex $mympiSplit 0 ]
20 # Check if we requested an intel MPI
21 set intelList "intelmpi impi intel intelmpi-mt impi-mt intel-mt"
22 if { [lsearch $intelList $mympiBase ] > -1 } {
23 # We requested intelmpi in some form
24 # Check if an intel compiler was loaded
25 set curComp [ GetLoadedCompiler 1]
26 if { $curComp ne {} } {
27 set curCompSplit [ split $curComp / ]
28 set curCompBase [ lindex $curCompSplit 0 ]
29 if { $curCompBase eq {intel} } {
30 # $noLoadIntel is set, requested MPI is intel MPI, and intel compiler loaded
31 return
32 }
33 }
34 }
35 }
36 module load $mympi
37 }
38
39 #--------------------------------------------------------------------
40 # GetKnownMpiFamilies:
41 #
42 # Returns a list of recognized MPI library family names
43 #E.g. gcc, intel, pgi
44 proc GetKnownMpiFamilies { } {
45 set mfamilies {openmpi mpavich intelmpi}
46 return $mfamilies
47 }
48
49 #--------------------------------------------------------------------
50 # GetLoadedMPI:
51 #
52 # Returns the string for the MPI library we are using (i.e. was previously
53 # module loaded), or empty string if nothing loaded (from is-loaded command)
54 # E.g., intel/2013.1.117
55 # Takes an optional argument,
56 # useIntel: boolean, default false. If set, returns 'intelmpi' if
57 # no MPI library is loaded but intel compiler is loaded
58 # forceIt: boolean, default false. If set, prereq MPI lib before returning.
59 # requireIt: boolean, default false. If set, prereq the MPI library
60 proc GetLoadedMPI { { useIntel 0} {forceIt 0} {requireIt 0} } {
61 set mtag {}
62 foreach mfam [ GetKnownMpiFamilies ] {
63 if { [ is-loaded $mfam ] } {
64 set mtag [ GetTagOfModuleLoaded $mfam ]
65 if { $requireIt } { prereq $ctag }
66 return $mtag
67 }
68 }
69 # No loaded compiler found, should we check for Intel compiler and return intelmpi?
70 if { $useIntel } {
71 #Yes
72 set ctag [ GetCompilerLoaded ]
73 set cSplit [ split $ctag / ]
74 set cBase [ lindex $cSplit 0 ]
75 if { $cBase eq intel } { return intelmpi }
76 }
77 return $mtag
78 }