Memory Access Problem

I am writing a code, but i find that it fails to compile even for the beginning part. The code looks like this:

[codebox]#include <stdio.h>

#include <stdlib.h>

#include “cutil_inline.h”

global void initial(float* u,int lengthx)

{

unsigned int thid=threadIdx.x+lengthx*blockIdx.x;

if(threadIdx.x<lengthx)

{

	u[thid]=1;

}

}

global void boundary(float* boundx0,float* boundx1,float* boundy0,float* boundy1,float* boundz0,float* boundz1,int lengthx,int lengthy,int lengthz)

{

unsigned int thidx=threadIdx.x+blockDim.x*blockIdx.x;

unsigned int thidy=threadIdx.y+blockDim.y*blockIdx.y;

if(thidx<lengthx&&thidy<lengthy)

{

	boundx0[thidx+thidy*lengthx]=0.1;

	boundx1[thidx+thidy*lengthx]=0.2;

	boundy0[thidx+thidy*lengthx]=0.3;

	boundy1[thidx+thidy*lengthx]=0.4;

	boundz0[thidx+thidy*lengthx]=0.5;

	boundz1[thidx+thidy*lengthx]=0.6;

}

}

int main(int argc, char* argv)

{

float*u,*boundx0,*boundx1,*boundy0,*boundy1,*boundz0,*boundz

1;

float*rhs,*a,*b,*c;

float alpha;

float*debug;

int lengthx=100,lengthy=100,lengthz=100;

int threads=128;

int blocks;

int slice;

int volume;

slice=threads*threads;

blocks=slice;

volume=slice*threads;

cudaMalloc((void**)&u,2097152*sizeof(float));

cudaMalloc((void**)&boundx0,slice*sizeof(float));

cudaMalloc((void**)&boundx1,slice*sizeof(float));

cudaMalloc((void**)&boundy0,slice*sizeof(float));

cudaMalloc((void**)&boundy1,slice*sizeof(float));

cudaMalloc((void**)&boundz0,slice*sizeof(float));

cudaMalloc((void**)&boundz1,slice*sizeof(float));

cudaMalloc((void**)&rhs,volume*sizeof(float));

cudaMalloc((void**)&a,threads*sizeof(float));

cudaMalloc((void**)&b,threads*sizeof(float));

cudaMalloc((void**)&c,threads*sizeof(float));

initial<<<blocks,threads>>>(u,lengthx);

cudaThreadSynchronize();

dim3 threads2D(16,16);

dim3 blocks2D(threads/16,threads/16);

boundary<<<blocks2D,threads2D>>>(boundx0,boundx1,boundy0,boundy1,boundz0,boundz1,lengthx,

lengthy,lengthz);

//Debug and Checking section

cudaMalloc((void**)&debug,volume*sizeof(float));

cudaMemcpy(debug,u,volume*sizeof(float),cudaMemcpyDeviceToHo

st);

FILE *fileid=fopen("output.txt","w");

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

{

	fprintf(fileid,"%f\n",debug[i]);

}  

}[/codebox]

Visual studio complains that expression for u cant be evaluated…

What mistakes have i done?

Ok i must be dreaming when i wrote the code… :">

I accidentally use cudaMalloc to allocate memory for the host…