Compiling CUDA with clang on Windows

Dear all,

In the official document, it is mentioned that CUDA compilation is supported on Windows as of 2017-01-05. I used msys2 to install clang 5.0.1. Then I installed cuda 8.0. However, I basically could not compile any code of cuda by the prescribed setting. I wounder if anyone can successfully compile cuda code by the clang on Windows. Any of your information is highly appreciated, and

best regards
Tsai

Hi, Tsai.

I've gotten simple clang builds to work with cuda on Windows. I didn't use
mingw, though.

Unfortunately your email does not have enough information to allow me to
assist you further than that.

-Justin

Dear all,

In the official document, it is mentioned that CUDA compilation is

supported on Windows as of 2017-01-05. I used msys2 to install clang 5.0.1.
Then I installed cuda 8.0. However, I basically could not compile any code
of cuda by the prescribed setting. I wounder if anyone can successfully
compile cuda code by the clang on Windows. Any of your information is
highly appreciated, and

Dear llvm friends and Justin:

I tried clang 7.0.1 from the pre-built binariy of windows (64bit) and cuda 8.0 to build axpy.cu in the website. I use the following command: clang++ axpy.cu -o axpy.exe --cuda-gpu-arch=sm_35 -L"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\lib\x64" -lcudart_static. The compiler indicated two types of bugs as “undefined FP_NAN, FP_INFINITE, FP_ZERO, FP_SUBNORMAL, & FP_NORMAL” and “conflicts of isnan, isfinite, & isinf”. I patched them by the attached files. Then, I can obtain axpy.exe correctly. However, the results are “y[0] = 0, y[1] = 0, y[2] = 0, y[3] = 0”, which are not correct. I will be very glad to have comments from you.

By the way, is it also possible to have a pre-built binary for msys2 (64bits) on windows? I suppose that it should be very similar to a linux system except reimp should be used to convert the cuda .lib files to the corresponding .a files. I have used the method to obtain libopencl.a, and it works perfectly well on my Nvidia GPU + msys2/mingw64/clang5 + opencl system as I tested all the examples from viennaCL.

best regard
Tsai

__clang_cuda_math_forward_declares.h (8.86 KB)

__clang_cuda_cmath.h (16.9 KB)

I can obtain axpy.exe correctly. However, the results are “y[0] = 0, y[1] = 0, y[2] = 0, y[3] = 0”, which are not correct. I will be very glad to have comments from you.

It probably is not launching the kernel successfully. You’ll need to add error checking and then figure out why you’re getting an error from CUDA.

By the way, is it also possible to have a pre-built binary for msys2 (64bits) on windows?

All of these things are community-driven, so if it’s not there already, you may be the best person to provide it. :slight_smile:

-Justin