Hey all,
Say I have the following piece of code…
INSIDE KERNEL :
[codebox]global void d_kernel(float *globalMem, int numBlocks, int i)
{
//Compute tempx, tempy
if(i==0)
globalMem[tempx+(tempy*X_SIZE)] = 2.5;
else if(i==1)
globalMem[tempx+(tempy*X_SIZE)] = tex2D(tex00,tempx,tempy);
}
[/codebox]
INSIDE MAIN :
[codebox]
texture<float, 2, cudaReadModeElementType> tex00;
float *globalMem,*globalMem1;
cudaMallocPitch((void**) &globalMem, &sizeGM, sizeof(float) * X_SIZE,Y_SIZE);
cudaMallocPitch((void**) &globalMem1, &sizeGM, sizeof(float) * X_SIZE,Y_SIZE);
d_kernel<<<dim3(numBlocks,numBlocks),dim3(BLOCK_DIM,BLOCK_DIM,1),0,0>>>(globalMem,numBlocks,0);
// I compute some value for globalMem in the above kernel. Now it is used as a texture for the next “globalMem2” - for faster accesses…
cudaBindTexture(0,tex00,globalMem5,channelDesc,sizeof(float)
X_SIZEY_SIZE);
d_kernel<<<dim3(numBlocks,numBlocks),dim3(BLOCK_DIM,BLOCK_DIM,1),0,0>>>(globalMem2,numBlocks,1);
int z =0;
CUDA_SAFE_CALL(cudaMemcpy2DAsync(&returned[X_SIZEY_SIZEz], X_SIZEsizeof(float), globalMem2, X_SIZEsizeof(float), X_SIZE*sizeof(float),Y_SIZE, cudaMemcpyDeviceToHost,0));
[/codebox]
Shouldn’t now on checking out “returned”, I have the value 2.5 stored in them? It really doesn’t work that way. So I conclude that the global memory gets flushed after every kernel execution. Is this true? Any way to do this?
Thanks,
Vandhan