0

I have an array containing a structure of two elements, that I send to CUDA in global memory, and I read the values from global memory.

As I read through some books and posts, and as I am only reading values from the structure, I thought i would be interesting if it was possible to store my array in Texture memory. I used the following code outside the kernel :

texture<node, cudaTextureType1D, cudaReadModeElementType> textureNode;

and the following lines in main()

gpuErrchk(cudaMemcpy(tree_d, tree, n * sizeof(node), cudaMemcpyHostToDevice)); 
gpuErrchk(cudaBindTexture( (size_t)0,textureNode, tree_d, n*sizeof(node) ));

and in my kernel I used the following :

        printf("Here %d\n",tex1Dfetch(textureNode, 0 ));

but I do have a compilation error, by using "node" in the first line however it compiles if I replace it by int but my point would be access elements in my array of structures by using something like :

tree[i].left; 

I have tried multiple things, but haven't been able to make it work, so I'm wondering if this is possible.

Thanks

1 Answer 1

1

Textures only support CUDA built in types. it is not possible to bind user structures to textures.

if you have a structure which happens to have the same size and alignment as a CUDA built-in vector type, it might be possible to pretend it is a built-in type.and bind it, but that is just idle speculation.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.