Hi,
I’m working on an application where I need to run an rvalue constructor on the device for many classes. The default rvalue constructor, by default, compiles for __host__
, as we all know. I need to use the default rvalue constructor, but on the device. From what I can tell, this entails writing down the whole default rvalue constructor (std::move applied to each of the constituent pieces of data in the class), but prefixing it with __device__ __host__
. Clearly, this is not a very sustainable software development technique since if someone adds a piece of data to any class (there are around 100 classes in this piece of software), they have to also modify the custom constructor.
Is it possible to generate the default constructors, but enabling them for __device__
? I tried this:
struct DeviceConstructible
{
__device__ __host__ DeviceConstructible(DeviceConstructible&& other) = default;
};
But sadly doesn’t give the effect I’m looking for. Looks like i may have to cook up some nasty macro or clang script to generate these automatically, huh? Or am I missing some CUDA feature?
Thanks,
Gavin