2

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.

talonmies
  • 70,661
  • 34
  • 192
  • 269
Přemysl Šťastný
  • 1,676
  • 2
  • 18
  • 39
  • 2
    I've heard about `accelerate` library, but have no idea how well it works. I think it translate a DSL to Cuda underneath. – lsmor Feb 23 '22 at 12:26
  • 2
    Parallel and Concurrent Programming in Haskell has a chapter on [GPU Programming With Accelerate](https://www.oreilly.com/library/view/parallel-and-concurrent/9781449335939/ch06.html) – Vikstapolis Feb 23 '22 at 13:12

0 Answers0