views:

238

answers:

0

I was trying to bind a host memory that was mapped for zero-copy to a texture, but it looks like it isn't possible.

Here is a code sample:

float* a;
float* d_a;
cudaSetDeviceFlags(cudaDeviceMapHost);
cudaHostAlloc( (void **)&a, bytes, cudaHostAllocMapped);
cudaHostGetDevicePointer((void **)&d_a,  (void *)a, 0);

texture<float, 2, cudaReadModeElementType> tex;
cudaBindTexture2D( 0, &tex, d_a, &channelDesc, width, height, pitch);

Is it recommended that you used pinned memory and just copy it over to device memory that is bind to texture?