是否有可能在 F Sharp 下使用 CUDA 编写 GPU 应用程序?

发布于 2024-09-29 22:43:45 字数 59 浏览 1 评论 0原文

我对使用 F# 进行数值计算感兴趣。如何在 F# 下使用 NVIDIA 的 CUDA 标准访问 GPU?

I am interested in using F# for numerical computation. How can I access the GPU using NVIDIA's CUDA standart under F#?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

衣神在巴黎 2024-10-06 22:43:45

我同意 jasper 的观点,目前最简单的选择是使用 Microsoft Research 的 Accelerator。我写了一系列关于使用 F# 的文章。 简单直接的介绍生命游戏示例,更多使用引号的高级示例的示例使用高级报价功能Satnam Singh 博客也是一个很棒的资源,其中包含一些 F# 演示。

当前显卡的一个问题是它们不支持整数(因此,Accelerator 仅在使用优化的 x64 并行引擎运行时才支持它们)。此外,当前的显卡并未根据 IEEE 标准实现浮点数 - 它们试图通过进行一些“猜测”来加快速度,这在计算三角形位置时并不重要,但如果您正在处理财务计算。 (加速器可以使用各种目标,因此如果您使用 x64 并行引擎,您是安全的)。

据我所知,DirectCompute 将需要浮点运算的精确实现以及对整数的直接支持,因此这可能是未来的一个不错的选择(或者如果 Accelerator 最终开始使用 DirectCompute 作为其引擎)。

I agree with jasper that the easiest option currently is to use Accelerator from Microsoft Research. I wrote a series of articles about using from F#. A simple and direct introduction, Game of Life example, more advanced example using quotations and an example of using advanced quotation features. Satnam Singh's blog is also a great resource with some F# demos.

One problem with current graphics cards is that they do not support integers (as a result, Accelerator supports them only when running using optimized x64 parallel engine). Also, current graphics cards don't imeplement floating point numbers according to the IEEE standards - they are trying to be faster by doing a bit of "guessing", which doesn't matter when calculating triangle position, but could be an issue if you're dealing with financial calculations. (Accelerator can use various targets, so you're safe if you're using x64 parallel engine).

As far as I know, DirectCompute will require a precise implementation of floating point arithmetics as well as direct support for integers, so that may be a good choice in the future (or if Accelerator eventually starts using DirectCompute as their engine).

梓梦 2024-10-06 22:43:45

可能只有像我这样的硬核 GPU 极客才听说过它。 Tidepowerd -- 死链接已创建GPGPU 可用于基于 CIL 的语言(例如 F#、C#、VB.NET 等)。另一方面,您可以使用 Quotation-to-GPU 运行时/API 对单独的 F# 语言执行相同的操作(期待看到有人实现该功能)。这是史密斯特工在博客关于的内容 或者 F# Expert 1.0 书(面向语言编程章节)AFAIK 中也提到了这一点。

史密斯特工(好吧,抱歉)正在谈论 NVIDIA Cg。但是您可以使用 HLSL DirectCompute 着色器或 OpenCL C99 执行相同操作。PTX(低级 NVIDIA IL)、CAL-IL(低级 AMD/ATI IL)...

Probably only hardcore GPU geeks like me have heard about it. Tidepowerd -- dead link has made GPGPU possible for CIL-based languages (such as F#, C#, VB.NET, whatever). On the other hand you can do the same for sole F# language with a Quotation-to-GPU runtime/API (looking forward to see someone implement that). This is something Agent Smith has bloged about or that is also mentioned in F# expert 1.0 book (Language Oriented Programming chapter) AFAIK.

Agent Smith (ok, sorry for that) is speaking about NVIDIA Cg. But you can do same using HLSL DirectCompute shaders or OpenCL C99.. PTX (low level NVIDIA IL), CAL-IL (low level AMD/ATI IL)...

秋叶绚丽 2024-10-06 22:43:45

作为替代方案,您可以考虑使用 DirectCompute。三大 GPU API:CUDA、OpenCL 和 DirectCompute 都非常相似。可以通过 SlimDX(DirectX 的 .NET 包装器)从 F# 轻松访问 DirectCompute。

As an alternative, you could consider using DirectCompute. The three big GPU APIs: CUDA, OpenCL and DirectCompute, are all very similiar. DirectCompute can easily be accessed from F# via SlimDX, a .NET wrapper for DirectX.

扮仙女 2024-10-06 22:43:45

MS 的 加速器 允许您利用 GPU,因此可以执行以下操作,尽管你不能使用 CUDA。

Accelerator from MS allows you to leverage the GPUs, so can do something like this, though you cant use CUDA.

梦在深巷 2024-10-06 22:43:45

您可以查看 CUDA.NET。它可以让您直接从 F# 使用 CUDA。可以在这里找到:
http://www.hoopoe-cloud.com/Solutions/CUDA.NET /Default.aspx

从托管代码中使用 CUDA 的另一种常见替代方法是将 CUDA 功能封装在本机 DLL 中,然后对其进行 P/Invoke 或编写一个 C++/CLI 包装器,然后在其中使用例如您的 F# 程序。

You might look into CUDA.NET. It would let you use CUDA straight from F#. It can be found here:
http://www.hoopoe-cloud.com/Solutions/CUDA.NET/Default.aspx

The other usual alternative for using CUDA from managed code is to encapsulate the CUDA functionality in a native DLL and then either P/Invoke that or write a C++/CLI wrapper around that, which you then use from e.g. your F# program.

长亭外,古道边 2024-10-06 22:43:45

出于文档的目的(这是一个老问题,其答案不涵盖当前的技术前景),如果您今天必须编写 GPU/CUDA 应用程序,那么可以考虑的另一个选择是 aleagpu。

For the sake of documentation (it is an old question with answers that do not cover the current technology landscape), if you had to write GPU/CUDA apps today, then another option to consider is aleagpu.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文