[cfe-dev] Compiling simple axpy CUDA

gry666 via cfe-dev cfe-dev at lists.llvm.org
Mon Dec 14 09:57:33 PST 2015


Hi all,

It's my first trial with clang. so if my question is so simple, i'm sorry
first of all.

Basically, I'm trying to compile simple axpy cuda code by using clang, I'm
following this example http://llvm.org/docs/CompileCudaWithLLVM.html.
However I'm getting this errors

$ clang++ axpy.cu -o axpy-clang -I/usr/local/cuda/samples/common/inc
In file included from axpy.cu:1:
In file included from /usr/local/cuda/samples/common/inc/helper_cuda.h:24:
/usr/local/cuda/samples/common/inc/helper_string.h:18:10: fatal error:
'fstream' file not found
#include <fstream>
         ^
1 error generated.
axpy.cu:5:1: error: unknown type name '__global__'
__global__ void axpy(float a, float* x, float* y) {
^
axpy.cu:5:12: error: expected unqualified-id
__global__ void axpy(float a, float* x, float* y) {
           ^
axpy.cu:19:19: error: use of undeclared identifier 'cudaMalloc'
  checkCudaErrors(cudaMalloc(&device_x, kDataLen * sizeof(float)));
                  ^
axpy.cu:20:19: error: use of undeclared identifier 'cudaMalloc'
  checkCudaErrors(cudaMalloc(&device_y, kDataLen * sizeof(float)));
                  ^
axpy.cu:22:30: error: use of undeclared identifier 'cudaMemcpyHostToDevice'
                             cudaMemcpyHostToDevice));
                             ^
axpy.cu:25:3: error: use of undeclared identifier 'axpy'
  axpy<<<1, kDataLen>>>(a, device_x, device_y);
  ^
axpy.cu:28:19: error: use of undeclared identifier 'cudaDeviceSynchronize'
  checkCudaErrors(cudaDeviceSynchronize());
                  ^
axpy.cu:30:30: error: use of undeclared identifier 'cudaMemcpyDeviceToHost'
                             cudaMemcpyDeviceToHost));
                             ^
axpy.cu:37:19: error: use of undeclared identifier 'cudaDeviceReset'
  checkCudaErrors(cudaDeviceReset());
                  ^
9 errors generated.

What am I supposed to do?

Regards
-- 
sulomen
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20151214/2b1ebe2b/attachment-0001.html>


More information about the cfe-dev mailing list