1

I am beginner of Cuda programming. Apology for my simple question.

I read some document and examples. If I use a kernel function, I should do something like

kernelfun <<<number of block, number of thread>>>(args).

So there is no number for grid. Do we need to set the number of grid we plan to use?

According to my GPU, how should I set the number of block, and number of thread? enter image description here

Because I saw the max number threads per block is 512. So I should to set the num of thread is 512 to full use the GPU.

The other question is should I calculate the memory of my project use when I set the numbers of block and thread? Or the computer will arrange this automatically and I do not need to concern the memory my project uses.

Vivian
  • 207
  • 1
  • 3
  • 11

1 Answers1

2

I believe the kernel launch parameters are:

kernelfun <<<number of block, number of _threads_>>>(args).

As for setting the number of grids - no, you don't have to do anything like that. One kernel launch is equivalent to one grid, which consists of blocks and blocks consist of threads and threads are the execution units executing the code of your kernel.

Your additional question about size of grids and blocks is most likely a duplicate as that is quite a famous topic - please see this SO thread for instance.

As for the last question, memory concerns, if your threads within blocks consume more registers than available, then the kernel will simply not execute successfully. Other than that I can't figure out what are you asking about exactly, so if this does not answer you question then please add additional details such as which kind of memory are you concerned about etc.

Community
  • 1
  • 1
Michal Hosala
  • 5,570
  • 1
  • 22
  • 49
  • hi, thank you for your answer. Could you please answer the other question in my newly edited post? – Vivian Sep 26 '14 at 12:36