Using the fact that the GHC run-time easily handles millions of tiny threads, we produced a highly concurrent implementation of interaction nets in Haskell.
The included interpreter RunInets performs parallel
execution of .inet files written in a restricted version
of Ian Mackie's “Inets” language, for which so far
only a compiler to sequential code has been available in the
Inets project.
Some example .inet files are included in the HINet distribution.
With the executables RunInets, fibND,
and ackND from this package, you can:
time fibND +RTS -N1 -H1G -M1G -RTS 20
Try again with 4 cores:
time fibND +RTS -N4 -H1G -M1G -RTS 20
Don't be disappointed that the speed-up is far from 4 — HINet only
implements extremely fine-grained concurrency without any attempt
to achieve larger granularity for parallelisation.
time fibND +RTS -N4 -H1G -M1G -s -RTS 20
Ackerman(3,6):
time ackND +RTS -N1 -H7M -M7M -RTS 3 6
time ackND +RTS -N4 -H7M -M7M -RTS 3 6
fib(20) again, but using a .inet specification — like the
above, this works with unary numbers internally, but now also produces a
unary number as output:
time RunInets +RTS -N1 -H1G -M1G -RTS data/Nat/fib20.inet
time RunInets +RTS -N4 -H1G -M1G -RTS data/Nat/fib20.inet
The conversion can be done in the Inets language, by using int attributes:
time RunInets +RTS -N1 -H1G -M1G -RTS data/Nat/fibN20.inet
time RunInets +RTS -N4 -H1G -M1G -RTS data/Nat/fibN20.inet
fib(20) again, but now using an .inet specification that does all
the additions on int attributes:
time RunInets +RTS -N1 -H1G -M1G -RTS data/Inets/fibonacci20.inet
time RunInets +RTS -N4 -H1G -M1G -RTS data/Inets/fibonacci20.inet
time RunInets +RTS -N1 -H1G -M1G -RTS data/Inets/sort100.inet
time RunInets +RTS -N4 -H1G -M1G -RTS data/Inets/sort100.inet
RunInets your own .inet files...
doc/HINet.pdf
and build your own interaction net tools using HINet...
Downloads: