Skip to content

Unable to compile SYCL for CUDA #1340

@pvelesko

Description

@pvelesko

I am trying to compile SYCL for CUDA and it says to direct issues here.

System:

[pvelesko@jlselogin2 build]$ uname -a
Linux jlselogin2 3.10.0-957.10.1.el7.x86_64 #1 SMP Thu Feb 7 07:12:53 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
[pvelesko@jlselogin2 build]$ ls /usr/include/c++/
4.8.2  4.8.5
[pvelesko@jlselogin2 build]$

I followed these instructions

add -DCMAKE_C_COMPILER=gcc (and g++) otherwise it will default to system gcc which is 4.8.0 and too old to meet requirements.
This is what my CMAKE line looks:

cd $SYCL_HOME
git clone https://github.com/codeplaysoftware/sycl-for-cuda -b sycl
mv sycl-for-cuda llvm
mkdir $SYCL_HOME/build
cd $SYCL_HOME/build

module load gcc/8.2.0
cmake -DCMAKE_BUILD_TYPE=Release -DLLVM_TARGETS_TO_BUILD="X86" \
-DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ \

-DLLVM_EXTERNAL_PROJECTS="llvm-spirv;sycl" \
-DLLVM_ENABLE_PROJECTS="clang;llvm-spirv;sycl" \
-DLLVM_EXTERNAL_SYCL_SOURCE_DIR=$SYCL_HOME/llvm/sycl \
-DLLVM_EXTERNAL_LLVM_SPIRV_SOURCE_DIR=$SYCL_HOME/llvm/llvm-spirv \
-DCUDA_TOOLKIT_ROOT_DIR=/soft/compilers/cuda/cuda-10.1.243 \
-DLLVM_ENABLE_PROJECTS="clang;llvm-spirv;sycl;libclc" \
-DSYCL_BUILD_PI_CUDA=ON \
-DLLVM_TARGETS_TO_BUILD="X86;NVPTX" \
-DLIBCLC_TARGETS_TO_BUILD="nvptx64--;nvptx64--nvidiacl" \
$SYCL_HOME/llvm/llvm

Running make:

$make -j`nproc` sycl-toolchain
<...>
[ 21%] Built target ocl-headers
make[1]: *** [tools/sycl/CMakeFiles/sycl-toolchain.dir/rule] Error 2
make: *** [sycl-toolchain] Error 2
$make -j 2 sycl-toolchain
<...>
[ 21%] Copying SYCL headers ...
make[3]: *** No rule to make target `CUDA_CUDA_LIBRARY-NOTFOUND', needed by `lib/libpi_cuda.so'.  Stop.
make[2]: *** [tools/sycl/plugins/cuda/CMakeFiles/pi_cuda.dir/all] Error 2
make[2]: *** Waiting for unfinished jobs....
[ 21%] Built target sycl-headers
make[1]: *** [tools/sycl/CMakeFiles/sycl-toolchain.dir/rule] Error 2
make: *** [sycl-toolchain] Error 2
$make sycl-toolchain

the last command ends up building successfully with the exception of that one CUDA error. I checked CMakeCache.txt and there are a couple of suspicious lines:

       591 //"cuda" library (older versions only).
       592 CUDA_CUDA_LIBRARY:FILEPATH=CUDA_CUDA_LIBRARY-NOTFOUND

       629 //Path to a file.
       630 CUDA_SDK_ROOT_DIR:PATH=CUDA_SDK_ROOT_DIR-NOTFOUND

but everything else CUDA related is found ok.

Then to use the compiler I made the following module (modified gcc/8.2.0 module):

       10 set gcc_path "/home/pvelesko/local/sycl_4_gpu/build_gcc9"
       11 set gcc_inc_cxx ${gcc_path}/include/c++/8.2.0
       12 #conflict gcc
       13 prepend-path {PATH} "${gcc_path}/bin"
       14 prepend-path {MANPATH} "${gcc_path}/share/man"
       15 prepend-path {LD_LIBRARY_PATH} "${gcc_path}/lib64:${gcc_path}/lib"
       16 prepend-path {LIBRARY_PATH} "${gcc_path}/lib64:${gcc_path}/lib"
       17 prepend-path {CPATH} "${gcc_inc_cxx}"
       18 prepend-path {CPATH} "${gcc_inc_cxx}/x86_64-pc-linux-gnu/"
       19 prepend-path {C_INCLUDE_PATH} "${gcc_path}/include"
       20 prepend-path {CPLUS_INCLUDE_PATH} "${gcc_inc_cxx}"

Then my main.cpp file:

#include <CL/sycl.hpp>
int main() {return 0;}

and compile line:
clang++ --gcc-toolchain=/soft/compilers/gcc/8.2.0/linux-rhel7-x86_64 -std=c++14 -fsycl ./main.cpp -o intel -D__STRICT_ANSI__

Produces the following error (with more, similar errors to follow):

[pvelesko@jlselogin2 template]$ make
clang++ --gcc-toolchain=/soft/compilers/gcc/8.2.0/linux-rhel7-x86_64 -std=c++14 -fsycl ./main.cpp -o intel  -D__STRICT_ANSI__
In file included from ./main.cpp:1:
In file included from /home/pvelesko/local/sycl_4_gpu/build_gcc9/lib/clang/11.0.0/include/CL/sycl.hpp:11:
In file included from /home/pvelesko/local/sycl_4_gpu/build_gcc9/lib/clang/11.0.0/include/CL/sycl/accessor.hpp:13:
In file included from /home/pvelesko/local/sycl_4_gpu/build_gcc9/lib/clang/11.0.0/include/CL/sycl/buffer.hpp:10:
In file included from /home/pvelesko/local/sycl_4_gpu/build_gcc9/lib/clang/11.0.0/include/CL/sycl/detail/buffer_impl.hpp:17:
In file included from /home/pvelesko/local/sycl_4_gpu/build_gcc9/lib/clang/11.0.0/include/CL/sycl/handler.hpp:15:
In file included from /home/pvelesko/local/sycl_4_gpu/build_gcc9/lib/clang/11.0.0/include/CL/sycl/detail/cg.hpp:20:
In file included from /home/pvelesko/local/sycl_4_gpu/build_gcc9/lib/clang/11.0.0/include/CL/sycl/nd_item.hpp:17:
In file included from /home/pvelesko/local/sycl_4_gpu/build_gcc9/lib/clang/11.0.0/include/CL/sycl/intel/sub_group.hpp:21:
In file included from /home/pvelesko/local/sycl_4_gpu/build_gcc9/lib/clang/11.0.0/include/CL/sycl/types.hpp:59:
In file included from /soft/compilers/gcc/9.2.0/linux-rhel7-x86_64/include/c++/9.2.0/cfenv:41:
/soft/compilers/gcc/9.2.0/linux-rhel7-x86_64/include/c++/9.2.0/fenv.h:58:11: error: no member named 'fenv_t' in the global namespace; did you mean 'dev_t'?
  using ::fenv_t;
        ~~^
/usr/include/sys/types.h:60:17: note: 'dev_t' declared here
typedef __dev_t dev_t;

Help would be appreciated.
Thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    cudaCUDA back-end

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions