是否可以用纯 Haskell 语言对 GPU 进行编程?

发布于 2025-01-09 05:42:34 字数 380 浏览 4 评论 0原文

我想知道我是否可以用纯 Haskell 编写应该由 GPU 评估的代码。

例如,GPU 中两个大矩阵相乘的函数(理论上)没有副作用,因此可以从纯 Haskell 函数中调用它。

但我也担心,如果我只是通过 FFI 将 CUDA C++ 程序作为纯函数包装到 Haskell,是否会出现问题。据我从文档中了解到,我必须确定没有副作用,但我根本不确定。

所以我的问题是:

  1. 如果我将 C++ CUDA 函数作为纯函数包装到 Haskell 中,是否有什么东西可能会破坏?
  2. 是否有一些库,使我能够仅使用纯 Haskell 来对 GPU 进行编程,而不使用 Haskell FFI?
  3. 如果没有的话,理论上可以制作吗?

谢谢。

I wonder, whether I can write code, which ought to be evaluated by GPU, in pure Haskell.

For example, a function for multiplication of two large matrices in GPU have (theoretically) no side effects, therefore it might be possible to call it from pure Haskell function.

But I am also worried, whether something don't get broken, if I just wrap CUDA C++ procedures to Haskell via FFI as pure functions. As I understand from the documentation, I must be sure, that there are no side effects and I am not sure at all.

So my questions are:

  1. Is there something, what might break, if I wrap C++ CUDA function to Haskell as a pure function?
  2. Is there some library, which enables me to use just pure Haskell to program GPU without usage of Haskell FFI?
  3. If not, is it theoretically possible to make one?

Thanks.

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文