0

我已完成以下操作以在 Visual Studio 2012 Professional 中创建 Alea GPU 项目:

  1. 文件 > 新建 > 项目 > F# 应用程序
  2. 将 NuGet 包管理器更新到最新版本
  3. 工具 > NuGet 包管理器 > 控制台
  4. PM> 安装包Alea.CUDA
  5. PM> 安装包 Alea.CUDA.IL
  6. 使用这些说明安装许可证:http: //quantalea.com/static/app/tutorial%5Cgetting_started%5Cinstall_license.html
  7. 将此处的代码https://github.com/quantalea/AleaGPUTutorial/blob/master/src/fsharp/getting_started/ParallelSquare.fs复制到我的主项目文件中。
  8. 构建解决方案。

我收到以下错误: 在此处输入图像描述

  1. 上面 GitHub 链接中的行号和文件相互对应。

I'm new to using Alea GPU, Visual Studio, and F#. I've tried doing what I could with the resources I have available. Although the the Alea GPU website explains what to do (install Alea through NuGet, install license, provides code, etc.) it might be targeted to users who have experience working with Visual Studio. It's also worth mentioning I have CUDA drivers installed on this machine.

I have also followed the instructions on this page, but it seems like it's still under construction: http://quantalea.com/static/app/tutorial%5Cgetting_started%5Ccreate_new_project.html. I'm not using Fody since I won't be using C#.

4

1 回答 1

3

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.

于 2015-07-16T06:19:12.710 回答