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

Zvi exta7@REDACTED
Thu Apr 3 06:45:58 CEST 2008


Jilani,

thanks for your tests.
It's expected from compiled statically-typed language, like Fortran,C or
Pascal to be faster than dynamic languages.
But I'm sure, that you can't calculate PI with one-liner in Pascal :) OK -
maybe with very very long one-liner. 
Are you Free Pascal version uses N=1000000 steps? Maybe you have some
epsilon-optimization, like Jeff suggested before? Can you send me your FP
code?

Thanks in advance,
Zvi



Jilani Khaldi-2 wrote:
> 
> 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
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
> 
> 

-- 
View this message in context: http://www.nabble.com/Calculate-PI-in-Erlang-faster-than-in-Matlab-tp16440056p16465102.html
Sent from the Erlang Questions mailing list archive at Nabble.com.




More information about the erlang-questions mailing list