In C++, I think, it is fairly common to initialize a structure with
SomeStruct s = {0};
I believe this is supposed to initialize the first element to “0” (whatever that is), and the rest to binary zeros.
(see the article at [url=“How to initialise structures to all-elements-zero-or-null”]http://ex-parrot.com/~chris/random/initialise.html[/url] )
However, I’ve tried this in CUDA and, although it compiles, it doesn’t seem to work.
My questions, then, are:
-
Isn’t this behavior specified in the C++ standard? Does CUDA not follow this part?
-
If this doesn’t work, does anyone have any suggestions for how to efficiently and succinctly intialize an arbitrary structure to 0’s? (Ideally, without manually iterating over each byte. In my case, I have a templated kernel e.g. template global void kernel(T* data), and intend to use it with ,, etc, and need to be able to initialize an element T to 0’s)