Building problems

Open discussion for MAGMA

Building problems

Postby alayanoleh » Fri Jan 20, 2012 7:54 am

Dear users,

I am writing a code in CUDA and I needed to use the magma_cgesv_gpu function. Without the magma function, it compiles so far using some CUBLAS functions and kernels.

So I started to port my code to the testing_cgesv_gpu example, in order to use this function.

When compiling, it gives me the following error:

~/magma_1.1.0/testing$ make
gcc -O3 -DADD_ -DGPUSHMEM=130 -I/usr/local/cuda/include -I../include -I../quark/include -c testing_cgesv_gpu.cpp -o testing_cgesv_gpu.o
testing_cgesv_gpu.cpp: In function ‘void CalcBM(double*, double*, double*, double*, double*, double*, double*, double*, int, int)’:
testing_cgesv_gpu.cpp:128: error: ‘blockIdx’ was not declared in this scope
testing_cgesv_gpu.cpp:128: error: ‘blockDim’ was not declared in this scope
testing_cgesv_gpu.cpp:128: error: ‘threadIdx’ was not declared in this scope

And similiar errors to other kernels.

Also it doesn't recognize CUDA kernel calls:

testing_cgesv_gpu.cpp:303: error: expected primary-expression before ‘<’ token
testing_cgesv_gpu.cpp:303: error: expected primary-expression before ‘>’ token
testing_cgesv_gpu.cpp:351: error: expected primary-expression before ‘<’ token
testing_cgesv_gpu.cpp:351: error: expected primary-expression before ‘>’ token

Can anyone help me with that?

Thank you in advance!
alayanoleh
 
Posts: 4
Joined: Wed Dec 21, 2011 1:35 pm

Re: Building problems

Postby mgates3 » Fri Jan 20, 2012 6:42 pm

Those variables (blockIdx, etc.) are CUDA specific, as is the kernel launch <<< >>> notation. In order to compile CUDA specific code, you need to be use the CUDA nvcc compiler, instead of gcc. CUDA source code files should have an extension .cu instead of .c or .cpp, to differentiate them.

The testing examples in MAGMA don't have any CUDA specific code, hence they can use the .cpp extension and be compiled with gcc. For example, magma_cgesv_gpu is a C function, usable from any C code, which calls magmablas and cublas functions, which in turn launch CUDA kernels.

-mark
mgates3
 
Posts: 438
Joined: Fri Jan 06, 2012 2:13 pm

Re: Building problems

Postby alayanoleh » Sun Jan 22, 2012 9:46 am

Thank you Mark.

I solved my problem by changing the Makefile of the testing folder. In order to compile a myprog.cu source code, I just added to the Makefile

myprog: myprog.o
$(CC) $(OPTS) $(LDOPTS) $(NOMAIN) $< $(OBJ) -o $@ lin/liblapacktest.a -L../lib \
-lcuda -lmagma -lmagmablas -lmagma $(LIBDIR) $(LIB)

myprog.o: myprog.cu
$(NVCC) $(OPTS) $(INC) -c $< -o $@

and to compile

$ make myprog

This might be useful for users having mixed CUDA and MAGMA code.
alayanoleh
 
Posts: 4
Joined: Wed Dec 21, 2011 1:35 pm


Return to User discussion

Who is online

Users browsing this forum: No registered users and 2 guests