c - Cuda code #define error, expected a ")" -


in following code, if bring #define n 65536 above #if fsize, following error:

#if fsize==1 __global__ void compute_sum1(float *a, float *b, float *c, int n) { #define n 65536         int majoridx = blockidx.x;         int subidx = threadidx.x;          int idx=majoridx*32+subidx ;          float sum=0;          int t=4*idx;         if(t<n)         {                 c[t]= a[t]+b[t];                 c[t+1]= a[t+1]+b[t+1];                 c[t+2]= a[t+2]+b[t+2];                 c[t+3]= a[t+3]+b[t+3];         }         return; } #elif fsize==2 __global__ void compute_sum2(float2 *a, float2 *b, float2 *c, int n) #define n 65536 {         int majoridx = blockidx.x;         int subidx = threadidx.x;          int idx=majoridx*32+subidx ;          float sum=0;          int t=2*idx;         if(t<n)         {                 c[t].x= a[t].x+b[t].x;                 c[t].y= a[t].y+b[t].y;                 c[t+1].x= a[t+1].x+b[t+1].x;                 c[t+1].y= a[t+1].y+b[t+1].y;         }         return ; } 

float1vsfloat2.cu(10): error: expected ")"

this problem little annoying , really know why happening. have feeling i'm overlooking silly. btw, code section @ top of file. not #include before it. appreciate possible explanations.

the preprocessor changes line:

__global__ void compute_sum1(float *a, float *b, float *c, int n) 

to

__global__ void compute_sum1(float *a, float *b, float *c, int 65536) 

which isn't valid cuda code.


Comments

Popular posts from this blog

javascript - Enclosure Memory Copies -

php - Replacing tags in braces, even nested tags, with regex -