我们如何在 AleaGpu 中使用 10000 行和 10000 列(而不是行 =10 和行 =5)的数组?
private void button3_Click(object sender, EventArgs e)
{
var worker = Worker.Default;
const int rows = 10;
const int cols = 5;
var rng = new Random();
var inputs = new double[rows, cols];
for (var row = 0; row < rows; ++row)
{
for (var col = 0; col < cols; ++col)
{
inputs[row, col] = rng.Next(1, 100);
}
}
var dInputs = worker.Malloc(inputs);
var dOutputs = worker.Malloc<double>(rows, cols);
var lp = new LaunchParam(1, 1);
worker.Launch(Kernel, lp, dOutputs.Ptr, dInputs.Ptr, rows, cols);
var outputs = new double[rows, cols];
dOutputs.Gather(outputs);
Assert.AreEqual(inputs, outputs);
}
如果我使用 rows = 10000 和 cols = 10000 (而不是 rows = 10 和 rows = 5):
我在函数中收到错误“Alea.CUDA.dll 中发生类型为 'Alea.CUDA.CUDAInterop.CUDAException' 的未处理异常”:public static void Gather(this DeviceMemory dmem, T[,] array2D):
dmem.Worker.EvalAction(() =>
{
CUDAInterop.cuSafeCall(CUDAInterop.cuMemcpyDtoH(hostPtr, devicePtr,
new IntPtr(Intrinsic.__sizeof<T>() * rows * cols)));
});
如何消除此错误?