Install DPC++ to simultaneously use all GPU backends (CUDA, OpenCL, and SYCL) for NVIDIA GPUs on Linux systems - SC-SGS/PLSSVM GitHub Wiki

(See also: https://intel.github.io/llvm-docs/GetStartedGuide.html#build-dpc-toolchain-with-support-for-nvidia-cuda)

Specify and create DPC++ install directory

export DPCPP_HOME=~/dpcpp_install_dir
mkdir -p $DPCPP_HOME
cd $DPCPP_HOME

Clone Intel's LLVM fork SYCL branch

git clone [email protected]:intel/llvm.git -b sycl
cd llvm

Optional: check out our most tested DPC++ commit

git checkout sycl-nightly/20221102

Configure DPC++:

python buildbot/configure.py --cuda --llvm-external-projects="clang-tools-extra,compiler-rt,openmp" --cmake-opt="-DENABLE_LIBOMPTARGET=OFF"

Build DPC++ with OpenMP support

python buildbot/compile.py
cmake --build build -- omp
cmake --build build -- install

Set necessary environment variabes

export PATH=$DPCPP_HOME/llvm/build/bin:$PATH
export LIBRARY_PATH=$DPCPP_HOME/llvm/build/lib:$LIBRARY_PATH
export LD_LIBRARY_PATH=$DPCPP_HOME/llvm/build/lib:$LD_LIBRARY_PATH
export CPLUS_INCLUDE_PATH=$DPCPP_HOME/llvm/build/projects/openmp/runtime/src:$DPCPP_HOME/llvm/build/install/include:$DPCPP_HOME/llvm/build/install/include/sycl:$CPLUS_INCLUDE_PATH

After that, running

cmake -DPLSSVM_TARGET_PLATFORMS="nvidia:sm_80" -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_BUILD_TYPE=Release -DPLSSVM_ENABLE_LTO=OFF -DOpenCL_INCLUDE_DIR=$DPCPP_HOME/llvm/build/include/sycl -DOpenCL_LIBRARY=$DPCPP_HOME/llvm/build/lib ..

on the PLSSVM library should result in a message like (at the end of the CMake output):

-- Enabled backends with respective targets:
--  - CUDA: nvidia (sm_80)
--  - OpenCL: nvidia
--  - SYCL (dpcpp*): nvidia (sm_80)

last tested on 2023-02-27 with clang version 16.0.0 (https://github.com/intel/llvm.git 19e99417be98df70dd7bc20bba98691239e85057)