Cuda-Parallel-programming-

Create appropriate number of threads and blocks based on the N number entered

We have up to 1024 threads and 2097151 blocks for the x dimension. I tried to create the most appropriate number of threads and blocks if the number was not more than the maximum number of threads according to the number of N entered.

If N is less than or equal to 1024, we only use one block.

image

If we enter 1025, it creates 2 block 513 threads instead of 2 block 1024 threads. image

The maximum number of threads is 1024, but when we enter 4000, I create 1000 threads in each block, avoiding extra threads.

image

1019 * 23 = 23437 Our N valu is 23432 thus, the most appropriate number of threads was formed within N number.

image