I started a new VS2017 c# console app project and installed Alea and Alea.Fody from package manager. Running a piece of sample code from the website gave me the following exception.
System.TypeInitializationException occurred HResult=0x80131534 Message=The type initializer for 'Alea.GlobalImplicitMemoryTracker' threw an exception. Source=Alea StackTrace: at Alea.GlobalImplicitMemoryTracker.GetInManagedFlag() at gputest.Program.DelegateWithClosureGpu() at gputest.Program.Main(String[] args) in c:\Users\myuser\documents\visual studio 2017\Projects\gputest\gputest\Program.cs:line 14
Inner Exception 1: TypeInitializationException: The type initializer for 'A.cf5aded17df9f7cc4c132234dda010fa7' threw an exception.
Inner Exception 2: FileNotFoundException: Could not load file or assembly 'FSharp.Core, Version=4.4.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
Here is the entire program.
using Alea;
using Alea.Parallel;
using System.Linq;
namespace gputest
{
class Program
{
private const int Length = 1000000;
static void Main(string[] args)
{
DelegateWithClosureGpu();
}
[GpuManaged]
public static void DelegateWithClosureGpu()
{
var arg1 = Enumerable.Range(0, Length).ToArray();
var arg2 = Enumerable.Range(0, Length).ToArray();
var result = new int[Length];
Gpu.Default.For(0, result.Length, i => result[i] = arg1[i] + arg2[i]);
var expected = arg1.Zip(arg2, (x, y) => x + y);
//Assert.That(result, Is.EqualTo(expected));
}
}
}
I had to install F# a little differently for VS2017 by modifying the .NET desktop development options to install F# language support but after that it did work. It is not intuitive that using Alea for C# requires F# support. That should be listed in the install guide.
You need to install F# runtime. In VS2015, select your vs installation and choose modify, add F# feature.
I had a similar error in VS2017.3 with F# already installed, starting from a clean project, using Alea GPU 3.0.3 from NuGet. It turns out that the package contains all the DLLs referenced, including the FSharp.Core.dll (check the .../packages/ sub-directory of your C# project). I copied all the DLLs over to the directory containing the executable (e.g., .../bin/Debug), unchecked the property of the C# program for "prefer 32-bit", and rebuilt. My program then ran fine. Note, I think the Alea GPU .targets file might need to be corrected to copy required files to the appropriate directory.
User contributions licensed under CC BY-SA 3.0