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