Skip to content

Commit

Permalink
progress
Browse files Browse the repository at this point in the history
  • Loading branch information
jngrad committed Jun 27, 2024
1 parent 6f45053 commit 63e3c02
Show file tree
Hide file tree
Showing 41 changed files with 3,265 additions and 1,049 deletions.
2 changes: 2 additions & 0 deletions cmake/FindCUDACompilerNVCC.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ target_compile_options(
$<$<CONFIG:Coverage>:-Xptxas=-O3 -Xcompiler=-Og,-g,--coverage,-fprofile-abs-path>
$<$<CONFIG:RelWithAssert>:-Xptxas=-O3 -Xcompiler=-O3,-g>
$<$<BOOL:${CMAKE_OSX_SYSROOT}>:-Xcompiler=-isysroot;-Xcompiler=${CMAKE_OSX_SYSROOT}>
# workaround for https://github.com/espressomd/espresso/issues/4943
$<$<BOOL:${ESPRESSO_BUILD_WITH_CCACHE}>:$<$<CONFIG:Coverage>:--coverage -fprofile-abs-path>>
)

function(espresso_add_gpu_library)
Expand Down
13 changes: 8 additions & 5 deletions cmake/unit_test.cmake → cmake/espresso_unit_test.cmake
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (C) 2016-2022 The ESPResSo project
# Copyright (C) 2016-2024 The ESPResSo project
#
# This file is part of ESPResSo.
#
Expand All @@ -17,9 +17,12 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#

# unit_test function
function(UNIT_TEST)
cmake_parse_arguments(TEST "" "NAME;NUM_PROC" "SRC;DEPENDS" ${ARGN})
function(ESPRESSO_UNIT_TEST)
cmake_parse_arguments(TEST "" "SRC;NAME;NUM_PROC" "DEPENDS" ${ARGN})
if(NOT DEFINED TEST_NAME)
cmake_path(GET TEST_SRC STEM TEST_NAME)
set(TEST_NAME ${TEST_NAME} PARENT_SCOPE)
endif()
if(${TEST_SRC} MATCHES ".*\.cu$")
espresso_add_gpu_executable(${TEST_NAME} ${TEST_SRC})
else()
Expand Down Expand Up @@ -72,4 +75,4 @@ function(UNIT_TEST)
${TEST_NAME} PROPERTIES ENVIRONMENT "${TEST_ENV_VARIABLES}")

add_dependencies(check_unit_tests ${TEST_NAME})
endfunction(UNIT_TEST)
endfunction()
112 changes: 22 additions & 90 deletions maintainer/CI/build_cmake.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash
#
# Copyright (C) 2016-2022 The ESPResSo project
# Copyright (C) 2016-2024 The ESPResSo project
# Copyright (C) 2014 Olaf Lenz
#
# Copying and distribution of this file, with or without modification,
Expand Down Expand Up @@ -151,50 +151,18 @@ cmake_params="-D CMAKE_BUILD_TYPE=${build_type} -D ESPRESSO_WARNINGS_ARE_ERRORS=
cmake_params="${cmake_params} -D CMAKE_INSTALL_PREFIX=/tmp/espresso-unit-tests -D ESPRESSO_INSIDE_DOCKER=ON"
cmake_params="${cmake_params} -D ESPRESSO_CTEST_ARGS:STRING=-j${check_procs} -D ESPRESSO_TEST_TIMEOUT=${test_timeout}"

if [ "${make_check_benchmarks}" = true ]; then
cmake_params="${cmake_params} -D ESPRESSO_BUILD_BENCHMARKS=ON"
fi

if [ "${with_ccache}" = true ]; then
cmake_params="${cmake_params} -D ESPRESSO_BUILD_WITH_CCACHE=ON"
fi

if [ "${with_caliper}" = true ]; then
cmake_params="${cmake_params} -D ESPRESSO_BUILD_WITH_CALIPER=ON"
fi

if [ "${with_hdf5}" = true ]; then
cmake_params="${cmake_params} -D ESPRESSO_BUILD_WITH_HDF5=ON"
else
cmake_params="${cmake_params} -D ESPRESSO_BUILD_WITH_HDF5=OFF"
fi

if [ "${with_fftw}" = true ]; then
cmake_params="${cmake_params} -D ESPRESSO_BUILD_WITH_FFTW=ON"
else
cmake_params="${cmake_params} -D ESPRESSO_BUILD_WITH_FFTW=OFF"
fi

if [ "${with_gsl}" = true ]; then
cmake_params="${cmake_params} -D ESPRESSO_BUILD_WITH_GSL=ON"
else
cmake_params="${cmake_params} -D ESPRESSO_BUILD_WITH_GSL=OFF"
fi

if [ "${with_scafacos}" = true ]; then
cmake_params="${cmake_params} -D ESPRESSO_BUILD_WITH_SCAFACOS=ON"
else
cmake_params="${cmake_params} -D ESPRESSO_BUILD_WITH_SCAFACOS=OFF"
fi

if [ "${with_stokesian_dynamics}" = true ]; then
cmake_params="${cmake_params} -D ESPRESSO_BUILD_WITH_STOKESIAN_DYNAMICS=ON"
else
cmake_params="${cmake_params} -D ESPRESSO_BUILD_WITH_STOKESIAN_DYNAMICS=OFF"
fi
cmake_params="${cmake_params} -D ESPRESSO_BUILD_BENCHMARKS=${make_check_benchmarks}"
cmake_params="${cmake_params} -D ESPRESSO_BUILD_WITH_CCACHE=${with_ccache}"
cmake_params="${cmake_params} -D ESPRESSO_BUILD_WITH_CALIPER=${with_caliper}"
cmake_params="${cmake_params} -D ESPRESSO_BUILD_WITH_HDF5=${with_hdf5}"
cmake_params="${cmake_params} -D ESPRESSO_BUILD_WITH_FFTW=${with_fftw}"
cmake_params="${cmake_params} -D ESPRESSO_BUILD_WITH_GSL=${with_gsl}"
cmake_params="${cmake_params} -D ESPRESSO_BUILD_WITH_SCAFACOS=${with_scafacos}"
cmake_params="${cmake_params} -D ESPRESSO_BUILD_WITH_STOKESIAN_DYNAMICS=${with_stokesian_dynamics}"
cmake_params="${cmake_params} -D ESPRESSO_BUILD_WITH_WALBERLA=${with_walberla}"

if [ "${with_walberla}" = true ]; then
cmake_params="${cmake_params} -D ESPRESSO_BUILD_WITH_WALBERLA=ON -D ESPRESSO_BUILD_WITH_WALBERLA_FFT=ON"
cmake_params="${cmake_params} -D ESPRESSO_BUILD_WITH_WALBERLA_FFT=ON"
if [ "${with_walberla_avx}" = true ]; then
cmake_params="${cmake_params} -D ESPRESSO_BUILD_WITH_WALBERLA_AVX=ON"
fi
Expand All @@ -203,39 +171,18 @@ if [ "${with_walberla}" = true ]; then
mpiexec_preflags="${mpiexec_preflags:+$mpiexec_preflags;}--bind-to;none"
fi

if [ "${with_coverage}" = true ]; then
cmake_params="-D ESPRESSO_BUILD_WITH_COVERAGE=ON ${cmake_params}"
fi

if [ "${with_coverage_python}" = true ]; then
cmake_params="-D ESPRESSO_BUILD_WITH_COVERAGE_PYTHON=ON ${cmake_params}"
fi

if [ "${with_asan}" = true ]; then
cmake_params="-D ESPRESSO_BUILD_WITH_ASAN=ON ${cmake_params}"
fi

if [ "${with_ubsan}" = true ]; then
cmake_params="-D ESPRESSO_BUILD_WITH_UBSAN=ON ${cmake_params}"
fi

if [ "${with_static_analysis}" = true ]; then
cmake_params="-D ESPRESSO_BUILD_WITH_CLANG_TIDY=ON ${cmake_params}"
fi

if [ "${run_checks}" = true ]; then
cmake_params="${cmake_params} -D ESPRESSO_BUILD_TESTS=ON"
else
cmake_params="${cmake_params} -D ESPRESSO_BUILD_TESTS=OFF"
fi
cmake_params="${cmake_params} -D ESPRESSO_BUILD_WITH_COVERAGE=${with_coverage}"
cmake_params="${cmake_params} -D ESPRESSO_BUILD_WITH_COVERAGE_PYTHON=${with_coverage_python}"
cmake_params="${cmake_params} -D ESPRESSO_BUILD_WITH_ASAN=${with_asan}"
cmake_params="${cmake_params} -D ESPRESSO_BUILD_WITH_UBSAN=${with_ubsan}"
cmake_params="${cmake_params} -D ESPRESSO_BUILD_WITH_CLANG_TIDY=${with_static_analysis}"
cmake_params="${cmake_params} -D ESPRESSO_BUILD_WITH_CUDA=${with_cuda}"

if [ "${with_cuda}" = true ]; then
cmake_params="-D ESPRESSO_BUILD_WITH_CUDA=ON -D CUDAToolkit_ROOT=/usr/lib/cuda ${cmake_params}"
cmake_params="${cmake_params} -D CUDAToolkit_ROOT=/usr/lib/cuda"
if [ "${CUDACXX}" = "" ] && [ "${CXX}" != "" ]; then
cmake_params="-D CMAKE_CUDA_FLAGS='--compiler-bindir=$(which "${CXX}")' ${cmake_params}"
cmake_params="${cmake_params} -D CMAKE_CUDA_FLAGS='--compiler-bindir=$(which "${CXX}")'"
fi
else
cmake_params="-D ESPRESSO_BUILD_WITH_CUDA=OFF ${cmake_params}"
fi

command -v nvidia-smi && nvidia-smi || true
Expand Down Expand Up @@ -281,11 +228,10 @@ fi
# CONFIGURE
start "CONFIGURE"

MYCONFIG_DIR="${srcdir}/maintainer/configs"
if [ "${myconfig}" = "default" ]; then
echo "Using default myconfig."
else
myconfig_file="${MYCONFIG_DIR}/${myconfig}.hpp"
myconfig_file="${srcdir}/maintainer/configs/${myconfig}.hpp"
if [ ! -e "${myconfig_file}" ]; then
echo "${myconfig_file} does not exist!"
exit 1
Expand Down Expand Up @@ -315,9 +261,8 @@ end "BUILD"
# library. See details in https://github.com/espressomd/espresso/issues/2249
# Can't do this check on CUDA though because nvcc creates a host function
# that just calls exit() for each device function, and can't do this with
# coverage because gcov 9.0 adds code that calls exit(), and can't do this
# with walberla because the library calls exit() in assertions.
if [[ "${with_coverage}" == false && ( "${with_cuda}" == false || "${with_cuda_compiler}" != "nvcc" ) && "${with_walberla}" != "true" ]]; then
if [[ ( "${with_cuda}" == false || "${with_cuda_compiler}" != "nvcc" ) && "${with_walberla}" != "true" ]]; then
if nm -o -C $(find . -name '*.so') | grep '[^a-z]exit@@GLIBC'; then
echo "Found calls to exit() function in shared libraries."
exit 1
Expand Down Expand Up @@ -409,20 +354,7 @@ if [ "${with_coverage}" = true ] || [ "${with_coverage_python}" = true ]; then
if [ "${with_coverage}" = true ]; then
echo "Running lcov and gcov..."
codecov_opts="${codecov_opts} --gcov"
lcov --gcov-tool "${GCOV:-gcov}" \
--quiet \
--ignore-errors graph,mismatch,mismatch,gcov,unused \
--directory . \
--filter brace,blank,range,region \
--capture \
--rc lcov_json_module="JSON::XS" \
--exclude "/usr/*" \
--exclude "$(realpath .)/_deps/*" \
--exclude "$(realpath .)/src/python/espressomd/*" \
--exclude "$(realpath "${srcdir}")/src/walberla_bridge/src/*/generated_kernels/*" \
--exclude "$(realpath "${srcdir}")/libs/*" \
--exclude "*/tmpxft_*cudafe1.stub.*" \
--output-file coverage.info
./run_lcov.sh coverage.info
fi
if [ "${with_coverage_python}" = true ]; then
echo "Running python3-coverage..."
Expand Down
45 changes: 45 additions & 0 deletions maintainer/CI/run_lcov.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/usr/bin/env sh
#
# Copyright (C) 2017-2024 The ESPResSo project
#
# This file is part of ESPResSo.
#
# ESPResSo is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# ESPResSo is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#

set -e

output="${1:-coverage.info}"
bindir="$(realpath .)"
srcdir="$(sed -nr "s/^ESPResSo_SOURCE_DIR:STATIC=(.+)/\1/p" "${bindir}/CMakeCache.txt")"

if [ "${srcdir}" = "" ]; then
echo "Cannot extract ESPResSo_SOURCE_DIR variable from the CMake cache" >&2
exit 2
fi

lcov --gcov-tool "${GCOV:-gcov}" \
--quiet \
--ignore-errors graph,mismatch,mismatch,gcov,unused \
--directory . \
--filter brace,blank,range,region \
--capture \
--rc lcov_json_module="JSON::XS" \
--exclude "/usr/*" \
--exclude "*/tmpxft_*cudafe1.stub.*" \
--exclude "${bindir}/_deps/*" \
--exclude "${bindir}/src/python/espressomd/*" \
--exclude "${srcdir}/src/walberla_bridge/src/*/generated_kernels/*" \
--exclude "${srcdir}/libs/*" \
--output-file "${output}"
Loading

0 comments on commit 63e3c02

Please sign in to comment.