dear all,
i am experiencing a quite weird behavior with memory in my program.
Here is the part of code of interest:
cudaMallocPitch((void**)&d_D,&pitch,sizeof(float)imageW,imageHimageD);
cudaMallocPitch((void**)&d_phi,&pitch,sizeof(float)imageW,imageHimageD);
cudaMallocPitch((void**)&d_phi1,&pitch,sizeof(float)imageW,imageHimageD);
cudaMemcpy2D(d_D,pitch,D,sizeof(float)*imageW,sizeof(float)*imageW,imageH*imageD,cudaMemcpyHostToDevice);
cudaMemcpy2D(d_phi1,pitch,phi,sizeof(float)*imageW,sizeof(float)imageW,imageHimageD,cudaMemcpyHostToDevice);
dim3 dimGrid(((imageW - 1)/BLOCKDIM_X) + 1,((imageH - 1)/BLOCKDIM_Y) + 1);
dim3 dimBlock(BLOCKDIM_X,BLOCKDIM_Y,BLOCKDIM_Z);
size_t free, total;
cudaMemGetInfo(&free,&total);
printf(“Free: [%f] - Occupied: [%f] \n”,(float)free/1000000000,(float)total/1000000000 - (float)free/1000000000);
for (int its=0; its<=ITERATIONS; its++) {
evolvephi<<<dimGrid,dimBlock>>>(d_phi,d_phi1,d_D,imageW,imageH,imageD,alpha,pitch);
getLastCudaError(“Kernel Launch Failed”);
cudaMemcpy2D(d_phi1,pitch,d_phi,sizeof(float)*imageW,sizeof(float)imageW,imageHimageD,cudaMemcpyDeviceToDevice);
cudaMemGetInfo(&free,&total);
printf(“Iteration Number: [%d] \n”,its);
printf(“Free: [%f] - Occupied: [%f] \n”,(float)free/1000000000,(float)total/1000000000 - (float)free/1000000000);
}
cudaMemcpy2D(phi,pitch,d_phi1,sizeof(float)*imageW,sizeof(float)imageW,imageHimageD,cudaMemcpyDeviceToHost);
cudaMemGetInfo(&free,&total);
printf(“Free: [%f] - Occupied: [%f] \n”,(float)free/1000000000,(float)total/1000000000 - (float)free/1000000000);
cudaFree(d_phi);
cudaFree(d_phi1);
cudaFree(d_D);
cudaMemGetInfo(&free,&total);
printf(“Free: [%f] - Occupied: [%f] \n”,(float)free/1000000000,(float)total/1000000000 - (float)free/1000000000);
int err = cudaDeviceReset();
if (err == 1) printf(“Device reset succesful!!! \n”);
if (err == 0) printf(“Device reset UNsuccesful!!! \n”);
And here what i get in my terminal, for the first ten iterations:
Free: [1.882714] - Occupied: [0.264049]
Iteration Number: [0]
Free: [1.882714] - Occupied: [0.264049]
Iteration Number: [1]
Free: [1.882714] - Occupied: [0.264049]
Iteration Number: [2]
Free: [1.882714] - Occupied: [0.264049]
Iteration Number: [3]
Free: [1.882714] - Occupied: [0.264049]
Iteration Number: [4]
Free: [1.882714] - Occupied: [0.264049]
Iteration Number: [5]
Free: [1.882714] - Occupied: [0.264049]
Iteration Number: [6]
Free: [1.882714] - Occupied: [0.264049]
Iteration Number: [7]
Free: [1.882714] - Occupied: [0.264049]
Iteration Number: [8]
Free: [1.882714] - Occupied: [0.264049]
Iteration Number: [9]
Free: [1.882714] - Occupied: [0.264049]
Iteration Number: [10]
Free: [1.882714] - Occupied: [0.264049]
Free: [0.000000] - Occupied: [0.000000]
Free: [0.000000] - Occupied: [0.000000]
Device reset UNsuccesful!!!
thanks all
Bruno