Skip to content

Commit

Permalink
alpaka CI: set CMAKE_CXX_COMPILER instead using update-alternatives
Browse files Browse the repository at this point in the history
- Instead changing the default host compiler, set the compiler via CMAKE_CXX_COMPILER argument at CMake configure.
- Rename environment variable CXX to ALPAKA_CI_CXX, because CXX can cause unexpected side effects.
- The environment variable CMAKE_CXX_COMPILER is created in the scripts depending on the variable ALPAKA_CI_CXX.
- Remove the environment variable CC completely because we do not compile C code.
- Set also CMAKE_CUDA_COMPILER as CMake configure argument manually.
  • Loading branch information
SimeonEhrig authored and psychocoderHPC committed Aug 16, 2024
1 parent a25a2fd commit 00c51bb
Show file tree
Hide file tree
Showing 16 changed files with 120 additions and 105 deletions.
42 changes: 21 additions & 21 deletions .github/workflows/ci.yml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion example/complex/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ set_property(GLOBAL PROPERTY USE_FOLDERS ON)

set(_TARGET_NAME complexNumbers)

project(${_TARGET_NAME})
project(${_TARGET_NAME} LANGUAGES CXX)

#-------------------------------------------------------------------------------
# Find alpaka.
Expand Down
7 changes: 6 additions & 1 deletion script/before_install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,15 @@ if [ "$ALPAKA_CI_OS_NAME" = "Linux" ]
then
if [ "${ALPAKA_CI_STDLIB}" == "libc++" ]
then
if [[ "${CXX}" == "g++"* ]]
if [[ "${ALPAKA_CI_CXX}" == "g++"* ]]
then
echo "using libc++ with g++ not yet supported."
exit 1
fi
fi
fi

if [ "$ALPAKA_CI_OS_NAME" = "Windows" ] || [ "$ALPAKA_CI_OS_NAME" = "macOS" ]
then
export CMAKE_CXX_COMPILER=$ALPAKA_CI_CXX
fi
13 changes: 5 additions & 8 deletions script/gitlabci/job_base.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,12 @@
image: ubuntu:${ALPAKA_CI_UBUNTU_VER}
variables:
ALPAKA_CI_UBUNTU_VER: "20.04"
CC: gcc
CXX: g++
ALPAKA_CI_CXX: g++
alpaka_ACC_CPU_B_SEQ_T_THREADS_ENABLE: "ON"
alpaka_ACC_CPU_B_OMP2_T_SEQ_ENABLE: "ON"
alpaka_ACC_CPU_B_SEQ_T_OMP2_ENABLE: "OFF"
alpaka_ACC_GPU_CUDA_ENABLE: "ON"
CMAKE_CUDA_COMPILER: nvcc
ALPAKA_CI_CUDA_COMPILER: nvcc
ALPAKA_CI_STDLIB: libstdc++
# CI contains a Quadro P5000 (sm_61)
CMAKE_CUDA_ARCHITECTURES: "61"
Expand All @@ -51,13 +50,12 @@
image: ubuntu:${ALPAKA_CI_UBUNTU_VER}
variables:
ALPAKA_CI_UBUNTU_VER: "20.04"
CC: clang
CXX: clang++
ALPAKA_CI_CXX: clang++
alpaka_ACC_CPU_B_SEQ_T_THREADS_ENABLE: "ON"
alpaka_ACC_CPU_B_OMP2_T_SEQ_ENABLE: "ON"
alpaka_ACC_CPU_B_SEQ_T_OMP2_ENABLE: "OFF"
alpaka_ACC_GPU_CUDA_ENABLE: "ON"
CMAKE_CUDA_COMPILER: clang++
ALPAKA_CI_CUDA_COMPILER: clang++
ALPAKA_CI_STDLIB: libstdc++
# CI contains a Quadro P5000 (sm_61)
CMAKE_CUDA_ARCHITECTURES: "61"
Expand Down Expand Up @@ -87,8 +85,7 @@
image: ubuntu:${ALPAKA_CI_UBUNTU_VER}
variables:
ALPAKA_CI_UBUNTU_VER: "22.04"
CC: clang
CXX: clang++
ALPAKA_CI_CXX: clang++
ALPAKA_CI_SANITIZERS: ""
ALPAKA_CI_ANALYSIS: "OFF"
ALPAKA_CI_TBB_VERSION: 2021.4.0
Expand Down
2 changes: 1 addition & 1 deletion script/gitlabci/print_env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ fi
echo -e "2. Run the following export commands in the container to setup enviroment\n"

# take all env variables, filter it and display it with a `export` prefix
printenv | grep -E 'alpaka_*|ALPAKA_*|CMAKE_*|BOOST_|CC|CXX|CUDA_' | while read -r line ; do
printenv | grep -E 'alpaka_*|ALPAKA_*|CMAKE_*|BOOST_|CUDA_' | while read -r line ; do
echo "export $line \\"
done

Expand Down
12 changes: 6 additions & 6 deletions script/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,13 @@ fi

if [ "${ALPAKA_CI_ANALYSIS}" == "ON" ] ;then source ./script/install_analysis.sh ;fi

# Install CUDA before installing gcc as it installs gcc-4.8 and overwrites our selected compiler
if [ "${ALPAKA_CI_INSTALL_CUDA}" == "ON" ] ;then source ./script/install_cuda.sh ;fi

if [ "$ALPAKA_CI_OS_NAME" = "Linux" ]
then
if [[ "${CXX}" == "g++"* ]] ;then source ./script/install_gcc.sh ;fi
if [[ "${ALPAKA_CI_CXX}" == "g++"* ]] ;then source ./script/install_gcc.sh ;fi
# do not install clang if we use HIP, HIP/ROCm is shipping an own clang version
if [[ "${CXX}" == "clang++" ]] && [ "${ALPAKA_CI_INSTALL_HIP}" != "ON" ] ;then source ./script/install_clang.sh ;fi
if [[ "${CXX}" == "icpx" ]] ;then source ./script/install_oneapi.sh ;fi
if [[ "${ALPAKA_CI_CXX}" == "clang++" ]] && [ "${ALPAKA_CI_INSTALL_HIP}" != "ON" ] ;then source ./script/install_clang.sh ;fi
if [[ "${ALPAKA_CI_CXX}" == "icpx" ]] ;then source ./script/install_oneapi.sh ;fi
elif [ "$ALPAKA_CI_OS_NAME" = "macOS" ]
then
echo "### list all applications ###"
Expand All @@ -55,8 +53,10 @@ then
sudo xcode-select -s "/Applications/Xcode_${ALPAKA_CI_XCODE_VER}.app/Contents/Developer"
fi

if [ "${ALPAKA_CI_INSTALL_CUDA}" == "ON" ] ;then source ./script/install_cuda.sh ;fi

# Don't install TBB for oneAPI runners - it will be installed as part of oneAPI
if [ "${ALPAKA_CI_INSTALL_TBB}" = "ON" ] && [ "${CXX}" != "icpx" ]
if [ "${ALPAKA_CI_INSTALL_TBB}" = "ON" ] && [ "${ALPAKA_CI_CXX}" != "icpx" ]
then
source ./script/install_tbb.sh
fi
Expand Down
20 changes: 13 additions & 7 deletions script/install_boost.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ then
: "${ALPAKA_CI_STDLIB?'ALPAKA_CI_STDLIB must be specified'}"
fi
: "${CMAKE_BUILD_TYPE?'CMAKE_BUILD_TYPE must be specified'}"
: "${CXX?'CXX must be specified'}"
: "${CC?'CC must be specified'}"
: "${ALPAKA_CI_CXX?'ALPAKA_CI_CXX must be specified'}"
: "${ALPAKA_CI_INSTALL_ATOMIC?'ALPAKA_CI_INSTALL_ATOMIC must be specified'}"
if [ "$ALPAKA_CI_OS_NAME" = "Windows" ]
then
Expand All @@ -31,7 +30,7 @@ then
ALPAKA_CI_STDLIB=""
fi

if [ "${CXX}" != "icpc" ] && [ "${ALPAKA_CI_STDLIB}" != "libc++" ]
if [ "${ALPAKA_CI_CXX}" != "icpc" ] && [ "${ALPAKA_CI_STDLIB}" != "libc++" ]
then
if agc-manager -e boost@${ALPAKA_BOOST_VERSION} ; then
echo_green "<USE: preinstalled BOOST ${ALPAKA_BOOST_VERSION}>"
Expand Down Expand Up @@ -71,15 +70,22 @@ then
TOOLSET="msvc-14.3"
fi
# Add new versions as needed
elif [ "${CXX}" == "icpc" ]
elif [ "${ALPAKA_CI_CXX}" == "icpc" ]
then
TOOLSET="intel-linux"
elif [ "${CXX}" == "icpx" ]
elif [ "${ALPAKA_CI_CXX}" == "g++" ]
then
TOOLSET="gcc"
elif [ "${ALPAKA_CI_CXX}" == "clang++" ]
then
TOOLSET="clang"
elif [ "${ALPAKA_CI_CXX}" == "icpx" ]
then
# icpx is binary compatibly with g++ and ipcx is not supported by b2
TOOLSET="gcc"
else
TOOLSET="${CC}"
echo_red "unknown ALPAKA_CI_CXX: ${ALPAKA_CI_CXX}"
exit 1
fi

# Bootstrap boost.
Expand Down Expand Up @@ -151,7 +157,7 @@ then

# Clang is not supported by the FindBoost script.
# boost (especially old versions) produces too much warnings when using clang (newer versions) so that the 4 MiB log is too short.
if [[ "${CXX}" == "clang++"* ]]
if [[ "${ALPAKA_CI_CXX}" == "clang++"* ]]
then
ALPAKA_BOOST_B2_CXXFLAGS+=" -Wunused-private-field -Wno-unused-local-typedef -Wno-c99-extensions -Wno-variadic-macros"
fi
Expand Down
16 changes: 9 additions & 7 deletions script/install_clang.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ echo_green "<SCRIPT: install_clang>"

: "${ALPAKA_CI_CLANG_VER?'ALPAKA_CI_CLANG_VER must be specified'}"
: "${ALPAKA_CI_STDLIB?'ALPAKA_CI_STDLIB must be specified'}"
: "${CXX?'CXX must be specified'}"

#TODO(SimeonEhrig): remove this statement, if ppa's are fixed in alpaka-group-container
if [[ -f "/etc/apt/sources.list.d/llvm.list" ]];
Expand Down Expand Up @@ -69,11 +68,14 @@ else
travis_retry sudo apt-get -y --quiet --allow-unauthenticated --no-install-recommends install "${LIBOMP_PACKAGE}"
fi

sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-"${ALPAKA_CI_CLANG_VER}" 50
sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-"${ALPAKA_CI_CLANG_VER}" 50
sudo update-alternatives --install /usr/bin/cc cc /usr/bin/clang-"${ALPAKA_CI_CLANG_VER}" 50
sudo update-alternatives --install /usr/bin/c++ c++ /usr/bin/clang++-"${ALPAKA_CI_CLANG_VER}" 50
which clang++-${ALPAKA_CI_CLANG_VER}
export CMAKE_CXX_COMPILER=$(which clang++-${ALPAKA_CI_CLANG_VER})

# create soft link clang and clang++ to the actual executable
# the boost build script requires that the executable clang++ exist
ln -s $(which clang-${ALPAKA_CI_CLANG_VER}) $(dirname $(which clang-${ALPAKA_CI_CLANG_VER}))/clang
ln -s $(which clang++-${ALPAKA_CI_CLANG_VER}) $(dirname $(which clang++-${ALPAKA_CI_CLANG_VER}))/clang++
fi

which "${CXX}"
${CXX} --version
which "${CMAKE_CXX_COMPILER}"
${CMAKE_CXX_COMPILER} --version
15 changes: 13 additions & 2 deletions script/install_cuda.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ else
if [ "$ALPAKA_CI_OS_NAME" = "Linux" ]
then
: "${ALPAKA_CI_CUDA_DIR?'ALPAKA_CI_CUDA_DIR must be specified'}"
: "${CMAKE_CUDA_COMPILER?'CMAKE_CUDA_COMPILER must be specified'}"
: "${ALPAKA_CI_CUDA_COMPILER?'ALPAKA_CI_CUDA_COMPILER must be specified'}"

if [[ "$(cat /etc/os-release)" == *"20.04"* ]]
then
Expand Down Expand Up @@ -157,7 +157,7 @@ else
export PATH=/usr/local/nvidia/bin:/usr/local/cuda/bin:${PATH}
export LD_LIBRARY_PATH=/usr/local/nvidia/lib:/usr/local/nvidia/lib64:$LD_LIBRARY_PATH

if [ "${CMAKE_CUDA_COMPILER}" == "clang++" ]
if [ "${ALPAKA_CI_CUDA_COMPILER}" == "clang++" ]
then
travis_retry sudo apt-get -y --quiet --allow-unauthenticated --no-install-recommends install g++-multilib
fi
Expand All @@ -180,3 +180,14 @@ else
./cuda_installer.exe -s "nvcc_${ALPAKA_CI_CUDA_VERSION}" "curand_dev_${ALPAKA_CI_CUDA_VERSION}" "cudart_${ALPAKA_CI_CUDA_VERSION}" "thrust_${ALPAKA_CI_CUDA_VERSION}" "visual_studio_integration_${ALPAKA_CI_CUDA_VERSION}"
fi
fi

if [ "${ALPAKA_CI_CUDA_COMPILER}" == "nvcc" ]
then
export CMAKE_CUDA_COMPILER=$(which nvcc)
elif [ "${ALPAKA_CI_CUDA_COMPILER}" == "clang++" ]
then
export CMAKE_CUDA_COMPILER=$(which clang++-${ALPAKA_CI_CLANG_VER})
else
echo_red "unknown ALPAKA_CI_CUDA_COMPILER: ${ALPAKA_CI_CUDA_COMPILER}"
exit 1
fi
17 changes: 12 additions & 5 deletions script/install_gcc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ echo_green "<SCRIPT: install_gcc>"

: "${ALPAKA_CI_GCC_VER?'ALPAKA_CI_GCC_VER must be specified'}"
: "${ALPAKA_CI_SANITIZERS?'ALPAKA_CI_SANITIZERS must be specified'}"
: "${CXX?'CXX must be specified'}"

if agc-manager -e gcc@${ALPAKA_CI_GCC_VER}
then
Expand All @@ -26,12 +25,20 @@ else
travis_retry sudo apt-get -y --quiet --allow-unauthenticated --no-install-recommends install g++-"${ALPAKA_CI_GCC_VER}"
fi

sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-"${ALPAKA_CI_GCC_VER}" 50
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-"${ALPAKA_CI_GCC_VER}" 50
which g++-${ALPAKA_CI_GCC_VER}
export CMAKE_CXX_COMPILER=$(which g++-${ALPAKA_CI_GCC_VER})

# the g++ executalbe is required for compiling boost
# if it does not exist, create symbolic link to the install g++-${ALPAKA_CI_GCC_VER}
if ! command -v g++ >/dev/null; then
echo_yellow "No g++ executable found."
ln -s $(which g++-${ALPAKA_CI_GCC_VER}) $(dirname $(which g++-${ALPAKA_CI_GCC_VER}))/g++
fi

if [[ "${ALPAKA_CI_SANITIZERS}" == *"TSan"* ]]
then
travis_retry sudo apt-get -y --quiet --allow-unauthenticated --no-install-recommends install libtsan0
fi

which "${CXX}"
${CXX} -v
which "${CMAKE_CXX_COMPILER}"
${CMAKE_CXX_COMPILER} -v
3 changes: 3 additions & 0 deletions script/install_hip.sh
Original file line number Diff line number Diff line change
Expand Up @@ -101,3 +101,6 @@ hipconfig
rocm-smi
# print newline as previous command does not do this
echo

# use the clang++ of the HIP SDK as C++ compiler
export CMAKE_CXX_COMPILER=$(which clang++)
12 changes: 5 additions & 7 deletions script/install_oneapi.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ source ./script/setup_utilities.sh

echo_green "<SCRIPT: install_oneapi>"

: "${CXX?'CXX must be specified'}"


if agc-manager -e oneapi
then
echo_green "<USE: preinstalled OneAPI ${ALPAKA_CI_ONEAPI_VERSION}>"
Expand Down Expand Up @@ -55,10 +52,11 @@ else
travis_retry sudo apt update
travis_retry sudo apt install -y --no-install-recommends g++-11
fi

# path depends on the SDK version
export CMAKE_CXX_COMPILER=$(which icpx)
fi

which "${CXX}"
${CXX} --version
which "${CC}"
${CC} --version
which "${CMAKE_CXX_COMPILER}"
${CMAKE_CXX_COMPILER} --version
sycl-ls
25 changes: 9 additions & 16 deletions script/job_generator/generate_job_yaml.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,22 +296,19 @@ def job_variables(job: Dict[str, Tuple[str, str]]) -> Dict[str, str]:
append_backend_variables(variables, job)

if job[DEVICE_COMPILER][NAME] == GCC:
variables["CC"] = "gcc"
variables["CXX"] = "g++"
variables["ALPAKA_CI_CXX"] = "g++"
variables["ALPAKA_CI_GCC_VER"] = job[DEVICE_COMPILER][VERSION]
if ALPAKA_ACC_CPU_B_TBB_T_SEQ_ENABLE in job and job[ALPAKA_ACC_CPU_B_TBB_T_SEQ_ENABLE][VERSION] == ON_VER:
variables["ALPAKA_CI_TBB_VERSION"] = "2021.10.0"

if job[DEVICE_COMPILER][NAME] == CLANG:
variables["CC"] = "clang"
variables["CXX"] = "clang++"
variables["ALPAKA_CI_CXX"] = "clang++"
variables["ALPAKA_CI_CLANG_VER"] = job[DEVICE_COMPILER][VERSION]
if ALPAKA_ACC_CPU_B_TBB_T_SEQ_ENABLE in job and job[ALPAKA_ACC_CPU_B_TBB_T_SEQ_ENABLE][VERSION] == ON_VER:
variables["ALPAKA_CI_TBB_VERSION"] = "2021.10.0"

if job[DEVICE_COMPILER][NAME] == HIPCC:
variables["CC"] = "clang"
variables["CXX"] = "clang++"
variables["ALPAKA_CI_CXX"] = "clang++"
variables["CMAKE_HIP_COMPILER"] = "clang++"
variables["CMAKE_HIP_ARCHITECTURES"] = "${CI_GPU_ARCH}"
# TODO(SimeonEhrig) check, if we can remove this variable:
Expand Down Expand Up @@ -347,33 +344,29 @@ def job_variables(job: Dict[str, Tuple[str, str]]) -> Dict[str, str]:

if job[DEVICE_COMPILER][NAME] == NVCC:
# general configuration, if nvcc is the CUDA compiler
variables["CMAKE_CUDA_COMPILER"] = "nvcc"
variables["ALPAKA_CI_CUDA_COMPILER"] = "nvcc"

# configuration, if GCC is the CUDA host compiler
if job[HOST_COMPILER][NAME] == GCC:
variables["CC"] = "gcc"
variables["CXX"] = "g++"
variables["ALPAKA_CI_CXX"] = "g++"
variables["ALPAKA_CI_GCC_VER"] = job[HOST_COMPILER][VERSION]
# configuration, if Clang is the CUDA host compiler
elif job[HOST_COMPILER][NAME] == CLANG:
variables["CC"] = "clang"
variables["CXX"] = "clang++"
variables["ALPAKA_CI_CXX"] = "clang++"
variables["ALPAKA_CI_CLANG_VER"] = job[HOST_COMPILER][VERSION]
else:
raise RuntimeError(
"generate_job_yaml.job_variables(): unknown CUDA host compiler: " f"{job[HOST_COMPILER][NAME]}"
)

if job[DEVICE_COMPILER][NAME] == CLANG_CUDA:
variables["CC"] = "clang"
variables["CXX"] = "clang++"
variables["ALPAKA_CI_CXX"] = "clang++"
variables["ALPAKA_CI_CLANG_VER"] = job[DEVICE_COMPILER][VERSION]
variables["CMAKE_CUDA_COMPILER"] = "clang++"
variables["ALPAKA_CI_CUDA_COMPILER"] = "clang++"

# oneAPI configuration
if job[DEVICE_COMPILER][NAME] == ICPX:
variables["CC"] = "icx"
variables["CXX"] = "icpx"
variables["ALPAKA_CI_CXX"] = "icpx"
if job[DEVICE_COMPILER][VERSION] == "2024.0":
variables["ALPAKA_CI_CLANG_VER"] = "17"
variables["ALPAKA_CI_STDLIB"] = "libstdc++"
Expand Down
Loading

0 comments on commit 00c51bb

Please sign in to comment.