Reduce precision list duplication

Use the same list of precision names when building MPI versions as well
as the install and check stages.

Instead of having two for loops, one for quad support and one without,
just have one loop and make the number of precisions a macro.

Signed-off-by: Trent Piepho <tpiepho@gmail.com>
This commit is contained in:
Trent Piepho 2022-11-27 12:09:31 -08:00
parent f8340f3728
commit d3c0a816a6

View File

@ -28,6 +28,16 @@ BuildRequires: gcc-gfortran
%global quad 1
%endif
# Names of precisions to (maybe) build
%global prec_names prec_name[0]=single;prec_name[1]=double;prec_name[2]=long;prec_name[3]=quad
# Number of precisions to build; sometimes quad is not possible
%global nprec 3
%if %{quad}
%global nprec 4
%endif
# Number of precisions to build for MPI
%global nmpiprec 3
# For check phase
BuildRequires: time
BuildRequires: perl-interpreter
@ -277,11 +287,7 @@ export F77=gfortran
BASEFLAGS="--enable-shared --disable-dependency-tracking --enable-threads"
BASEFLAGS+=" --enable-openmp"
# Precisions to build
prec_name[0]=single
prec_name[1]=double
prec_name[2]=long
prec_name[3]=quad
%prec_names
# Corresponding flags
prec_flags[0]=--enable-single
@ -311,11 +317,7 @@ done
#%endif
# Loop over precisions
%if %{quad}
for ((iprec=0; iprec<4; iprec++)) ; do
%else
for ((iprec=0; iprec<3; iprec++)) ; do
%endif
for ((iprec=0; iprec<%{nprec}; iprec++)) ; do
mkdir ${prec_name[iprec]}${ver_name[iver]}
cd ${prec_name[iprec]}${ver_name[iver]}
ln -s ../configure .
@ -330,7 +332,7 @@ done
for mpi in %{mpi_list} ; do
module load mpi/${mpi}-%{_arch}
# Loop over precisions - no quad precision support with MPI
for((iprec=0;iprec<3;iprec++)) ; do
for((iprec=0;iprec<%{nmpiprec};iprec++)) ; do
mkdir ${mpi}-${prec_name[iprec]}${ver_name[iver]}
cd ${mpi}-${prec_name[iprec]}${ver_name[iver]}
ln -s ../configure .
@ -351,23 +353,21 @@ for mpi in %{mpi_list} ; do
done
%install
%prec_names
# Explicitly load shell support for the environment-modules package, used
# below via 'module' pseudo-command.
source /etc/profile.d/modules.sh
%if %{quad}
for ver in single double long quad ; do
%else
for ver in single double long ; do
%endif
%make_install -C $ver
for((iprec=0;iprec<%{nprec};iprec++)) ; do
%make_install -C ${prec_name[iprec]}
done
# MPI
for mpi in %{mpi_list} ; do
module load mpi/${mpi}-%{_arch}
for ver in single double long ; do
%make_install -C ${mpi}-${ver}
for((iprec=0;iprec<%{nmpiprec};iprec++)) ; do
%make_install -C ${mpi}-${prec_name[iprec]}
# Remove duplicated non-mpi libraries, binaries, and data
find %{buildroot}%{_libdir}/${mpi}/lib -name libfftw\* -a \! -name \*_mpi.\* -delete
rm -r %{buildroot}%{_libdir}/${mpi}/{bin,share}
@ -379,18 +379,15 @@ rm -f %{buildroot}%{_infodir}/dir
find %{buildroot} -name \*.la -delete
%check
%prec_names
# Explicitly load shell support for the environment-modules package, used
# below via 'module' pseudo-command.
. /etc/profile.d/modules.sh
bdir=$(pwd)
%if %{quad}
for ver in single double long quad ; do
%else
for ver in single double long ; do
%endif
export LD_LIBRARY_PATH=$bdir/$ver/.libs:$bdir/$ver/threads/.libs
%make_build -C $ver check
for((iprec=0;iprec<%{nprec};iprec++)) ; do
export LD_LIBRARY_PATH=$bdir/${prec_name[iprec]}/.libs:$bdir/${prec_name[iprec]}/threads/.libs
%make_build -C ${prec_name[iprec]} check
done
# MPI
@ -398,9 +395,9 @@ done
export OMPI_MCA_rmaps_base_oversubscribe=1
for mpi in %{mpi_list} ; do
module load mpi/${mpi}-%{_arch}
for ver in single double long ; do
export LD_LIBRARY_PATH=$bdir/$ver/.libs:$bdir/$ver/threads/.libs
%make_build -C ${mpi}-${ver}/mpi check
for((iprec=0;iprec<%{nmpiprec};iprec++)) ; do
export LD_LIBRARY_PATH=$bdir/${prec_name[iprec]}/.libs:$bdir/${prec_name[iprec]}/threads/.libs
%make_build -C ${mpi}-${prec_name[iprec]}/mpi check
done
module unload mpi/${mpi}-%{_arch}
done
@ -527,6 +524,7 @@ done
* Mon Mar 27 2023 Trent Piepho <tpiepho@gmail.com> - 3.3.10-6
- Enable AVX2 on x86-86
- Enable NEON on aarch64
- Clean up precision list
* Thu Mar 02 2023 Orion Poplawski <orion@nwra.com> - 3.3.10-5
- Use make macros