完整的堆栈跟踪:
“i32不是结构类型。源位置堆栈:
- >在C:\ Users \ IcaroLima \ Documents \ Visual Studio 2017 \ Projects \ TestandoAleaParallel \ TestandoAleaParallel \ Program.cs(16,33-16,37)
- >在TestandoAleaParallel.Program + A. [Void set_X(Int32)]
- >在C:\ Users \ IcaroLima \ Documents \ Visual Studio 2017 \ Projects \ TestandoAleaParallel \ TestandoAleaParallel \ Program.cs(31,17-31,32)
- >在TestandoAleaParallel.Program +<> c__DisplayClass1_0。[Void b__0(Int32)]
- >在Alea.Parallel.Device.DeviceFor。[Void Kernel(Int32,Int32,System.Action1 [System.Int32])]
- >在定义runtime32(sm52,32bit)作为内核的加载方法:
- >方法:Alea.Parallel.Device.DeviceFor。[Void Kernel(Int32,Int32,System.Action1 [System.Int32])]
- > InstanceOpt:
- >争论。#0:0
- >争论。#1:10
- >参数。#2:System.Action1 [System.Int32]获取或加载方法为内核:
- >方法:Alea.Parallel.Device.DeviceFor。[Void Kernel(Int32,Int32,System.Action1 [System.Int32])]
- > InstanceOpt:
- >争论。#0:0
- >争论。#1:10
- >参数。#2:System.Action`1 [System.Int32]“ExceçãoSemTratamento:System.Exception:i32不是结构类型。
源位置堆栈:
- >在C:\ Users \ IcaroLima \ Documents \ Visual Studio 2017 \ Projects \ TestandoAleaParallel \ TestandoAleaParallel \ Program.cs(16,33-16,37)
- >在TestandoAleaParallel.Program + A. [Void set_X(Int32)]
- >在C:\ Users \ IcaroLima \ Documents \ Visual Studio 2017 \ Projects \ TestandoAleaParallel \ TestandoAleaParallel \ Program.cs(31,17-31,32)
- >在TestandoAleaParallel.Program +<> c__DisplayClass1_0。[Void b__0(Int32)]
- >在Alea.Parallel.Device.DeviceFor。[Void Kernel(Int32,Int32,System.Action1 [System.Int32])]
- >在定义runtime32(sm52,32bit)作为内核的加载方法:
- >方法:Alea.Parallel.Device.DeviceFor。[Void Kernel(Int32,Int32,System.Action1 [System.Int32])]
- > InstanceOpt:
- >争论。#0:0
- >争论。#1:10
- >参数。#2:System.Action1 [System.Int32]获取或加载方法为内核:
- >方法:Alea.Parallel.Device.DeviceFor。[Void Kernel(Int32,Int32,System.Action1 [System.Int32])]
- > InstanceOpt:
- >争论。#0:0
- >争论。#1:10
- >参数。#2:System.Action1 [System.Int32]em Alea.Gpu.GetOrLoad(MethodInfo kernelMethodInfo,FSharpOption1 instanceOpt,FSharpList1参数)em
Alea.CSharp.GpuExtensions.Launch [T1,T2,T3](Gpu this,Action3内核, LaunchParam lp,T1 arg1,T2 arg2,T3 arg3)em
Alea.Parallel.Device.DeviceFor.For(Gpu gpu,Int32 fromInclusive,Int32 toExclusive,Action1 op)em
TestandoAleaParallel.Program.Main(String [] args)na
C:\ Users \ IcaroLima \ Documents \ Visual Studio 2017年\项目\ TestandoAleaParallel \ TestandoAleaParallel \的Program.cs:linha 29
我的简单代码:
class Program
{
[GpuManaged]
class A
{
public int X { get; set; }
public int Score(A b)
{
return X + b.X;
}
}
static void Main(string[] args)
{
A[] array = new A[10];
Alea.Gpu gpu = Gpu.Default;
gpu.For(0, 10, i =>
{
array[i].X = i;
});
for (int i = 0; i < 10; i++)
{
Console.WriteLine(array[i].X);
}
}
}
我相信代码很简单,我不明白错误的原因。