Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

creating arrays in nvidia cuda kernel

Tags:

c++

cuda

nvidia

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];
  ...
}
like image 592
kl. Avatar asked Feb 02 '10 19:02

kl.


People also ask

What is CUDA array?

From the same document: > CUDA arrays are opaque memory layouts optimized for texture fetching.

What is the correct way to launch CUDA kernel?

In order to run a kernel on the CUDA threads, we need two things. First, in the main() function of the program, we call the function to be executed by each thread on the GPU. This invocation is called Kernel Launch and with it we need provide the number of threads and their grouping.

Does CUDA support C++?

Using the CUDA Toolkit you can accelerate your C or C++ applications by updating the computationally intensive portions of your code to run on GPUs. To accelerate your applications, you can call functions from drop-in libraries as well as develop custom applications using languages including C, C++, Fortran and Python.


1 Answers

You can do #1, but beware this will be done in EVERY thread!

Your second snippet won't work, because dynamic memory allocation at kernel runtime is not supported.

like image 103
Sebastian Dressler Avatar answered Oct 19 '22 17:10

Sebastian Dressler