malloc in a kernel

I need to allocate an array in a kernel. The problem is that the size vary according variables depending of the thread. Therefore I can’t use CudaMalloc in the main() function.
So how can I allocate an array directly in my kernel function ? Is there a function like malloc() callable in the kernel ?

No dynamic memory allocation in kernels. The only notionally dynamic allocation method is the ability to allocate up 16kb of shared memory to a block of running threads at kernel launch.

dommage! thanks for your reply.

I will have to allocate a huge array in the main () function and each thread will call a piece of it. :thumbup: