[erlang-questions] Calculate PI in Erlang faster than in Matlab

Jilani Khaldi jilani@REDACTED
Wed Apr 2 12:25:46 CEST 2008


Zvi wrote:
> Hi All,
> 
> I wrote "Migrating to Multi-Core" presentation, where I describe various
> parallel programming models and APIs. As a practical example, I calculate PI
> number using various parallel APIs, such as pthreads, Win32 threads, OpenMP,
> MPI, Intel TBB and off course plain old serial C code.
> So I decided to add example in my favorite parallel language - Erlang. The
> code and math description is attached.
I will have a look at the code later seen I am very interested in 
scientific and technical programming in Erlang. However Vega and Deneb + 
Plain Pascal (Free Pascal Compiler) said:
Vega (1 CPU Celeron, 512 MB RAM, 2.4 GHZ, Win2K) -> 15 ms
Deneb (1 CPU Celeron, 256 MB RAM, 300 MHZ, Linux Slack 10.2) -> 127 ms

Your code on Vega gives:
3> c(pi).
{ok,pi}
4> pi:test().
[{math,{16000,3.14159}},
  {list_creation,{171999,3.14159}},
  {lc,{1389999,3.14159}},
  {lc_no_pow,{1249999,3.14159}},
  {map,{812999,3.14159}},
  {mapfoldl,{2249999,3.14159}},
  {serial_decr,{389999,3.14159}},
  {serial,{406999,3.14159}},
  {parallel,{405999,3.14159}}]
5> pi:test().
[{math,{1,3.14159}},
  {list_creation,{140998,3.14159}},
  {lc,{1295999,3.14159}},
  {lc_no_pow,{1468999,3.14159}},
  {map,{1109999,3.14159}},
  {mapfoldl,{920999,3.14159}},
  {serial_decr,{390999,3.14159}},
  {serial,{405999,3.14159}},
  {parallel,{406999,3.14159}}]

And on Deneb it gives:
[{math,{2567,3.14159}},
  {list_creation,{644691,3.14159}},
  {lc,{5523921,3.14159}},
  {lc_no_pow,{5061841,3.14159}},
  {map,{3643349,3.14159}},
  {mapfoldl,{9540475,3.14159}},
  {serial_decr,{1156172,3.14159}},
  {serial,{1196930,3.14159}},
  {parallel,{1221314,3.14159}}]

JK

-- 
***
T E M A
http://www.dotpas.org



More information about the erlang-questions mailing list