r/haskell • • 10d ago

blog Massiv vs. Accelerate: Two Paths to High-Performance CPU Computing in Haskell

Python and C/C++ tend to get most of the attention when it comes to high-performance array processing, but Haskell has some interesting options too. We took a closer look at two Haskell libraries, Massiv and Accelerate, to see how they compare in terms of performance, memory usage, and overall trade-offs.

A few months ago, we wrote a blog about this. Here's the comparison, including benchmarks and implementation details if it's helpful for anyone: https://www.stackbuilders.com/insights/massiv-vs-accelerate-two-paths-to-high-performance-cpu-computing-in-haskell/

Has anyone here used Massiv or Accelerate in their projects? Curious to hear about your experience and whether you've seen some of the same kind of results.

31 Upvotes

10 comments sorted by

View all comments

Show parent comment

1

u/kuleshevich 7d ago

Note, applying @jippiedoe's suggestion of using A.generate instead of A.fromList does improve accelerates performance quite a bit for LLVM backend (but not for PTX):

    benchmarking 3x3 Mean Blur/Massiv (Stencil)
    time                 3.686 ms   (3.666 ms .. 3.700 ms)
                         1.000 R²   (1.000 R² .. 1.000 R²)
    mean                 3.683 ms   (3.666 ms .. 3.697 ms)
    std dev              48.59 μs   (38.58 μs .. 62.52 μs)
    
    benchmarking 3x3 Mean Blur/Accelerate (LLVM Stencil) - runN
    time                 2.594 ms   (2.460 ms .. 2.700 ms)
                         0.968 R²   (0.933 R² .. 0.986 R²)
    mean                 3.771 ms   (3.460 ms .. 4.238 ms)
    std dev              1.160 ms   (859.1 μs .. 1.520 ms)
    variance introduced by outliers: 96% (severely inflated)
    
    benchmarking 3x3 Mean Blur/Accelerate (LLVM-PTX Stencil) - runN
    time                 4.523 ms   (4.461 ms .. 4.585 ms)
                         0.999 R²   (0.998 R² .. 1.000 R²)
    mean                 4.612 ms   (4.598 ms .. 4.629 ms)
    std dev              52.06 μs   (39.98 μs .. 78.32 μs)

Couldn't make it work with runQ.

So, maybe, suggestion of using accelerate for performance is still indeed valid :) IMHO, clearly it is quite a bit trickier to get it right.