Thanks for reporting the web site problem. Yes, our document are under constructing. I tried your steps and I figured out how to do it correctly, which I will show you later. The issues you met are mainly because:
- You are using VS2012, which by default referencing FSharp 3.0, which is a little out-of-date, we suggest to use FSharp 3.1
- You forget to reference other assemblies which is used in the code, such as NUnit and FSharp.Charting
- Alea.CUDA.Fody doesn't means to work with C#, it means to do AOT compile on GPU code. It uses Fody plugin to compile GPU code during MSBuild process, so your appliction doesn't need to compile GPU code in runtime.
Now, here are the steps:
- Open VS 2012, upgrade nuget plugin, then new F# console application project
- Expand "References" in solution explorer, and remove the
FSharp.Core
reference (since it is FSharp 3.0, we will replace it with new 3.1)
- Go to "Package Manager Console", install some nuget packages which is used in the code:
Install-Package FSharp.Core
Install-Package FSharp.Charting
Install-Package NUnit
- Now we will install
Alea.CUDA.Fody
(which will install Alea.CUDA by dependency). But since Fody plugin has to run some powershell script to create an FodyWeavers.xml
file to configure Fody usage, and this script doesn't work well with F# project (it works with C# project). The workaround is simple, just click "save all" in VS2012 before you run Install-Package Alea.CUDA.Fody
. You will see some red error in the package manager console, that is fine, it is just the Fody plugin's script doesn't work well with F# project. You can safely ignore it. After install Alea.CUDA.Fody
, a file FodyWeavers.xml
file will be added to your project, there you can configure how you will do the AOT compilation. I suggest you add a setting to show verbose information: <Alea.CUDA Verbose="true"/>
- Now you need add some common references, since the package
FSharp.Charting
uses them. To do that, right click your "References" in solution explorer, and choose "Add Reference...", under "Assemblies" -> "Framework", select these assemblies:
System.Drawing
System.Windows.Forms
System.Windows.Forms.DataVisualization
- Now your project is set. Please Change the building configuration to "Release".
- Now let's add the source file. First right click
Program.fs
in solution explorer, and select "Add above" -> "New Item...", select F# source file, name it ParallelSquare.fs
- Copy https://github.com/quantalea/AleaGPUTutorial/blob/master/src/fsharp/getting_started/ParallelSquare.fs into that new created file
- You need modify one place: https://github.com/quantalea/AleaGPUTutorial/blob/master/src/fsharp/getting_started/ParallelSquare.fs#L139 , change this to
WorkerExtension.Launch(worker, <@ squareKernel @>) lp dOutputs.Ptr dInputs.Ptr inputs.Length
, the reason is, the Launch
method is an extension method, which the FSharp compiler in VS 2012 doesn't support it well, so we call that extension method directly (So I suggest you to use VS 2013).
- Now in your
Program.fs
file, call the test in main function: Tutorial.Fs.quickStart.ParallelSquare.squareChart()
. and then you can press "F5" to run it.
After this, I suggest you read http://quantalea.com/static/app/manual/compilation-index.html where explains the intallation, the AOT vs JIT compilation, etc.