传递给 gpu 内存的结构未定义。如何将结构传递给 Cudafy?
Struct passed to gpu memory is undefined. How to pass struct to Cudafy?
我有一个结构和一个带有 Execute() 方法的 class,并且 cudafying 方法使用该结构。
问题:Cuda 说:“.../CUDAFYSOURCETEMP.cu(3):错误:标识符 "PointGPU" 未定义”
[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, ...);
决定是:
CudafyModule km = CudafyTranslator.Cudafy(typeof(PointGPU));
我有一个结构和一个带有 Execute() 方法的 class,并且 cudafying 方法使用该结构。
问题:Cuda 说:“.../CUDAFYSOURCETEMP.cu(3):错误:标识符 "PointGPU" 未定义”
[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, ...);
决定是:
CudafyModule km = CudafyTranslator.Cudafy(typeof(PointGPU));