Problem when using struct on device

while i am compiling the blew struct the cuda compiler is returng error … exit with code 1

any one has an idea why?

struct Ray {
	float3 orig;	// ray origin
	float3 dir;		// ray direction	
	__device__ Ray(float3 o_, float3 d_) : orig(o_), dir(d_) {}


That code, by itself, compiles fine/without error.

You should provide the complete output from nvcc when compiling this. If you are on windows in visual studio, turn up the visual studio verbosity until you can see the nvcc compile command and output/result.

Are you using this struct anywhere in HOST code? (Then, it’ll need device host instead of just device)

Or are you using it without any parameters in the constructor? (Once at least one custom constructor exists, default one will be gone, but you probably know that already…)

Another possible case could be that you have the function in some .cu file and are calling from another, but judging from your source, this seems unlikely. Anyway, if you altered the code here and that was the case in the original source, by default, “Dynamic compilation and linking mode” and “Relocatable device code” are turned off for the CUDA compiler and, therefore, no function references will be found from other compilation units. I would suggest either having them both in the same compilation unit (ei inlined; it’ll produce faster code anyway), or turning those features on (-dc -rdc for unix; -dc in command line options in visual studio, alongside turning “Relocatable Device Code” on in the CUDA compiler settings).

Hope, this helps…