Пример кода aleaGPU не работает в VB
Код C#:
[GpuManaged, Test]
public static void ActionFactoryWithClosure2()
{
var MyGPU = Gpu.Get(0);
var arg1 = Enumerable.Range(0, Length).ToArray();
var arg2 = Enumerable.Range(0, Length).ToArray();
var result = new int[Length];
Func<int[], Action<int>> opFactory = res => i =>
{
res[i] = arg1[i] + arg2[i];
};
MyGPU.For(0, arg1.Length, opFactory(result));
}
Код VB.NET:
<GpuManaged>
Public Shared Function GPU_TEST_VB_20170920()
Dim MyGPU As Alea.Gpu = Gpu.Default
Dim arg1 = Enumerable.Range(0, Length).ToArray()
Dim arg2 = Enumerable.Range(0, Length).ToArray()
Dim result = New Integer(Length - 1) {}
Dim expected = New Integer(Length - 1) {}
Dim opFactory As Func(Of Integer(), Action(Of Integer)) = Function(res) Function(i)
res(i) = arg1(i) + arg2(i)
End Function
Dim op As Action(Of Integer) = Function(i) InlineAssignHelper(result(i), arg1(i) + arg2(i))
Dim op2 As Action(Of Integer) = Sub(i)
result(i) = arg1(i) + arg2(i)
End Sub
MyGPU.[For](0, result.Length, Function(i) InlineAssignHelper(result(i), arg1(i) + arg2(i))) 'Error : The given key was not present in the dictionary.
MyGPU.For(0, arg1.Length, opFactory(result)) 'Error : The given key was not present in the dictionary.
MyGPU.For(0, arg1.Length, op) 'Error : The given key was not present in the dictionary.
MyGPU.For(0, arg1.Length, op2) 'Error : Cannot get field ""$VB$Local_result. Possible reasons: -> Static field Is Not supported."
End Sub
В случае C# я могу запустить пример кода, но в VB у меня появляется сообщение об ошибке (см. Строки кода выше). Что делать
То же состояние: VS 2017, Windows 10, AleaGPU 3.0.3