【问题标题】:Struct passed to gpu memory is undefined. How to pass struct to Cudafy?传递给 gpu 内存的结构未定义。如何将结构传递给Cudafy?
【发布时间】:2017-07-18 05:17:54
【问题描述】:

我有一个结构和一个带有 Execute() 方法的类,一个 cudafying 方法使用该结构。

问题:Cuda 说:“.../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 = ... 
    }
}

CudafySourceTemp.cu 中的这一行是

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

【问题讨论】:

    标签: c# .net gpu cudafy.net


    【解决方案1】:

    决定是:

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

    【讨论】:

      猜你喜欢
      • 2015-07-15
      • 2011-05-09
      • 1970-01-01
      • 2023-03-15
      • 2019-09-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多