Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get size of an array in CUDA kernel function?

Tags:

cuda

I have a CUDA kernel function like this:

__global__ void kernel(int a, int b)
{
extern __shared__ unsigned char array[];
//int size = /*size of array*/; = 16
}

and in function main I called it:

sharedMemSize = 16;
kernel<<<gridSize, blockSize, sharedMemSize>>>(1, 2);

How can I get size of shared memory array? This is the first time I have a question on StackOverflow :) Thank you!!!

like image 885
Trần Công Thạch Avatar asked Nov 16 '25 23:11

Trần Công Thạch


1 Answers

You can get the size in bytes of your array using: sizeof(array).

like image 126
user2023370 Avatar answered Nov 18 '25 13:11

user2023370



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!