Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

MPI.txt 11 KB

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
  1. = Message Passing Interface
  2. == Introduction
  3. Message Passing Interface (MPI) is an API for parallelization of programs across multiple nodes and has been around since 1994 https://en.wikipedia.org/wiki/Message_Passing_Interface[1]. MPI can also be used for parallelization on SMP machines and is considered very efficient in it too (close to 100% scaling on parallelizable code as compared to ~80% commonly obtained with threads due to unoptimal memory allocation on NUMA machines). Before MPI, about every manufacturer of supercomputers had their own programming language for writing programs; MPI made porting software easy.
  4. There are many MPI implementations available, such as https://www.open-mpi.org/[Open MPI] (the default MPI compiler in Fedora and the MPI compiler used in RHEL), https://www.mpich.org/[MPICH] (in Fedora and RHEL) and
  5. https://mvapich.cse.ohio-state.edu/[MVAPICH1 and MVAPICH2] (in RHEL but not yet in Fedora).
  6. As some MPI libraries work better on some hardware than others, and some software works best with some MPI library, the selection of the library used must be done in user level, on a session specific basis. Also, people doing high performance computing may want to use more efficient compilers than the default one in Fedora (gcc), so one must be able to have many versions of the MPI compiler each compiled with a different compiler installed at the same time. This must be taken into account when writing spec files.
  7. == Packaging of MPI compilers
  8. The files of MPI compilers MUST be installed in the following directories:
  9. [cols=",",options="header",]
  10. |===================================================================
  11. |File type |Placement
  12. |Binaries |`+%{_libdir}/%{name}/bin+`
  13. |Libraries |`+%{_libdir}/%{name}/lib+`
  14. |[[PackagingDrafts/Fortran |Fortran modules]] |`+%{_fmoddir}/%{name}+`
  15. |[[Packaging/Python |Python modules]] |`+%{python2_sitearch}/%{name}+`
  16. `+%{python3_sitearch}/%{name}+`
  17. |Config files |`+%{_sysconfdir}/%{name}-%{_arch}+`
  18. |===================================================================
  19. As include files and manual pages are bound to overlap between different MPI implementations, they MUST also placed outside normal directories. It is possible that some man pages or include files (either those of the MPI compiler itself or of some MPI software installed in the compiler's directory) are architecture specific (e.g. a definition on a 32-bit arch differs from that on a 64-bit arch), the directories that MUST be used are as follows:
  20. [cols=",",options="header",]
  21. |================================================
  22. |File type |Placement
  23. |Man pages |`+%{_mandir}/%{name}-%{_arch}+`
  24. |Include files |`+%{_includedir}/%{name}-%{_arch}+`
  25. |================================================
  26. Architecture independent parts (except headers which go into `+-devel+`) MUST be placed in a `+-common+` subpackage that is `+BuildArch: noarch+`.
  27. The runtime of MPI compilers (mpirun, the libraries, the manuals etc) MUST be packaged into %\{name}, and the development headers and libraries into %\{name}-devel.
  28. As the compiler is installed outside `+PATH+`, one needs to load the relevant variables before being able to use the compiler or run MPI programs. This is done using xref:EnvironmentModules.adoc[environment modules].
  29. The module file MUST be installed under `+%{_sysconfdir}/modulefiles/mpi+`. This allows as user with only one mpi implementation installed to load the module with:
  30. ....
  31. module load mpi
  32. ....
  33. The module file MUST have the line:
  34. ....
  35. conflict mpi
  36. ....
  37. to prevent concurrent loading of multiple mpi modules.
  38. The module file MUST prepend `+$MPI_BIN+` into the user's `+PATH+` and prepend `+$MPI_LIB+` to `+LD_LIBRARY_PATH+`.
  39. The module file MUST also set some helper variables (primarily for use in spec files):
  40. [cols=",,",options="header",]
  41. |==========================================================================================
  42. |Variable |Value |Explanation
  43. |`+MPI_BIN+` |`+%{_libdir}/%{name}/bin+` |Binaries compiled against the MPI stack
  44. |`+MPI_SYSCONFIG+` |`+%{_sysconfdir}/%{name}-%{_arch}+` |MPI stack specific configuration files
  45. |`+MPI_FORTRAN_MOD_DIR+` |`+%{_fmoddir}/%{name}+` |MPI stack specific Fortran module directory
  46. |`+MPI_INCLUDE+` |`+%{_includedir}/%{name}-%{_arch}+` |MPI stack specific headers
  47. |`+MPI_LIB+` |`+%{_libdir}/%{name}/lib+` |Libraries compiled against the MPI stack
  48. |`+MPI_MAN+` |`+%{_mandir}/%{name}-%{_arch}+` |MPI stack specific man pages
  49. |`+MPI_PYTHON2_SITEARCH+` |`+%{python2_sitearch}/%{name}+` |MPI stack specific Python 2 modules
  50. |`+MPI_PYTHON3_SITEARCH+` |`+%{python3_sitearch}/%{name}+` |MPI stack specific Python 3 modules
  51. |`+MPI_COMPILER+` |`+%{name}-%{_arch}+` |Name of compiler package, for use in e.g. spec files
  52. |`+MPI_SUFFIX+` |`+_%{name}+` |The suffix used for programs compiled against the MPI stack
  53. |==========================================================================================
  54. As these directories may be used by software using the MPI stack, the MPI runtime package MUST own all of them.
  55. MUST: By default, NO files are placed in `+/etc/ld.so.conf.d+`. If the packager wishes to provide alternatives support, it MUST be placed in a subpackage along with the ld.so.conf.d file so that alternatives support does not need to be installed if not wished for.
  56. MUST: If the maintainer wishes for the environment module to load automatically by use of a scriptlet in /etc/profile.d or by some other mechanism, this MUST be done in a subpackage.
  57. MUST: The MPI compiler package MUST provide an RPM macro that makes loading and unloading the support easy in spec files, e.g. by placing the following in `+/etc/rpm/macros.openmpi+`
  58. ....
  59. %_openmpi_load \
  60. . /etc/profile.d/modules.sh; \
  61. module load mpi/openmpi-%{_arch}; \
  62. export CFLAGS="$CFLAGS %{optflags}";
  63. %_openmpi_unload \
  64. . /etc/profile.d/modules.sh; \
  65. module unload mpi/openmpi-%{_arch};
  66. ....
  67. loading and unloading the compiler in spec files is as easy as `+%{_openmpi_load}+` and `+%{_openmpi_unload}+`.
  68. Automatic setting of the module loading path in python interpreters is done using a `+.pth+` file placed in one of the directories normally searched for modules (`+%{python2_sitearch}+`, `+%{python3_sitearch}+`). Those `+.pth+` files should append the directory specified with $MPI_PYTHON2_SITEARCH or $MPI_PYTHON3_SITEARCH environment variable, depending on the interpreter version, to `+sys.path+`, and do nothing if those variables are unset. Module files MUST NOT set PYTHONPATH directly, since it cannot be set for both Python versions at the same time.
  69. If the environment module sets compiler flags such as `+CFLAGS+` (thus overriding the ones exported in `+%configure+`, the RPM macro MUST make them use the Fedora optimization flags `+%{optflags}+` once again (as in the example above in which the openmpi-%\{_arch} module sets CFLAGS).
  70. == Packaging of MPI software
  71. Software that supports MPI MUST be packaged also in serial mode [i.e. no MPI], if it is supported by upstream. (for instance: `+foo+`).
  72. If possible, the packager MUST package versions for each MPI compiler in Fedora (e.g. if something can only be built with mpich and mvapich2, then mvapich1 and openmpi packages do not need to be made).
  73. MPI implementation specific files MUST be installed in the directories used by the used MPI compiler (`+$MPI_BIN+`, `+$MPI_LIB+` and so on).
  74. The binaries MUST be suffixed with `+$MPI_SUFFIX+` (e.g. _openmpi for Open MPI, _mpich for MPICH and _mvapich2 for MVAPICH2). This is for two reasons: the serial version of the program can still be run when an MPI module is loaded and the user is always aware of the version s/he is running. This does not need to hurt the use of shell scripts:
  75. ....
  76. # Which MPI implementation do we use?
  77. #module load mpi/mvapich2-i386
  78. #module load mpi/openmpi-i386
  79. module load mpi/mpich-i386
  80. # Run preprocessor
  81. foo -preprocess < foo.in
  82. # Run calculation
  83. mpirun -np 4 foo${MPI_SUFFIX}
  84. # Run some processing
  85. mpirun -np 4 bar${MPI_SUFFIX} -process
  86. # Collect results
  87. bar -collect
  88. ....
  89. The MPI enabled bits MUST be placed in a subpackage with the suffix denoting the MPI compiler used (for instance: `+foo-openmpi+` for Open MPI [the traditional MPI compiler in Fedora] or `+foo-mpich+` for MPICH). For directory ownership and to guarantee the pickup of the correct MPI runtime, the MPI subpackages MUST require the correct MPI compiler's runtime package.
  90. Each MPI build of shared libraries SHOULD have a separate -libs subpackage for the libraries (e.g. foo-mpich-libs). As in the case of MPI compilers, library configuration (in `+/etc/ld.so.conf.d+`) MUST NOT be made.
  91. In case the headers are the same regardless of the compilation method and architecture (e.g. 32-bit serial, 64-bit Open MPI, MPICH), they MUST be split into a separate `+-headers+` subpackage (e.g. 'foo-headers'). Fortran modules are architecture specific and as such are placed in the (MPI implementation specific) `+-devel+` package (foo-devel for the serial version and foo-openmpi-devel for the Open MPI version).
  92. Each MPI build MUST have a separate -devel subpackage (e.g. foo-mpich-devel) that includes the development libraries and `+Requires: %{name}-headers+` if such a package exists. The goal is to be able to install and develop using e.g. 'foo-mpich-devel' without needing to install e.g. openmpi or the serial version of the package.
  93. Files must be shared between packages as much as possible. Compiler independent parts, such as data files in `+%{_datadir}/%{name}+` and man files MUST be put into a `+-common+` subpackage that is required by all of the binary packages (the serial package and all of the MPI packages).
  94. === A sample spec file
  95. ....
  96. # Define a macro for calling ../configure instead of ./configure
  97. %global dconfigure %(printf %%s '%configure' | sed 's!\./configure!../configure!g')
  98. Name: foo
  99. Requires: %{name}-common = %{version}-%{release}
  100. %package common
  101. %package openmpi
  102. BuildRequires: openmpi-devel
  103. # Require explicitly for dir ownership and to guarantee the pickup of the right runtime
  104. Requires: openmpi
  105. Requires: %{name}-common = %{version}-%{release}
  106. %package mpich
  107. BuildRequires: mpich-devel
  108. # Require explicitly for dir ownership and to guarantee the pickup of the right runtime
  109. Requires: mpich
  110. Requires: %{name}-common = %{version}-%{release}
  111. %build
  112. # Have to do off-root builds to be able to build many versions at once
  113. # To avoid replicated code define a build macro
  114. %define dobuild() \
  115. mkdir $MPI_COMPILER; \
  116. cd $MPI_COMPILER; \
  117. %dconfigure --program-suffix=$MPI_SUFFIX ;\
  118. make %{?_smp_mflags} ; \
  119. cd ..
  120. # Build serial version, dummy arguments
  121. MPI_COMPILER=serial MPI_SUFFIX= %dobuild
  122. # Build parallel versions: set compiler variables to MPI wrappers
  123. export CC=mpicc
  124. export CXX=mpicxx
  125. export FC=mpif90
  126. export F77=mpif77
  127. # Build OpenMPI version
  128. %{_openmpi_load}
  129. %dobuild
  130. %{_openmpi_unload}
  131. # Build mpich version
  132. %{_mpich_load}
  133. %dobuild
  134. %{_mpich_unload}
  135. %install
  136. # Install serial version
  137. make -C serial install DESTDIR=%{buildroot} INSTALL="install -p" CPPROG="cp -p"
  138. # Install OpenMPI version
  139. %{_openmpi_load}
  140. make -C $MPI_COMPILER install DESTDIR=%{buildroot} INSTALL="install -p" CPPROG="cp -p"
  141. %{_openmpi_unload}
  142. # Install MPICH version
  143. %{_mpich_load}
  144. make -C $MPI_COMPILER install DESTDIR=%{buildroot} INSTALL="install -p" CPPROG="cp -p"
  145. %{_mpich_unload}
  146. %files # All the serial (normal) binaries
  147. %files common # All files shared between the serial and different MPI versions
  148. %files openmpi # All openmpi linked files
  149. %files mpich # All mpich linked files
  150. ....
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...