Bind texture with pinned mapped memory in CUDA

Posted by sjchoi on Stack Overflow See other posts from Stack Overflow or by sjchoi
Published on 2010-04-14T23:15:34Z Indexed on 2010/04/14 23:23 UTC
Read the original article Hit count: 254

Filed under:

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?

© Stack Overflow or respective owner

Related posts about cuda