Skip to content

Commit

Permalink
fix: rewrite part of the build system,so that paths are not linked to…
Browse files Browse the repository at this point in the history
… build directories.

Signed-off-by: Franz R. Sattler <[email protected]>
  • Loading branch information
Franz R. Sattler committed Dec 23, 2024
1 parent 79483c5 commit 17807ec
Show file tree
Hide file tree
Showing 23 changed files with 464 additions and 284 deletions.
15 changes: 1 addition & 14 deletions DiFfRG/cmake/install_bundled.cmake
Original file line number Diff line number Diff line change
@@ -1,17 +1,4 @@
set(BUNDLE_DIR ${CMAKE_SOURCE_DIR}/../external)

install(DIRECTORY ${BUNDLE_DIR}/autodiff_install DESTINATION bundled MESSAGE_NEVER)
install(DIRECTORY ${BUNDLE_DIR}/Catch2_install DESTINATION bundled MESSAGE_NEVER)
install(DIRECTORY ${BUNDLE_DIR}/dealii_install DESTINATION bundled MESSAGE_NEVER)
install(DIRECTORY ${BUNDLE_DIR}/kokkos_install DESTINATION bundled MESSAGE_NEVER)
install(DIRECTORY ${BUNDLE_DIR}/rapidcsv DESTINATION bundled MESSAGE_NEVER)
install(DIRECTORY ${BUNDLE_DIR}/rmm_build DESTINATION bundled MESSAGE_NEVER)
install(DIRECTORY ${BUNDLE_DIR}/spdlog_install DESTINATION bundled MESSAGE_NEVER)
install(DIRECTORY ${BUNDLE_DIR}/sundials_install DESTINATION bundled MESSAGE_NEVER)
install(DIRECTORY ${BUNDLE_DIR}/eigen_install DESTINATION bundled MESSAGE_NEVER)
install(DIRECTORY ${BUNDLE_DIR}/boost_install DESTINATION bundled MESSAGE_NEVER)
install(DIRECTORY ${BUNDLE_DIR}/qmc_install DESTINATION bundled MESSAGE_NEVER)
install(DIRECTORY ${BUNDLE_DIR}/thread-pool_install DESTINATION bundled MESSAGE_NEVER)
cmake_policy(SET CMP0177 NEW)

install(DIRECTORY ${CMAKE_SOURCE_DIR}/../python DESTINATION ./ MESSAGE_NEVER)
install(DIRECTORY ${CMAKE_SOURCE_DIR}/../Mathematica DESTINATION ./ MESSAGE_NEVER)
10 changes: 7 additions & 3 deletions DiFfRG/cmake/setup_build_system.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@

if(${CMAKE_PROJECT_NAME} STREQUAL "DiFfRG")
set(BASE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
set(BUNDLED_DIR ${BASE_DIR}/../external)
if (NOT DEFINED BUNDLED_DIR)
set(BUNDLED_DIR ${BASE_DIR}/../external)
endif()
else()
set(BASE_DIR ${DiFfRG_BASE_DIR})
set(BUNDLED_DIR ${BASE_DIR}/bundled)
Expand Down Expand Up @@ -42,10 +44,12 @@ link_libraries(TBB::tbb)
find_package(OpenMP REQUIRED)
link_libraries(OpenMP::OpenMP_CXX)

find_package(Boost 1.80 REQUIRED HINTS ${BUNDLED_DIR}/boost_install)
find_package(Boost 1.80 REQUIRED HINTS ${BUNDLED_DIR}/boost_install COMPONENTS thread random iostreams math serialization system)
message(STATUS "Boost version: ${Boost_VERSION}")
message(STATUS "Boost include dir: ${Boost_INCLUDE_DIRS}")
message(STATUS "Boost libraries: ${Boost_LIBRARIES}")
include_directories(SYSTEM ${Boost_INCLUDE_DIRS})
link_libraries(${Boost_LIBRARIES})

find_package(autodiff REQUIRED PATHS ${BUNDLED_DIR}/autodiff_install)
link_libraries(autodiff::autodiff)
Expand All @@ -61,7 +65,7 @@ link_libraries(GSL::gsl)
message(STATUS "GSL include dir: ${GSL_INCLUDE_DIR}")
include_directories(SYSTEM ${GSL_INCLUDE_DIR})

include_directories(SYSTEM ${BUNDLED_DIR}/rapidcsv/src)
include_directories(SYSTEM ${BUNDLED_DIR}/rapidcsv_install/include)
include_directories(SYSTEM ${BUNDLED_DIR}/qmc_install)
include_directories(SYSTEM ${BUNDLED_DIR}/thread-pool_install/include)

Expand Down
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ RUN dnf --enablerepo=devel install -y gcc-toolset-12 cmake git openblas-devel do
RUN git reset --hard
RUN cat config_docker >config
SHELL [ "/usr/bin/scl", "enable", "gcc-toolset-12"]
RUN bash -i build.sh -j $threads -f $cuda -i /opt/DiFfRG
RUN bash -i build.sh -j $threads -f $cuda -i DiFfRG_install &> build.log
RUN ln -s /DiFfRG/DiFfRG_install /opt/DiFfRG

# run the command
CMD ["scl", "enable", "gcc-toolset-12", "bash"]
105 changes: 46 additions & 59 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,65 +47,52 @@ source config
# ##############################################################################

git submodule update --init --recursive --jobs ${threads}
echo
echo "Building bundled libraries..."
cd ${scriptpath}/external
start=$(date +%s)
echo " Building QMC..."
bash -i ./build_qmc.sh -j ${threads} &>/dev/null || {
echo " Failed to build qmc, aborting."
exit 1
}
echo " Building autodiff..."
bash -i ./build_autodiff.sh -j ${threads} &>/dev/null || {
echo " Failed to build autodiff, aborting."
exit 1
}
echo " Building Boost..."
bash -i ./build_boost.sh -j ${threads} &>/dev/null || {
echo " Failed to build Boost, aborting."
exit 1
}
echo " Building Catch2..."
bash -i ./build_Catch2.sh -j ${threads} &>/dev/null || { echo " Failed to build Catch2, tests will not work. Continuing setup process."; }
echo " Building Eigen3..."
bash -i ./build_eigen.sh -j ${threads} &>/dev/null || {
echo " Failed to build Eigen, aborting."
exit 1
}
echo " Building thread-pool..."
bash -i ./build_thread-pool.sh -j ${threads} &>/dev/null || {
echo " Failed to build thread-pool, aborting."
exit 1
}
echo " Building spdlog..."
bash -i ./build_spdlog.sh -j ${threads} &>/dev/null || {
echo " Failed to build spdlog, aborting."
exit 1
}
echo " Building rmm..."
bash -i ./build_rmm.sh -j ${threads} &>/dev/null || { echo " Failed to build rmm, CUDA will not work. Continuing setup process."; }
echo " Building kokkos..."
bash -i ./build_kokkos.sh -j ${threads} &>/dev/null || {
echo " Failed to build kokkos, aborting."
exit 1
}
echo " Building sundials..."
bash -i ./build_sundials.sh -j ${threads} &>/dev/null || {
echo " Failed to build SUNDIALS, aborting."
exit 1
}
echo " Building deal.II..."
bash -i ./build_dealii.sh -j ${threads} &>/dev/null || {
echo " Failed to build deal.ii, aborting."
exit 1
}
end=$(date +%s)
runtime=$((end - start))
elapsed="Elapsed: $(($runtime / 3600))hrs $((($runtime / 60) % 60))min $(($runtime % 60))sec"
echo " Done. (${elapsed})"
cd ${scriptpath}
echo

if [[ -z ${install_dir+x} ]]; then
echo
read -p "Install DiFfRG library globally to /opt/DiFfRG? [y/N/path] " install_dir
install_dir=${install_dir:-N}
fi

if [[ -z ${option_setup_library+x} ]]; then
read -p "Build DiFfRG library? [Y/n] " option_setup_library
option_setup_library=${option_setup_library:-Y}
fi

if [[ ${install_dir} != "n" ]] && [[ ${install_dir} != "N" ]]; then
cd ${SCRIPTPATH}

# Make sure the install directory is absolute
idir=$(expandPath ${install_dir}/)
idir=$(readlink --canonicalize ${idir})
echo "DiFfRG library will be installed in ${idir}"

# Check if the install directory is writable
mkdir -p ${idir} &>/dev/null && touch ${idir}/_permission_test &>/dev/null || {
failed_first=1
}

# Install dependencies
start=$(date +%s)
cd ${SCRIPTPATH}/external
if [[ $failed_first == 0 ]]; then
rm ${idir}/_permission_test
echo
echo "Installing dependencies..."
bash -i ./install.sh -i ${idir}/bundled -j ${THREADS} ${cuda_flag} # &>${LOGPATH}/DiFfRG_dependencies_install.log
else
echo "Elevated permissions required for install path ${idir}."
sudo mkdir -p ${idir}
echo
echo "Installing dependencies..."
sudo -E bash -i ./install.sh -i ${idir}/bundled -j ${THREADS} ${cuda_flag} # &>${LOGPATH}/DiFfRG_dependencies_install.log
fi
end=$(date +%s)
runtime=$((end - start))
elapsed="Elapsed: $(($runtime / 3600))hrs $((($runtime / 60) % 60))min $(($runtime % 60))sec"
echo " Done. (${elapsed})"
echo
fi

# ##############################################################################
# Setup and build library
Expand Down
6 changes: 3 additions & 3 deletions config
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
# export CXX_FLAGS="-march=core-avx2 -fPIC"
# export C_FLAGS="-march=core-avx2 -fPIC"
# export CUDA_FLAGS="-arch=sm_35"
export CXX_FLAGS="-march=native -fPIC -flto"
export C_FLAGS="-march=native -fPIC -flto"
export CXX_FLAGS="-march=native -fPIC -flto=auto"
export C_FLAGS="-march=native -fPIC -flto=auto"
export CUDA_FLAGS=""
export CUDA_ARCHITECTURES="native"

Expand Down Expand Up @@ -45,4 +45,4 @@ if command -v dnsdomainname &>/dev/null; then
echo ${DEAL_II_CMAKE}
echo
fi
fi
fi
2 changes: 2 additions & 0 deletions external/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,7 @@ eigen_build/
eigen_install/
qmc_install/
thread-pool_install/
rapidcsv_build/
rapidcsv_install/
logs/
*.log
94 changes: 94 additions & 0 deletions external/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
#!/bin/bash

# ##############################################################################
# Script setup
# ##############################################################################

threads='1'
while getopts j:c flag; do
case "${flag}" in
j) threads=${OPTARG} ;;
c) cuda="-c" ;;
?)
exit 2
;;
esac
done

source ../config

################################################################################
# This script builds all the dependencies for the project.
################################################################################

echo " Building QMC..."
bash -i ./build_qmc.sh -j ${threads} &>/dev/null || {
echo " Failed to build qmc, aborting."
exit 1
}

echo " Building autodiff..."
bash -i ./build_autodiff.sh -j ${threads} &>/dev/null || {
echo " Failed to build autodiff, aborting."
exit 1
}

echo " Building rapidcsv..."
bash -i ./build_rapidcsv.sh -j ${threads} &>/dev/null || {
echo " Failed to build rapidcsv, aborting."
exit 1
}

echo " Building Boost..."
bash -i ./build_boost.sh -j ${threads} &>/dev/null || {
echo " Failed to build Boost, aborting."
exit 1
}

echo " Building Catch2..."
bash -i ./build_Catch2.sh -j ${threads} &>/dev/null || {
echo " Failed to build Catch2, tests will not work. Continuing setup process."
}

echo " Building Eigen3..."
bash -i ./build_eigen.sh -j ${threads} &>/dev/null || {
echo " Failed to build Eigen, aborting."
exit 1
}

echo " Building thread-pool..."
bash -i ./build_thread-pool.sh -j ${threads} &>/dev/null || {
echo " Failed to build thread-pool, aborting."
exit 1
}

echo " Building spdlog..."
bash -i ./build_spdlog.sh -j ${threads} &>/dev/null || {
echo " Failed to build spdlog, aborting."
exit 1
}

if [[ "${cuda}" == "-c" ]]; then
echo " Building rmm..."
bash -i ./build_rmm.sh -j ${threads} &>/dev/null || {
echo " Failed to build rmm, CUDA will not work. Continuing setup process."
}
fi

echo " Building kokkos..."
bash -i ./build_kokkos.sh -j ${threads} &>/dev/null || {
echo " Failed to build kokkos, aborting."
exit 1
}

echo " Building sundials..."
bash -i ./build_sundials.sh -j ${threads} &>/dev/null || {
echo " Failed to build SUNDIALS, aborting."
exit 1
}

echo " Building deal.II..."
bash -i ./build_dealii.sh -j ${threads} &>/dev/null || {
echo " Failed to build deal.ii, aborting."
exit 1
}
2 changes: 1 addition & 1 deletion external/build_Catch2.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ SCRIPT_PATH="$(
pwd -P
)"

source $SCRIPT_PATH/build_scripts/populate_paths.sh
source $SCRIPT_PATH/build_scripts/parse_flags.sh
source $SCRIPT_PATH/build_scripts/populate_paths.sh
source $SCRIPT_PATH/build_scripts/cleanup_build_if_asked.sh
source $SCRIPT_PATH/build_scripts/setup_folders.sh

Expand Down
26 changes: 13 additions & 13 deletions external/build_autodiff.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,26 @@ SCRIPT_PATH="$(
pwd -P
)"

source $SCRIPT_PATH/build_scripts/populate_paths.sh
source $SCRIPT_PATH/build_scripts/parse_flags.sh
source $SCRIPT_PATH/build_scripts/populate_paths.sh
source $SCRIPT_PATH/build_scripts/cleanup_build_if_asked.sh
source $SCRIPT_PATH/build_scripts/setup_folders.sh

cd $BUILD_PATH

cmake -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_CUDA_FLAGS=${CUDA_FLAGS} \
-DCMAKE_CUDA_ARCHITECTURES=${CUDA_ARCHITECTURES} \
-DCMAKE_CXX_FLAGS="${CXX_FLAGS} -O3 -DNDEBUG" \
-DCMAKE_EXE_LINKER_FLAGS="${EXE_LINKER_FLAGS}" \
-DAUTODIFF_BUILD_TESTS=OFF \
-DAUTODIFF_BUILD_PYTHON=OFF \
-DAUTODIFF_BUILD_EXAMPLES=OFF \
-DAUTODIFF_BUILD_DOCS=OFF \
-DEigen3_DIR=${SCRIPT_PATH}/eigen_install \
-DCMAKE_INSTALL_PREFIX=${INSTALL_PATH} \
-S ${SOURCE_PATH} \
2>&1 | tee $CMAKE_LOG_FILE
-DCMAKE_CUDA_FLAGS=${CUDA_FLAGS} \
-DCMAKE_CUDA_ARCHITECTURES=${CUDA_ARCHITECTURES} \
-DCMAKE_CXX_FLAGS="${CXX_FLAGS} -O3 -DNDEBUG" \
-DCMAKE_EXE_LINKER_FLAGS="${EXE_LINKER_FLAGS}" \
-DAUTODIFF_BUILD_TESTS=OFF \
-DAUTODIFF_BUILD_PYTHON=OFF \
-DAUTODIFF_BUILD_EXAMPLES=OFF \
-DAUTODIFF_BUILD_DOCS=OFF \
-DEigen3_DIR=${SCRIPT_PATH}/eigen_install \
-DCMAKE_INSTALL_PREFIX=${INSTALL_PATH} \
-S ${SOURCE_PATH} \
2>&1 | tee $CMAKE_LOG_FILE

make -j $THREADS 2>&1 | tee $MAKE_LOG_FILE
make -j $THREADS install
2 changes: 1 addition & 1 deletion external/build_boost.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ SCRIPT_PATH="$(
pwd -P
)"

source $SCRIPT_PATH/build_scripts/populate_paths.sh
source $SCRIPT_PATH/build_scripts/parse_flags.sh
source $SCRIPT_PATH/build_scripts/populate_paths.sh
source $SCRIPT_PATH/build_scripts/cleanup_build_if_asked.sh
source $SCRIPT_PATH/build_scripts/setup_folders.sh

Expand Down
11 changes: 5 additions & 6 deletions external/build_dealii.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ SCRIPT_PATH="$(
pwd -P
)"

source $SCRIPT_PATH/build_scripts/populate_paths.sh
source $SCRIPT_PATH/build_scripts/parse_flags.sh
source $SCRIPT_PATH/build_scripts/populate_paths.sh
source $SCRIPT_PATH/build_scripts/cleanup_build_if_asked.sh
source $SCRIPT_PATH/build_scripts/setup_folders.sh

Expand All @@ -17,19 +17,18 @@ cmake -DCMAKE_BUILD_TYPE=DebugRelease \
-DDEAL_II_COMPONENT_EXAMPLES=OFF \
-DDEAL_II_COMPONENT_DOCUMENTATION=OFF \
-DDEAL_II_ALLOW_PLATFORM_INTROSPECTION=ON \
-DDEAL_II_WITH_CUDA=OFF \
-DDEAL_II_WITH_MPI=OFF \
-DDEAL_II_USE_LTO=ON \
-DDEAL_II_WITH_UMFPACK=ON \
-DDEAL_II_WITH_TASKFLOW=OFF \
-DDEAL_II_WITH_VTK=OFF \
-DDEAL_II_USE_LTO=ON \
-DCMAKE_CXX_FLAGS="${CXX_FLAGS}" \
-DCMAKE_EXE_LINKER_FLAGS="${EXE_LINKER_FLAGS}" \
-DCMAKE_CXX_STANDARD=17 \
-DKOKKOS_DIR=${SCRIPT_PATH}/kokkos_install \
-DSUNDIALS_DIR=${SCRIPT_PATH}/sundials_install \
-DKOKKOS_DIR=${TOP_INSTALL_PATH}/kokkos_install \
-DSUNDIALS_DIR=${TOP_INSTALL_PATH}/sundials_install \
${DEAL_II_CMAKE} \
-DBOOST_DIR=${SCRIPT_PATH}/boost_install \
-DBOOST_DIR=${TOP_INSTALL_PATH}/boost_install \
-DCMAKE_INSTALL_PREFIX=${INSTALL_PATH} \
-S ${SOURCE_PATH} \
2>&1 | tee $CMAKE_LOG_FILE
Expand Down
Loading

0 comments on commit 17807ec

Please sign in to comment.