Skip to content

Haskell Pidigits GHC-6 update by Liam Zhu

Haskell GHC-6 update by Liam Zhu

Source code

Revamped to use more idiomatic code, away from the code-golfed version, although I don't understand the algorithm well enough to provide variable names. Added a primitive command parser and an exceptions handler in case the command parser fails. Added proper pure / impure separation between the IO and generator (list) code.

https://salsa.debian.org/Liamzy/haskell-benchmark-rigs/-/blob/main/pidigits7.hs pidigits7.hs

Provide an example build command-line

Build on M3 silicon:

ghc --make -fllvm -O2 -XBangPatterns -threaded -rtsopts pidigits7.hs -o pidigits.ghc-7.ghc_run -I/opt/homebrew/opt/gmp/include/

Informal comparisons:

./pidigits.ghc-7.ghc_run +RTS -N4 -RTS 10000 0.44s user 0.06s system 104% cpu 0.486 total

./pidigits.ghc-7.ghc_run +RTS -N1 -RTS 10000 0.43s user 0.02s system 96% cpu 0.460 total

./pidigits.gcc-2.gcc_run 10000 0.31s user 0.01s system 98% cpu 0.318 total

Edited by William Zhu