Skip to content

Commit 79144f2

Browse files
committed
Regenerate MPI modules on update
1 parent 133f3ba commit 79144f2

File tree

3 files changed

+192
-157
lines changed

3 files changed

+192
-157
lines changed
Lines changed: 169 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,169 @@
1+
#!/bin/bash
2+
# Don't clobber/overwrite existing files
3+
# Write the new file .rpmnew
4+
testfile () {
5+
if [ -e "$1" ]; then
6+
echo "$1.rpmnew"
7+
else
8+
echo "$1"
9+
fi
10+
}
11+
12+
# Remove .rpmnew files if they are identical
13+
# otherwise record in manifest
14+
modprocess () {
15+
if [ "${1/.rpmnew/}" != "$1" ]; then
16+
if cmp "${1/.rpmnew/}" "$1"; then
17+
rm "$1"
18+
return
19+
fi
20+
fi
21+
md5sum "${modname}" >> @@oneapi_manifest@@
22+
}
23+
24+
# Create an OpenHPC module file for each version found in compilers
25+
rm -f @@oneapi_manifest@@
26+
27+
# Regenerate the oneAPI modules directory (since MPI may have just been added)
28+
echo "Generating new oneAPI modulefiles"
29+
/opt/intel/oneapi/modulefiles-setup.sh --ignore-latest --force --output-dir=@@OHPC_MODULEDEPS@@/oneapi/ > /dev/null
30+
if [ ! -d @@OHPC_MODULEDEPS@@/oneapi/compiler ]; then
31+
echo "ERROR: Failed to create oneAPI module directory"
32+
exit 1
33+
fi
34+
35+
# Set system defaults for default OBS oneAPI modules
36+
for tool in @@exact_deps@@; do
37+
filename="@@OHPC_MODULEDEPS@@/oneapi/${tool%%/*}/.version"
38+
echo "#%Module1.0" > "${filename}"
39+
echo "set ModulesVersion \"${tool##*/}\"" >> "${filename}"
40+
done
41+
42+
# Create an OpenHPC module file for each MPI version found
43+
echo "Creating OpenHPC-style modulefiles for local oneAPI MPI installation(s)."
44+
for mpis in @@OHPC_MODULEDEPS@@/oneapi/mpi/2*; do
45+
ver=$(basename "$mpis")
46+
echo "--> Installing modulefile for version=${ver}"
47+
modname=$(testfile @@OHPC_MODULEDEPS@@/intel/impi/"$ver")
48+
49+
# Get value for MPI_DIR
50+
eval "$(@@OHPC_ADMIN@@/lmod/lmod/libexec/lmod --expert use @@OHPC_MODULEDEPS@@/oneapi)"
51+
eval "$(@@OHPC_ADMIN@@/lmod/lmod/libexec/lmod --expert load mpi/\"$ver\")"
52+
MPIDIR=$I_MPI_ROOT
53+
eval "$(@@OHPC_ADMIN@@/lmod/lmod/libexec/lmod --expert unload mpi/\"$ver\")"
54+
eval "$(@@OHPC_ADMIN@@/lmod/lmod/libexec/lmod --expert unuse @@OHPC_MODULEDEPS@@/oneapi)"
55+
56+
cat << EOF > "${modname}"
57+
#%Module1.0#####################################################################
58+
59+
set version "$ver"
60+
61+
proc ModulesHelp { } {
62+
global version
63+
puts stderr "\nThis module loads the Intel MPI environment.\n"
64+
puts stderr " mpiifort (Fortran source)"
65+
puts stderr " mpiicc (C source)"
66+
puts stderr " mpiicpc (C++ source)"
67+
puts stderr "\nVersion \$version\n"
68+
}
69+
70+
module-whatis "Name: Intel MPI"
71+
module-whatis "Version: \$version"
72+
module-whatis "Category: library, runtime support"
73+
module-whatis "Description: Intel MPI Library (C/C++/Fortran for x86_64)"
74+
module-whatis "URL: http://software.intel.com/en-us/articles/intel-mpi-library"
75+
76+
# For convenience, redirect standard mpicc/mpicxx/mpifort
77+
# to use oneAPI icc/icpc/ifort instead of gcc/g++/gfortran
78+
setenv I_MPI_CC icx
79+
setenv I_MPI_CXX icpx
80+
setenv I_MPI_FC ifx
81+
setenv I_MPI_F77 ifx
82+
setenv I_MPI_F90 ifx
83+
84+
setenv MPI_DIR "${MPIDIR}"
85+
86+
prepend-path MODULEPATH @@OHPC_MODULEDEPS@@/oneapi
87+
prepend-path MODULEPATH @@OHPC_MODULEDEPS@@/intel-impi
88+
89+
module load "mpi/\$version"
90+
91+
prepend-path LIBRARY_PATH "${MPIDIR}/libfabric/lib"
92+
prepend-path LIBRARY_PATH "${MPIDIR}/lib"
93+
94+
family "MPI"
95+
EOF
96+
97+
modprocess "${modname}"
98+
99+
modname=$(testfile @@OHPC_MODULEDEPS@@/gnu/impi/"$ver")
100+
101+
cat << EOF > "${modname}"
102+
#%Module1.0#####################################################################
103+
104+
set version "$ver"
105+
106+
proc ModulesHelp { } {
107+
global version
108+
puts stderr "\nThis module loads the Intel MPI environment for use with the GNU"
109+
puts stderr "compiler toolchain\n"
110+
puts stderr "mpif90 (Fortran source)"
111+
puts stderr "mpicc (C source)"
112+
puts stderr "mpicxx (C++ source)"
113+
puts stderr "\nVersion \$version\n"
114+
}
115+
116+
module-whatis "Name: Intel MPI"
117+
module-whatis "Version: \$version"
118+
module-whatis "Category: library, runtime support"
119+
module-whatis "Description: Intel MPI Library (C/C++/Fortran for x86_64)"
120+
module-whatis "URL: http://software.intel.com/en-us/articles/intel-mpi-library/"
121+
122+
setenv MPI_DIR "${MPIDIR}"
123+
124+
prepend-path MODULEPATH @@OHPC_MODULEDEPS@@/oneapi
125+
prepend-path MODULEPATH @@OHPC_MODULEDEPS@@/gnu-impi
126+
127+
module load "mpi/\$version"
128+
129+
prepend-path LIBRARY_PATH "${MPIDIR}/libfabric/lib"
130+
prepend-path LIBRARY_PATH "${MPIDIR}/lib"
131+
132+
family "MPI"
133+
EOF
134+
135+
modprocess "${modname}"
136+
137+
# support for gnu major version
138+
orig_modname=$modname
139+
modname=$(testfile @@OHPC_MODULEDEPS@@/gnu@@gnu_major_ver@@/impi/"$ver")
140+
cp "${orig_modname}" "${modname}"
141+
sed -i "s,@@OHPC_MODULEDEPS@@/gnu-impi,@@OHPC_MODULEDEPS@@/gnu@@gnu_major_ver@@-impi," "${modname}"
142+
modprocess "${modname}"
143+
144+
done
145+
146+
# Default Intel(R) MPI Versions to match OpenHPC build version
147+
modname=$(testfile @@OHPC_MODULEDEPS@@/intel/impi/.version)
148+
149+
cat << EOF > "${modname}"
150+
#%Module1.0#####################################################################
151+
set ModulesVersion "@@exact_mpi_ver@@"
152+
EOF
153+
154+
modprocess "${modname}"
155+
156+
modname=$(testfile @@OHPC_MODULEDEPS@@/gnu/impi/.version)
157+
158+
cat << EOF > "${modname}"
159+
#%Module1.0#####################################################################
160+
set ModulesVersion "@@exact_mpi_ver@@"
161+
EOF
162+
163+
modprocess "${modname}"
164+
165+
# support for gnu major version
166+
orig_modname=$modname
167+
modname=$(testfile @@OHPC_MODULEDEPS@@/gnu@@gnu_major_ver@@/impi/.version)
168+
cp "${orig_modname}" "${modname}"
169+
modprocess "${modname}"

components/mpi-families/impi-devel/SPECS/intel-mpi.spec

Lines changed: 20 additions & 157 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,15 @@
2626
Summary: OpenHPC compatibility package for Intel(R) oneAPI MPI Library
2727
Name: %{pname}%{PROJ_DELIM}
2828
Version: 2024.0
29-
Release: %{?dist}.1
29+
Release: %{?dist}.2
3030
License: Apache-2.0
3131
URL: https://github.com/openhpc/ohpc
3232
Group: %{PROJ_NAME}/mpi-families
3333
BuildArch: x86_64
3434
AutoReq: no
3535

3636
Source1: mod_generator_impi.sh
37+
Source2: ohpc-update-modules-mpi
3738

3839
#!BuildIgnore: post-build-checks
3940

@@ -57,11 +58,27 @@ MPI Library.
5758
# Mod generator for PSXE support
5859
install -D -m755 %{SOURCE1} %{buildroot}/%{OHPC_ADMIN}/compat/modulegen/mod_generator_impi.sh
5960

61+
# Mod generator for oneAPI support
62+
sed -e 's|@@oneapi_manifest@@|%{oneapi_manifes}|' \
63+
-e 's|@@OHPC_ADMIN@@|%{OHPC_ADMIN}|' \
64+
-e 's|@@OHPC_MODULEDEPS@@|%{OHPC_MODULEDEPS}|' \
65+
-e 's|@@OHPC_MODULES@@|%{OHPC_MODULES}|' \
66+
-e 's|@@exact_deps@@|%{exact_deps}|' \
67+
-e 's|@@exact_mpi_ver@@|%{exact_mpi_ver}|' \
68+
-e 's|@@gnu_major_ver@@|%{gnu_major_ver}|' %{SOURCE3} > ohpc-update-modules-mpi
69+
install -D -m755 ohpc-update-modules-mpi %{buildroot}/%{OHPC_BIN}/ohpc-update-modules-mpi
70+
6071
# Module directories
6172
mkdir -p %{buildroot}/%{OHPC_MODULEDEPS}/intel/impi
6273
mkdir -p %{buildroot}/%{OHPC_MODULEDEPS}/gnu/impi
6374
mkdir -p %{buildroot}/%{OHPC_MODULEDEPS}/gnu%{gnu_major_ver}/impi
6475

76+
77+
# Regenerate module files when components are added or removed
78+
%transfiletriggerin -- /opt/intel/oneapi/mpi
79+
%{OHPC_BIN}/ohpc-update-modules-mpi
80+
81+
6582
%pre
6683
if ! [ -d /opt/intel/oneapi/mpi/%{exact_mpi_ver}/etc/modulefiles ]; then
6784
echo " "
@@ -72,162 +89,7 @@ fi
7289

7390

7491
%post
75-
# Don't clobber/overwrite existing files
76-
# Write the new file .rpmnew
77-
testfile () {
78-
if [ -e $1 ]; then
79-
echo "$1.rpmnew"
80-
else
81-
echo "$1"
82-
fi
83-
}
84-
85-
# Create an OpenHPC module file for each version found in compilers
86-
rm -f %{oneapi_manifest}
87-
88-
# Regenerate the oneAPI modules directory (since MPI may have just been added)
89-
echo "Generating new oneAPI modulefiles"
90-
/opt/intel/oneapi/modulefiles-setup.sh --ignore-latest --force --output-dir=%{OHPC_MODULEDEPS}/oneapi/ > /dev/null
91-
if [ ! -d %{OHPC_MODULEDEPS}/oneapi/compiler ]; then
92-
echo "ERROR: Failed to create oneAPI module directory"
93-
exit 1
94-
fi
95-
96-
# Set system defaults for default OBS oneAPI modules
97-
for tool in %{exact_deps}; do
98-
filename=%{OHPC_MODULEDEPS}/oneapi/${tool%%/*}/.version
99-
echo "#%Module1.0" > ${filename}
100-
echo "set ModulesVersion \"${tool##*/}\"" >> ${filename}
101-
done
102-
103-
# Create an OpenHPC module file for each MPI version found
104-
echo "Creating OpenHPC-style modulefiles for local oneAPI MPI installation(s)."
105-
for mpis in %{OHPC_MODULEDEPS}/oneapi/mpi/2*; do
106-
ver=$(basename "$mpis")
107-
echo "--> Installing modulefile for version=${ver}"
108-
modname=$(testfile %{OHPC_MODULEDEPS}/intel/impi/$ver)
109-
110-
# Get value for MPI_DIR
111-
eval $(%{OHPC_ADMIN}/lmod/lmod/libexec/lmod --expert use %{OHPC_MODULEDEPS}/oneapi)
112-
eval $(%{OHPC_ADMIN}/lmod/lmod/libexec/lmod --expert load mpi/$ver)
113-
MPIDIR=$I_MPI_ROOT
114-
eval $(%{OHPC_ADMIN}/lmod/lmod/libexec/lmod --expert unload mpi/$ver)
115-
eval $(%{OHPC_ADMIN}/lmod/lmod/libexec/lmod --expert unuse %{OHPC_MODULEDEPS}/oneapi)
116-
117-
cat << EOF > ${modname}
118-
#%Module1.0#####################################################################
119-
120-
set version "$ver"
121-
122-
proc ModulesHelp { } {
123-
global version
124-
puts stderr "\nThis module loads the Intel MPI environment.\n"
125-
puts stderr " mpiifort (Fortran source)"
126-
puts stderr " mpiicc (C source)"
127-
puts stderr " mpiicpc (C++ source)"
128-
puts stderr "\nVersion \$version\n"
129-
}
130-
131-
module-whatis "Name: Intel MPI"
132-
module-whatis "Version: \$version"
133-
module-whatis "Category: library, runtime support"
134-
module-whatis "Description: Intel MPI Library (C/C++/Fortran for x86_64)"
135-
module-whatis "URL: http://software.intel.com/en-us/articles/intel-mpi-library"
136-
137-
# For convenience, redirect standard mpicc/mpicxx/mpifort
138-
# to use oneAPI icc/icpc/ifort instead of gcc/g++/gfortran
139-
setenv I_MPI_CC icx
140-
setenv I_MPI_CXX icpx
141-
setenv I_MPI_FC ifx
142-
setenv I_MPI_F77 ifx
143-
setenv I_MPI_F90 ifx
144-
145-
setenv MPI_DIR "${MPIDIR}"
146-
147-
prepend-path MODULEPATH %{OHPC_MODULEDEPS}/oneapi
148-
prepend-path MODULEPATH %{OHPC_MODULEDEPS}/intel-impi
149-
150-
module load "mpi/\$version"
151-
152-
prepend-path LIBRARY_PATH "${MPIDIR}/libfabric/lib"
153-
prepend-path LIBRARY_PATH "${MPIDIR}/lib"
154-
155-
family "MPI"
156-
EOF
157-
158-
md5sum ${modname} >> %{oneapi_manifest}
159-
160-
modname=$(testfile %{OHPC_MODULEDEPS}/gnu/impi/$ver)
161-
162-
cat << EOF > ${modname}
163-
#%Module1.0#####################################################################
164-
165-
set version "$ver"
166-
167-
proc ModulesHelp { } {
168-
global version
169-
puts stderr "\nThis module loads the Intel MPI environment for use with the GNU"
170-
puts stderr "compiler toolchain\n"
171-
puts stderr "mpif90 (Fortran source)"
172-
puts stderr "mpicc (C source)"
173-
puts stderr "mpicxx (C++ source)"
174-
puts stderr "\nVersion \$version\n"
175-
}
176-
177-
module-whatis "Name: Intel MPI"
178-
module-whatis "Version: \$version"
179-
module-whatis "Category: library, runtime support"
180-
module-whatis "Description: Intel MPI Library (C/C++/Fortran for x86_64)"
181-
module-whatis "URL: http://software.intel.com/en-us/articles/intel-mpi-library/"
182-
183-
setenv MPI_DIR "${MPIDIR}"
184-
185-
prepend-path MODULEPATH %{OHPC_MODULEDEPS}/oneapi
186-
prepend-path MODULEPATH %{OHPC_MODULEDEPS}/gnu-impi
187-
188-
module load "mpi/\$version"
189-
190-
prepend-path LIBRARY_PATH "${MPIDIR}/libfabric/lib"
191-
prepend-path LIBRARY_PATH "${MPIDIR}/lib"
192-
193-
family "MPI"
194-
EOF
195-
196-
md5sum ${modname} >> %{oneapi_manifest}
197-
198-
# support for gnu major version
199-
orig_modname=$modname
200-
modname=$(testfile %{OHPC_MODULEDEPS}/gnu%{gnu_major_ver}/impi/$ver)
201-
cp ${orig_modname} ${modname}
202-
sed -i "s,%{OHPC_MODULEDEPS}/gnu-impi,%{OHPC_MODULEDEPS}/gnu%{gnu_major_ver}-impi," ${modname}
203-
md5sum ${modname} >> %{oneapi_manifest}
204-
205-
done
206-
207-
# Default Intel(R) MPI Versions to match OpenHPC build version
208-
modname=$(testfile %{OHPC_MODULEDEPS}/intel/impi/.version)
209-
210-
cat << EOF > ${modname}
211-
#%Module1.0#####################################################################
212-
set ModulesVersion "%{exact_mpi_ver}"
213-
EOF
214-
215-
md5sum ${modname} >> %{oneapi_manifest}
216-
217-
modname=$(testfile %{OHPC_MODULEDEPS}/gnu/impi/.version)
218-
219-
cat << EOF > ${modname}
220-
#%Module1.0#####################################################################
221-
set ModulesVersion "%{exact_mpi_ver}"
222-
EOF
223-
224-
md5sum ${modname} >> %{oneapi_manifest}
225-
226-
# support for gnu major version
227-
orig_modname=$modname
228-
modname=$(testfile %{OHPC_MODULEDEPS}/gnu%{gnu_major_ver}/impi/.version)
229-
cp ${orig_modname} ${modname}
230-
md5sum ${modname} >> %{oneapi_manifest}
92+
%{OHPC_BIN}/ohpc-update-modules-mpi
23193

23294
%preun -p /bin/bash
23395
# Check current files against the manifest
@@ -490,6 +352,7 @@ fi
490352

491353
%files -n %{psxemod}
492354
%{OHPC_ADMIN}/compat/modulegen/mod_generator_impi.sh
355+
%{OHPC_BIN}/ohpc-update-modules-mpi
493356
%dir %{OHPC_MODULEDEPS}/intel/impi
494357
%dir %{OHPC_MODULEDEPS}/gnu/impi
495358
%dir %{OHPC_MODULEDEPS}/gnu%{gnu_major_ver}/impi

0 commit comments

Comments
 (0)