开发者

Do Accelerate and Repa have different use cases?

开发者 https://www.devze.com 2023-03-10 17:07 出处:网络
I\'ve been playing around with Repa and Accelerate - they\'re both interesting, but I can\'t work out when I\'d use one and when the other. Are they growing together, riv开发者_高级运维als, or just fo

I've been playing around with Repa and Accelerate - they're both interesting, but I can't work out when I'd use one and when the other. Are they growing together, riv开发者_高级运维als, or just for different problems?


Repa is a library for efficient array construction and traversal, programmed in Haskell and run in the Haskell runtime. Repa relies on GHC's optimizer and threads for performance. You can mix arbitrary Haskell code with Repa (Repa functions such as map take Haskell functions as parameters).

Accelerate is an embedded language for GPU and multi-core CPU programming. Accelerate relies on its own compiler and GPU/CPU parallelism for performance. A piece of code using the Accelerate library doesn't actually do array computation. It generates an Accelerate program, which is processed by Accelerate's own runtime compiler to generate the code that actually processes your array data. In practice, however, you shouldn't notice the underlying steps, just import the library and CPU.run (A.map f xs) – or GPU.run. API-wise that's similar to Repa, where you would computeP to get the value out. A more noticable difference is that arguments to Accelerate functions will be of type Exp a if they're scalars, or Acc a if they're collective, ensuring you stick to "flat data-parallelism involving only regular, multi-dimensional arrays".

If you want to support GPUs in Haskell, Accelerate is the primary option. If you only need your code to run on CPUs, both Repa and Accelerate are good options.

0

精彩评论

暂无评论...
验证码 换一张
取 消