Hello All,
I allocated one big chunk of memory using cudaMalloc() and I partioned/divided that into some parts…
When I bind one of the sub part of the memory by using cudaBindTexture() API, it is returning cudaErrorInvalidValue.
Below is the code…
[b]unsigned char* gpuMem=NULL;
cudaMalloc( (void**)&gpuMem, 10KB); // allocated 10 Kilo Bytes memory
texturetexHandle;
unsigned short int* partOfGpuMem = (unsigned short int*)(gpuMem+2KB); // 2 kilo bytes is the offset
cudaError error = cudaBindTexture( 0, texHandle, partOfGpuMem, sizeof(unsigned short int)*srcW ); // Here srcW is 800 [/b]
Here error is cudaErrorInvalidValue.
I searched for this on internet, I found the usgae of cudaBindTexture() link
[url=“http://developer.download.nvidia.com/compute/cuda/2_3/toolkit/docs/online/group__CUDART__TEXTURE_g8e565cd508f9cbbee2791346fd2f2706.html#g8e565cd508f9cbbee2791346fd2f2706”]http://developer.download.nvidia.com/compu...2791346fd2f2706[/url]
After that, I changed the code like below…
size_t offset;
cudaError error = cudaBindTexture( &offset, texHandle, partOfGpuMem, sizeof(unsigned short int)*srcW ); // Here srcW is 800
Here, “error” is cudaErrorInvalidValue and “offset” is 128.
The below is the discription of cudaBindTexture() from the above link
Since the hardware enforces an alignment requirement on texture base addresses, cudaBindTexture() returns in *offset a byte offset that must be applied to texture fetches in order to read from the desired memory. This offset must be divided by the texel size and passed to kernels that read from the texture so they can be applied to the tex1Dfetch() function
But Im not getting how to use “offset” in fetching and what is “texel size” and why I should devide offesrt by the texel size.
please help me on how to use the “offset” in texture fetching?.