Amount of shared memory


In my kernel I have the following deceleration for dynamically allocating shared memory:

global void prescan(float *g_odata, float *g_idata, int n)

extern shared float temp[];

My question is do I need to mention the amount of shared memory required, while I call the kernel in the main? Is it necessary?

Thanks for your time!!

Yes, you must set the 3rd parameter in the kernel launch:

prescan<<<dimGrid, dimBlock, sizeof(float) * numSharedFloats>>>

If it works without the third parameter, that is on accident and should not be relied upon.