c# - 抛出异常 : 'System.Exception' in Alea. dll“i32 不是结构类型

标签 c# aleagpu

我正在尝试使用 Alea GPU 库中的 Gpu.Default.For,但我一直收到异常:

i32 is not a struct type error.

这个错误是什么意思,为什么我用这个简单的 Gpu.Default.For 循环得到它?

for (Int32 j = 0; j <= TimePeriodArray.Length - 1; j++)
//Gpu.Default.For(0, TimePeriodArray.Length - 1, j =>
{
    Int32 days = TimePeriodArray[j];
    Double[] CalcResult = new Double[CloseArray.Length];

    for (Int32 Index = days; Index <= CloseArray.Length - 1; Index++)
    {
        Gpu.Default.For(Index - 1, Index - days, i =>
        {
            CalcResult[Index] = CalcResult[Index] + CloseArray[i];
        });

        CalcResult[Index] = CalcResult[Index] / days;
    }

    CalcResultsList.Add(CalcResult);
//});
}

最佳答案

两件事:首先,您在 GPU 代码中新建了一个数组,这是不受支持的。其次,我猜 CalcResultsListList 类型,同样不受支持。原因是,在 GPU 代码中分配新内存效率不高。 GPU 代码会被很多线程执行,不推荐在 GPU 代码内部分配。

关于c# - 抛出异常 : 'System.Exception' in Alea. dll“i32 不是结构类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44330186/

相关文章:

c# - 2路跨进程通信

c# - 在不重定向或重新加载页面的情况下单击 html 元素时执行代码

c# - 使用 Alea GPU 加速嵌套循环和按位运算

c# - Alea GPU 教程未使用 FSharp.Core 4.4.0.0 在 VS 2015 Update 2 上编译

c# - GPU全局内存计算

c# - 从 .NET 调用带有 WS Security 的 Web 服务

c# - 如何将事件从基于 Laravel 的服务器广播到基于 .net C# 的客户端?

c# - 使用指纹的 FTPS

c - 我们如何使用 AleaGpu 将多维数组复制到内核?