compiling cuda code

I am a new CUDA user. I am trying to compile this program, but I am receiving the following errors: error: variable “i” is not a template error: expected a “>” error: expected a “;”

3 errors detected in the compilation of “/tmp/tmpxft_000037bf_00000000-4_test3.cpp1.ii”.

this is line 31 for (int i=0, i<SIZE; i++)

Can anyone please help? Thank you.

global void vecAdd(float* A, float* B, float* C)


int i = threadIdx.x;



C[i]=A[i] + B[i];





#define SIZE 10

int main()


int N=SIZE;

float A, B, C;

float *devPtrA;

float *devPtrB;

float *devPtrC;

int memsize=SIZE * sizeof(float);

cudaMalloc((void**)&devPtrA, memsize);

cudaMalloc((void**)&devPtrB, memsize);

cudaMalloc((void**)&devPtrC, memsize);

cudaMemcpy(devPtrA, A, memsize, cudaMemcpyHostToDevice);

cudaMemcpy(devPtrB, B, memsize, cudaMemcpyHostToDevice);

//global functions are called: Func<<< Dg, Db, Ns >>>(parameter);

vecAdd<<<1, N>>>(devPtrA, devPtrB, devPtrC);

cudaMemcpy(C, devPtrC, memsize, cudaMemcpyHostToDevice);

for (int i=0, i<SIZE; i++)







for (int i=0, i<SIZE; i++)


should read


for (int i=0; i<SIZE; i++)


You need a ; after initializing the loop counter.