constant memory and struct with texture member
Hey, I am new to cuda! nvcc give an error in my code,
Compiler error mesg:
[code]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".
[/code]

Below is the simple code to reproduce the problem:

[code]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));
}[/code]

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!
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!

#1
Posted 04/24/2012 11:57 AM   
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).
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).

Always check return codes of CUDA calls for errors. Do not use __syncthreads() in conditional code unless the condition is guaranteed to evaluate identically for all threads of each block. Run your program under cuda-memcheck to detect stray memory accesses. If your kernel dies for larger problem sizes, it might exceed the runtime limit and trigger the watchdog timer.

#2
Posted 04/24/2012 12:10 PM   
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.
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.

#3
Posted 04/24/2012 01:58 PM   
Thanks for your quick replay. /thanks.gif' class='bbc_emoticon' alt=':thanks:' />

I am trying your suggestions.
[quote name='tera' date='24 April 2012 - 08:10 PM' timestamp='1335269450' post='1400286']
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).
[/quote]
Thanks for your quick replay. /thanks.gif' class='bbc_emoticon' alt=':thanks:' />



I am trying your suggestions.

[quote name='tera' date='24 April 2012 - 08:10 PM' timestamp='1335269450' post='1400286']

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).

#4
Posted 04/24/2012 02:08 PM   
Scroll To Top