I saw CUDA C Programming Guide mention support for “c++ classes” and “dynamic memory malloc”.
It also mentioned that allocations with “cuda c’s/kernel’s malloc” would remain between kernel launches…
So I wonder if this also applies to classes and arrays and such which have been allocated/created with the new allocator ?
So for example:
TSomeClass *mSomeClass = new TSomeClass;
Would these 10 classes remain present between kernel launches ?!?
(My guess would be yes because new probably uses malloc ?)
Also perhaps the guide’s name should be changed to CUDA C/C++ Programming Guide, since it seems to support C++ as well ?! =D
Anyway I am wondering about this because it might represent a little optimization possibility… I could then place the constructor calls or allocations or something in a special kernel… or perhaps cuda does that automatically just once on the first kernel run ? It’s probably not much of an issue to allocate just every time the kernel is run… I am just wondering about possibilities… might be a bit difficult to create a “allocation kernel only” and a “freeing kernel only” plus the “execution kernel” which would be called many times.
For now my code design relies on automatic class construction with default constructors… perhaps cuda could deviate from c++ and prevent automatic class construction but that probably not be nice… or I could change my code to use “class references” or “class/object pointers” or so and manually instantiate class objects myself :)