Will new[] preserve memory allocations between kernel launches ? CUDA C (new[] allocator)

Hello,

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[10];

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 ;) :)

Bye,
Skybuck.

Em… I certainly believe that it will be preserved. But why don’t you give it a try and tell us the result?

Well, I can’t try everything… I already have a lot to do ;)

Trying simple stuff costs more time then asking a question and reading the answer ;) :)

Ofcourse in due time I will try, but this also allows me to think about my plans ;)

And there are certain difficulities with figuring out what happens.

I might not be able to try out printf, since I am using cuda from Delphi.

So figuring out what constructors are called gets a little bit more tricky ;)

Also debugging not working yet so I gotta try that out too ;)