Hello everyone, I have a problem with the command cudaMemcpy,I have a structure data type Scene (hScene) that must be copied into dScene on my device
the data structure type (scene) is defined:
[codebox]struct _scene
{
double* vertex;
double* normal;
double* texture;
int* face;
int* faceIndex;
int vertexSize;
int normalSize;
int textureSize;
int faceSize;
int faceIndexSize;
int vertexNum;
int normalNum;
int textureNum;
int faceNum;
};
typedef struct _scene scene;[/codebox]
This is the function code AllocaScena:
[codebox]
host void AllocaScena(scene *dScene, scene *hScene)
{
scene tempScene;
cudaMalloc((void**) &(tempScene.vertex), hScene->vertexSize * sizeof(double));
cudaMalloc((void**) &(tempScene.normal), hScene->normalSize * sizeof(double));
cudaMalloc((void**) &(tempScene.texture), hScene->textureSize * sizeof(double));
cudaMalloc((void**) &(tempScene.face), hScene->faceSize * sizeof(int));
cudaMalloc((void**) &(tempScene.faceIndex), hScene->faceIndexSize * sizeof(int));
cudaMemcpy(hScene->vertex, &(tempScene.vertex), hScene->vertexSize * sizeof(double),cudaMemcpyHostToDevice);
cudaMemcpy(hScene->normal, &(tempScene.normal), hScene->normalSize * sizeof(double),cudaMemcpyHostToDevice);
cudaMemcpy(hScene->texture, &(tempScene.texture), hScene->textureSize * sizeof(double),cudaMemcpyHostToDevice);
cudaMemcpy(hScene->face, &(tempScene.face), hScene->faceSize * sizeof(int),cudaMemcpyHostToDevice);
cudaMemcpy(hScene->faceIndex, &(tempScene.faceIndex), hScene->faceIndexSize * sizeof(int),cudaMemcpyHostToDevice);
tempScene.faceNum = hScene->faceNum;
if (dScene==NULL){
cudaMalloc((void**) &dScene, sizeof(scene));
cudaMemcpy(&tempScene, &dScene, sizeof(scene),cudaMemcpyHostToDevice);
}
}
[/codebox]
This is one piece of kernel’s code:
[codebox]
global void DrawScreen(float *a_d, int w, int h, int ch,float3 eye, float3 xdir, float3 ydir, float3 LLdir, scene *dScene)
{
…
<b>Error-></b> for (int i=0; i<dScene->faceNum; i++){
…
}
}
[/codebox]
problem occurs when I read parameters into the dscene, visual studio gives me the following error:
0xC0000005: Access violation reading location 0x00000034
I’m working on Windows XP with Visual Studio 2008 and Cuda_SDK 2.3
These are the settings of Visual Studio 2008:
please help me !!!