Struct passed to gpu memory is undefined. How to pass struct to Cudafy?

137 views Asked by At

I have a struct and a class with Execute() method and a cudafying method uses the struct.

PROBLEM: Cuda says: ".../CUDAFYSOURCETEMP.cu(3): error: identifier "PointGPU" is undefined"

[Cudafy]
public struct PointGPU
        {
            public double x;
            public double y;
            public double z;

        public PointGPU(double xVal, double yVal, double zVal)
        {
            x = xVal;
            y = yVal;
            z = zVal;
        }
    }

class MarchingCubesOnGPU
{
    CudafyModule km = CudafyTranslator.Cudafy();
    GPGPU gpu = CudafyHost.GetDevice();

    private static PointGPU[] pointsGpu = new PointGPU[8];

    public void Execute()
    {
        gpu.LoadModule(km);

        PointGPU[] dev_points = gpu.CopyToDevice(pointsGpu);

        gpu.Launch().PolygoniseOnGpu(dev_points, ...);

        ...
    }

    [Cudafy]
    public static void PolygoniseOnGpu(PointGPU[] p, ...)
    {
        ...
    }

    public List<Triangle> setPolygoniseParameters(...)
    {
        pointsGpu = ... 
    }
}

This line in CudafySourceTemp.cu is

extern "C" __global__  void PolygoniseOnGpu( PointGPU* p, ...);
1

There are 1 answers

0
Julia Grabovska On BEST ANSWER

The decision is:

CudafyModule km = CudafyTranslator.Cudafy(typeof(PointGPU));