[ANN] marching-cubes2

Hello,

I released marching-cubes2 today. It is similar to marching-cubes but the marching cubes algorithm is implemented in C and it is faster.

Here are some usage examples.

4 Likes

Why a second package and not a new version of the previous one?

1 Like

https://chrisdone.com/posts/ipp/

2 Likes

I don’t think it serves well here. It isn’t just/even a matter of breakage. The first one is pure Haskell, the second one has C bits. Unless the API or output is different that could be a package flag.

It isn’t clear-cut as “the 2nd version is better, upgrade if you can”.

2 Likes

I wonder why the C version is faster. I can think of these reasons:

  1. Different algorithm and/or data structures
  2. Automatic vectorization of GCC
  3. Manual memory management

But only 2 could be insurmountable for Haskell.

Also, do you have a benchmark? I might try to translate your C implementation to low level Haskell.

3 Likes

@jaror I’m also wondering. Perhaps I don’t correctly use the bang patterns. The algorithm is the same, and it was not easy to implement in Haskell. That’s a reason for which I did another package instead of replacing the Haskell code with the C code, I don’t want to abandon the Haskell implementation (but I could have added the C implementation in the first package, I just didn’t think about that).

I don’t have benchmarks but you can try the Mandelbulb with each implementation and you will clearly see the C implementation is faster.

Not sure the memory management is better with the C implementation. When I did the animation of the toratope (ICN5D.hs, the strange tori with topology changing) with the C implementation, my laptop has crashed (it has 32 Go). I didn’t try with the Haskell implementation.

3 Likes