In kernel function, I want two vectors of shared memory, both with size
length (actually sizeof(float)*size
).
Since it is not possible to a
The C Programming guide section on __shared__ includes examples where you allocate multiple arrays from dynamically allocated shared memory:
extern __shared__ float array[];
__device__ void func() // __device__ or __global__ function
{
short* array0 = (short*)array;
float* array1 = (float*)&array0[128];
int* array2 = (int*)&array1[64];
}
Since you're just getting a pointer to an element and making that a new array, I believe you could adapt that to use dynamic offsets instead of the static offsets they have in the example. They also note that the alignment has to be the same, which shouldn't be an issue in your case.