More than one external shared memory declaration per kernel?

Hi,

I have a question regarding external shared memory:

Does it make sense to have more than one external shared memory declaration per kernel? The reason I ask is because all these variables start at the same address in memory (the offsets have to be managed explicitly by the application, according to the CUDA Programming Guide, sec. B.2.3).

It seems to me that any application using external shared memory would declare a buffer using ‘extern shared’ and then set up the individual variables explicitly, like this:

[codebox]extern shared char buffer;

global void func( )

{

short* array0 = (short *)buffer;

float* array1 = (float *)&array0[128];

int* array2 = (int *)&array1[64];

...

}[/codebox]

Any thoughts?

Thank you,

Rodrigo

The only time I’ve considered more than one extern shared array is if my kernel needs arrays of different types at during different phases of the execution.

The only time I’ve considered more than one extern shared array is if my kernel needs arrays of different types at during different phases of the execution.

Even in that case you’d still declare one extern shared array and a bunch of local pointers for all the other arrays of different types, like in the example code above.

Even in that case you’d still declare one extern shared array and a bunch of local pointers for all the other arrays of different types, like in the example code above.

Why?

Why?