CUDA beginner asking for help

Hi all,

I just started learning CUDA and I have a very basic program.

#include <stdio.h>
#include <stdlib.h>
#include <cuda.h>

__global__ void testCUDA(int *a, int *b){
	a[0] += b[0];
}

int main(){
	printf("hello world!\n");

	return 0;
}

I hide some parts.

A warning is pointed at the start of “global”: this declaration has no storage class or type specifier.
An error is pointed at the start of “void testCUDA()”: expected a “;”.

I have cuda.h included and double underscore on both sides of “global”.

Can anyone help me out here?

Thanks so much!

Tim

CUDA programs need to be compiled by nvcc, not your system’s C or C++ compiler.

Once you do that, you can also leave out the cuda.h include.

Hi Tera,

Thanks for your reply.
I’m compiling my code on GPU cluster from a provider and the compiler they provide is icc.
They don’t have much tutorial on this and their only example is CUBLAS.
I tried to modify the way of compiling CUBLAS and made sure it finds cuda.h, and this is how I got the above problems.

Perhaps this gives an idea about icc:
https://devtalk.nvidia.com/default/topic/454808/cuda-programming-and-performance/intel-compiler-support-for-front-end-cuda-compilation/

Regardless, the CUDA toolkit needs to be on the test system you are running… and you need to call nvcc, which is NVIDIA’s compiler… example:

http://code.google.com/p/stanford-cs193g-sp2010/wiki/TutorialHelloWorld