Anders Finn Jørgensen Anders Finn Jørgensen - 1 month ago 16
C# Question

TypeInitializationException thrown by aleagpu

I am trying to use aleagpu but I get the System.TypeInitializationException. I have tried to google what the problem is but I couldn't find any solution, so please help. The program is the simplest possible:

class Klazz
{
private const int N = 100;
private const int Length = 10000000;
var gpu = Gpu.Default;// here is the Exception thrown
public static void Unmanaged()
{
var data = new int[Length];

for (var k = 0; k < N; k++)
gpu.For(0, data.Length, i => data[i] += 1);
}
}


I am imagining that there is something wrong in my installation, because the program is a copied example from aleagpu's homepage.

My system is:


  • Windows 10

  • .NET v4.5.2

  • VS 2015 Community
    NVIDIA GPU computing toolkit CUDA v8.0



Alea is installed from NuGet November 9. 2016


  • Alea (3.0.1)

  • Alea.IL (2.2.0.3307)

  • Alea.CUDA (2.2.0.3307)

  • Alea.CUDA.IL
    (2.2.0.3307)

  • Alea.CUDA.Unbound (2.2.0.3307)



The variables in PATH is correct.

I have tried the AleaSample.CS.ParallelForAutoMemMgt as well with the same result.

Answer Source

It turns out that aleagpu is written in F#, and when you install FSharp.Core the program works. Thanks to Ghosthack answering the question: Alea GPU Tutorial not compiling on VS 2015 Update 2 with FSharp.Core 4.4.0.0