Skip to content

Commit

Permalink
Split FFTW3 into double and float versions for ROOT and O2 (alisw#5363)
Browse files Browse the repository at this point in the history
* Split FFTW3 into double and float versions for ROOT and O2

ROOT requires libfftw3, but O2 requires libfftw3f.

Also, make sure that ROOT actually finds libfftw3 and doesn't just disable the
feature we request.

* Combine fftw3 and fftw3f libraries into one package
  • Loading branch information
TimoWilken authored Feb 23, 2024
1 parent 8c57371 commit 90837e5
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 37 deletions.
55 changes: 18 additions & 37 deletions fftw3.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,44 +9,25 @@ build_requires:
- "GCC-Toolchain:(?!osx)"
---
#!/bin/bash -e
export FFTW3_WITH_AVX # use AVX with float or double. Unset automatically for long double and quad
# ROOT and O2 need different variants of fftw3, but we cannot configure fftw3
# to build both at the same time. As a workaround, configure and build one,
# then wipe out the build directory and configure and build the second one.

if [[ $FFTW3_DOUBLE == "ON" ]]; then # ensure only one option is set and AVX is disabled if necessary
FFTW3_FLOAT="OFF"
FFTW3_LONG_DOUBLE="OFF"
elif [[ $FFTW3_LONG_DOUBLE == "ON" ]]; then
unset FFTW3_WITH_AVX
FFTW3_FLOAT="OFF"
FFTW3_DOUBLE="OFF"
else # keep FLOAT default option as it was
FFTW3_FLOAT="ON"
FFTW3_DOUBLE="OFF"
FFTW3_LONG_DOUBLE="OFF"
fi
# First, build fftw3 (double precision), required by ROOT.
cmake -S "$SOURCEDIR" -B "$BUILDDIR/fftw3" \
-DCMAKE_INSTALL_PREFIX:PATH="$INSTALLROOT" \
-DCMAKE_INSTALL_LIBDIR:PATH=lib
make -C "$BUILDDIR/fftw3" ${JOBS+-j "$JOBS"}
make -C "$BUILDDIR/fftw3" install

case $ARCHITECTURE in
osx_arm64)
cmake $SOURCEDIR \
-DCMAKE_INSTALL_PREFIX:PATH="${INSTALLROOT}" \
-DCMAKE_INSTALL_LIBDIR:PATH="lib" \
-DENABLE_LONG_DOUBLE=${FFTW3_LONG_DOUBLE-OFF} \
-DENABLE_FLOAT=${FFTW3_FLOAT-OFF}
;;
*)
cmake $SOURCEDIR \
-DCMAKE_INSTALL_PREFIX:PATH="${INSTALLROOT}" \
-DCMAKE_INSTALL_LIBDIR:PATH="lib" \
-DENABLE_LONG_DOUBLE=${FFTW3_LONG_DOUBLE-OFF} \
-DENABLE_FLOAT=${FFTW3_FLOAT-OFF} \
${FFTW3_WITH_AVX:+-DENABLE_AVX=ON}
;;
esac

make ${JOBS+-j $JOBS}
make install
# Now reconfigure for fftw3f (single precision float), required by O2.
cmake -S "$SOURCEDIR" -B "$BUILDDIR/fftw3f" \
-DCMAKE_INSTALL_PREFIX:PATH="$INSTALLROOT" \
-DCMAKE_INSTALL_LIBDIR:PATH=lib \
-DENABLE_FLOAT=ON
make -C "$BUILDDIR/fftw3f" ${JOBS+-j "$JOBS"}
make -C "$BUILDDIR/fftw3f" install

#Modulefile
MODULEDIR="$INSTALLROOT/etc/modulefiles"
MODULEFILE="$MODULEDIR/$PKGNAME"
mkdir -p "$MODULEDIR"
alibuild-generate-module --bin --lib > $MODULEFILE
mkdir -p "$INSTALLROOT/etc/modulefiles"
alibuild-generate-module --bin --lib > "$INSTALLROOT/etc/modulefiles/$PKGNAME"
4 changes: 4 additions & 0 deletions root.sh
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,10 @@ cmake $SOURCEDIR

cmake --build . --target install ${JOBS+-j $JOBS}

# Make sure ROOT actually found its build dependencies and didn't disable
# features we requested. "-Dfail-on-missing=ON" would probably be better.
[ "$("$INSTALLROOT/bin/root-config" --has-fftw3)" = yes ]

# Add support for ROOT_PLUGIN_PATH envvar for specifying additional plugin search paths
grep -v '^Unix.*.Root.PluginPath' $INSTALLROOT/etc/system.rootrc > system.rootrc.0
cat >> system.rootrc.0 <<\EOF
Expand Down

0 comments on commit 90837e5

Please sign in to comment.