constant memory and struct with texture member

Hey, I am new to cuda! nvcc give an error in my code,

Compiler error mesg:

est.cu(8): error: can't generate code for non empty constructors or destructors on device

1 error detected in the compilation of "/tmp/tmpxft_0000055c_00000000-4_test.cpp1.ii".

Below is the simple code to reproduce the problem:

typedef struct{

    texture<float, 2>  tex_f[9];

} Simulation;

__constant__ Simulation const_sim;

int main(){

    Simulation temp_sim;

    cudaMemcpyToSymbol(&const_sim, &temp_sim, sizeof(Simulation));

}

I have googled the error for long time and it says the error occurs mainly because the c++ style struct … but my struct have no functions at all !

Regard any help!

As far as I know textures cannot be part of complex data structures, because there is some magic to map them to the hardware. That also is why layered textures have been introduced to CUDA (to replace arrays of textures).

Another workaround would be to use function pointers for functions providing access to each texture used (or C++ subclasses, which are essentially the same).

Bindless textures on Kepler should enable one to embed texture handles in data structures (according to the whitepaper). Though, I don’t recall seeing them mentioned in the CUDA 4.2 guide, and the whitepaper says OpenGL only. Here’s hoping that CUDA-enable this feature in the next release.

Thanks for your quick replay. External Image

I am trying your suggestions.