Search code examples
c#gpgpualeagpu

How to allocate multiple arrays in shared memory


I'm trying to convert a kernel written for Cudafy to Alea. Cudafy lets you allocate multiple arrays of different types in shared memory. Example:

int[,] paths = thread.AllocateShared<int>("path", 128, 9);
float[] best = thread.AllocateShared<float>("best", 128);

It seems in Alea, you can only allocate a single array in shared memory. I'm only seeing the following:

var lp = new LaunchParam(128, 128, 1024);
...
int[,] paths = __shared__.Array2D<int>(128, 9);

Am I missing something? Is there a way to allocate multiple arrays in shared memory in Alea?


Solution

  • __shared__.Array2D is used in kernel to define compile-time fixed size 2D array. It cannot be used outside of kernel. Here are some examples: https://github.com/quantalea/AleaGPUTutorial/blob/master/src/csharp/examples/matrix_multiplication/MatrixMult.cs#L52