I’m rather new to both C++ and CUDA. I was looking to initialize a static const variable on the device to my custom class.
device constant MyClass firstDummy = MyClass(“dummy1”, 57);
device constant MyClass secondDummy = MyClass(“dummy2”, 22);
When I compile, I get…
error: can’t generate code for non empty constructors or destructors on device
From what that error says I can’t have a non-empty constructor, but I need those, and anyway if I make an empty constructor or even not include a constructor at all, it still wouldn’t compile unless I made it a pointer like …MyClass* fir… but then how would I initialize it?
The only thing I can think of as a work-around is to make an Initialize() method that I would Launch when the CUDA module is first loaded that set’s these classes in a global variable. Then after that launch start running the actual code. These values never need to be accessed by host code, all this code is device only
Anyway I’m looking for some suggestions on what the best way is to define something like 15 instances of “MyClass” that will not change during runtime. But will be referenced often.