[erlang-questions] MPI and Erlang. (fun experiment)

Bengt Kleberg bengt.kleberg@REDACTED
Fri Jun 17 08:46:24 CEST 2011


Greetings,

Thank you for supplying the example. Would it be possible for you to
split parts of simpsonrule.erl into one mpi.erl where you have the C
examples MPI library? It would make the comparison easier.

Moreover, the C code has hard coded sin(). In Erlang you send a fun. Try
to hard code sin() in Erlang too, it might speed things up a little.
Finally, you have apply/2 in compute/5 which I think could be written as
Fun(X), it might speed things up a little.


bengt

 On Fri, 2011-06-17 at 05:07 +0200, Ale wrote:
> Hello all,
> 
> Just sharing with whom might ever be interested, a fun (for me, might
> not be for you) experiment. I tried to port a MPI implementation of
> Simpson's rule[0], I had made for a course in HPC, to Erlang. I wasn't
> expecting Erlang to beat C... but, well see the results:
> 
> MPI: https://github.com/alep/Experiments/blob/master/simpson/c-mpi/simpsons_rule_mpi.c
> $ time mpirun -np 2 mpisimpson 0 10 100000000
> ale@REDACTED's password:
> proc[0]: iterating from: 0 to: 50000000
> proc[0]: result: 1.83907152907611348702
> proc[1]: iterating from: 50000000 to: 100000000
> 
> real 0m7.016s
> user 0m3.288s
> sys 0m0.072s
> 
> Erlang:  https://github.com/alep/Experiments/blob/master/simpson/erlang/simpsonrule.erl
> $ time ./run.sh
> Hostname: dell-desktop
> Proc[0]: iterating from 0 to 50000000
> Proc[1]: iterating from 50000000 to 100000000
> Result: 1.8390715290761146
> 
> real 0m25.047s
> user 0m22.713s
> sys 0m0.116s
> 
> FAIL! :-D But it was fun.
> 
> Now is there a way to make it a bit faster? What am I doing wrong? How
> can I improve it? Ideas....? Thanks
> 
> [0] http://en.wikipedia.org/wiki/Simpson%27s_rule




More information about the erlang-questions mailing list