dynamic array issue?

I’m a beginner to program in cuda.

When we write kernel function, are there any dynamic array mechnism like CArray,CDWordArray in C++? Because we really don’t know what’s the exact size of an array during a task. We only hope to add more data into that array depending on the conditions.


There is no dynamic memory allocation of any form available in CUDA kernels on the current generation of hardware. The next generation of hardware is supposed to support in-kernel dynamic memory allocation, but at the moment that only exists as a specification on a piece of paper.

Anyway you may consider to allocate memory for your biggest array size, or the whole available GPU Global Memory.

Contrary to “classical” OS, when your kernel is running, you may take all the available GPU Global Memory without any side-effect on other software (your kernel is THE software).
So don’t bother allocating dynamic array, instead begin by allocation all available memory to your kernel and use it at your will using pointers :-)

Foward to using it soon.

It’s a good way. But this approach will waste too many memories especilly when memory resources are very precious.

This is no waste of memory, since except for the video framebuffer, all GPU video-ram is dedicated to the running kernel, you just have to ask for the whole available gpu memory and allocate it at your will inside your kernel.

This is no waste at all because all this GPU memory is dedicated to your kernel, wether you ask for it or not!