Is there an Erlang way which let me know if:
1. the Erlang VM was compiled with SMP support or not?
2. the Erlang VM was started with SMP enabled (i.e "erl -smp enable" )
3. how many cores are available on my machine?
Regards
Z.
_______________________________________________
erlang-questions mailing list
erlang-q...@erlang.org
http://erlang.org/mailman/listinfo/erlang-questions
Theoretically, you can use the following code to discover how
many cpus are on a machine.
application:start(sasl).
application:start(os_mon).
cpu_sup:util([per_cpu]).
However, it doesn't work on Macs or at least mine.
We also write a small library routine that parses /proc/cpuinfo on
Linux. /proc/cpuinfo has a line of the
form
processor: x
where x is the cpu id. We simply retrieved the largest x found in the
file. Thus we then have the number of cpus on that machine. Remember
this doesn't work on Windows, Mac, embedded or many other OSs.
But the second method isn't an Erlang way.
Barry Nicholson
On Saturday 23 July 2011 22:10:06 Zabrane Mickael wrote:
> Hi,
> Is there an Erlang way which let me know if:
> 1. the Erlang VM was compiled with SMP support or not?
> 2. the Erlang VM was started with SMP enabled (i.e "erl -smp enable" )
erlang:system_info(smp_support).
> 3. how many cores are available on my machine?
erlang:system_info(logical_processors_available).
> Regards
> Z.
HTH,
Michael
Le 23 juil. 2011 à 22:48, Michael Schreckenbauer a écrit :
> Hi,
>
> On Saturday 23 July 2011 22:10:06 Zabrane Mickael wrote:
>> Hi,
>
>> Is there an Erlang way which let me know if:
>
>> 1. the Erlang VM was compiled with SMP support or not?
>> 2. the Erlang VM was started with SMP enabled (i.e "erl -smp enable" )
>
> erlang:system_info(smp_support).
>
>> 3. how many cores are available on my machine?
>
> erlang:system_info(logical_processors_available).
_______________________________________________
> erlang:system_info(smp_support).
>
> erlang:system_info(logical_processors_available).
$ erl
Erlang R14B03 (erts-5.8.4) [source] [64-bit] [smp:4:4] [rq:4] [async-threads:0] [hipe] [kernel-poll:false]
Eshell V5.8.4 (abort with ^G)
1> erlang:system_info(smp_support).
true
2> erlang:system_info(logical_processors_available).
unknown
... on my 4 core MacBook Pro ...
Cheers
Frank
> [smp:4:4]
Here it is.
--
Tomasz Maciejewski
> Dnia 24-07-2011 o 12:00:12 Frank Goenninger <fr...@me.com> napisał(a):
>
>> [smp:4:4]
>
> Here it is.
I know. But why does this show up as "unknown" when asked for programmatically ?
Frank
> try
>
> 1> erlang:system_info(logical_processors).
> 2
>
> That got me the right thing on my mbp when logical_processors_available wasn't. Maybe also try:
>
> 2> erlang:system_info(logical_processors_online).
> 2
Cool! Works!
Thanks.