I think you can just pass c2nim on the mpi.h header file on your computer. It should be similar to this if you use OpenMPI: https://github.com/open-mpi/ompi/blob/master/ompi/include/mpi.h.in.
Here is a toy matrix multiplication example that you can use as a demo with MPI: http://blog.speedgocomputing.com/search/label/parallelization
So the answer is there is no lib like that. ^^" That's a shame. Sadly, simply running c2nim was not the way to go, I had to change some stuff manually. Still, the prototype is here and I guess the results are pretty nice and idiomatic:
# mpitest.nim
import strutils
from mpi import mpiApp
proc main() {.mpiApp.} =
let rank = mpi.commRank()
let size = mpi.commSize()
echo "Hello world from process $1 of $2".format(rank, size)
var digits = newSeq[int](4)
if rank == 0:
digits = @[1,2,3,4]
mpi.send(digits[1..3], dest=1)
elif rank == 1:
mpi.recv(digits[0..2], src=0)
echo "on $1: arr = $2".format(rank, digits)
mpi.sum(digits)
if rank == mpi.Root:
echo "on $1: sum = $2".format(rank, digits)
main()
# mpirun -n 2 mpitest.nim:
# Hello world from process 1 of 2
# Hello world from process 0 of 2
# on 0: arr = @[1, 2, 3, 4]
# on 1: arr = @[2, 3, 4, 0]
# on 0: sum = @[3, 5, 7, 4]
Yes, it works with slices, just like parallel-spawn. ;) Thank you, metamagic.
I have an MPI wrapper here https://github.com/jcosborn/qex/tree/devel/src/comms
I'm planning to add it to nimble eventually.