I'm having some issues allocating a struct, which contains several arrays, to the GPU. In the 2nd code block im getting an error with:
SimpleDataStructure[] dev_SDS = _gpu.CopyToDevice(SDS);
Does anyone know why? From what i can see CopyToDevice() doesnt support a struct as an argument. I might be missing something though so would appreciate some assistance in any case.
Struct declaration:
[Cudafy]
public struct SimpleDataStructure
{
public float[] AreaCode;
public float[] Number;
public SimpleDataStructure(int x)
{
AreaCode = new float[x];
Number = new float[x];
}
}
Code in a method in my class:
Public class TaskManager
{
private static GPGPU _gpu;
private SimpleDataStructure SDS;
public void PreparationForTasks()
{
DataRetrieval();
SDS = new SimpleDataStructure(_entity.Data.Count - 1);
CudafyModule km = CudafyTranslator.Cudafy();
_gpu = CudafyHost.GetDevice(eGPUType.Cuda);
_gpu.LoadModule(km);
//Loaded SimpleDataStructure into same module.
km = CudafyTranslator.Cudafy(typeof(SimpleDataStructure));
_gpu.LoadModule(km, false);
//Getting error on following line.
SimpleDataStructure[] dev_SDS = _gpu.CopyToDevice(SDS);
dim3 grid = new dim3(10, 10, 1);
dim3 block = new dim3(8, 8, 1);
_gpu.Launch(grid, block, "WorkerKernelOnGPU", dev_SDS);
SimpleDataStructure result_SDS = new SimpleDataStructure(100);
_gpu.CopyFromDevice(dev_SDS, result_SDS);
}
//.....
}