I need to perform a 2D texture fetch in CUDA, i am able to do so only in emu mode.
When trying to run on GPU, it looks like the Memcopy function is failing, as I am getting only Zero Values on copy-back
I am working with a 2D array of float2’s
My code is below:
//Declared Globally texture<float2, 2, cudaReadModeElementType> tex; ... ... //Host-Side Code cudaChannelFormatDesc channelDesc = cudaCreateChannelDesc <float2>(); cudaArray *Ad; float2 *Bd; int size=h*w*sizeof(float2); CUDA_SAFE_CALL( cudaMallocArray(&Ad,&channelDesc,w,h)); CUDA_SAFE_CALL( cudaMemcpyToArray( Ad,0,0, A, size, cudaMemcpyHostToDevice)); tex.addressMode = cudaAddressModeWrap; tex.addressMode = cudaAddressModeWrap; tex.filterMode = cudaFilterModePoint; tex.channelDesc = channelDesc; tex.normalized = false; CUDA_SAFE_CALL( cudaBindTextureToArray(tex,Ad)); ... ... //Launch Kernel - using tex2d to fetch inside kernel, //write result back to B (in global memory) ... ... CUDA_SAFE_CALL(cudaMemcpy(B,Bd,size,cudaMemcpyDeviceToHost)); ... ...
The texture fetches are working in emu mode but not on the GPU.
I even tried a simple copy to the cudaArray and back to host, but even that doesn’t work on the GPU, it works fine in emu mode.
Can anyone throw some light on why the cudaMemcopyArray might be failing or if its some other issue?