creating arrays in nvidia cuda kernel

c++, cuda, nvidia

Solution

You can do the first example, I haven't tried the second.

However, if you can help it, you might want to redesign your program not to do this. You do not want to allocate 4000 bytes of memory in your kernel. That will lead to a lot of use of CUDA local memory, since you will not be able to fit everything into registers. CUDA local memory is slow (400 cycles of memory latency).

Problem

hi I just wanted to know whether it is possible to do the following inside the nvidia cuda kernel ``` __global__ void compute(long *c1, long size, ...) { ... long d[1000]; ... } ``` or the following ``` __global__ void compute(long *c1, long size, ...) { ... long d[size]; ... } ```

Original source

Related problems