bydefault function arguments resides in shared memory?


If I call a kernal funcrion like below…

Kernal<<< 10, 256>>>( int* iPtr, float* fPtr, char* cPtr );

In which memory the function arguments (iPtr, fptr and cPtr ) are resides?
Is it shared memory or global memory??

[deleted, see better response below]

Its in shared memory.

CUDA_programming_guide : top of page 21:

global function parameters are currently passed via shared memory to the device and limited to 256 bytes”


ok, but I’m not understood “limited to 256 bytes”.

What is this mean?

Exactly what it says. Function arguments are passed from shared memory via an allocated buffer/stack which can hold 256 bytes. So the sum of the size of types in the argument list passed to the function must be less than or equal to 256 bytes.

__global__ void MyKernel( int a, int b, int c )



Will occupy 3 * sizeof( ints) of the 256 available for you.

Same for all types of primitives and pointers.

The compiler will issue an error if you exceed this limit, as far as I remember.


I am calling a global function with 1MB data, Its just wokring fine.

If the size is more than 256 bytes, the arguments resides in which memory?

The actual arguments may be limited to 256 bytes

i assume you’re passing a pointer (4 bytes) that is pointing to a 1MB array? in that case the 1MB array will be wherever you put it as you should of allocated the memory on the gpu prior to executing the kernel

You are calling a global function with a pointer to 1Mb of data. Completely different thing.

oh!, yes, Im passing a pointer which is point to 1MB data.