[erlang-questions] SMP enabled or not?

13 views
Skip to first unread message

Zabrane Mickael

unread,
Jul 23, 2011, 4:10:06 PM7/23/11
to Erlang-Questions Questions
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" )
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

Barry Nicholson

unread,
Jul 23, 2011, 4:33:59 PM7/23/11
to erlang-q...@erlang.org
I have no idea about questions 1 & 2.

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

Michael Schreckenbauer

unread,
Jul 23, 2011, 4:48:08 PM7/23/11
to erlang-q...@erlang.org
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).

> Regards
> Z.

HTH,
Michael

erlang

unread,
Jul 23, 2011, 4:56:31 PM7/23/11
to Michael Schreckenbauer, Barry Nicholson, erlang-q...@erlang.org
Thanks guys.

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).

_______________________________________________

Frank Goenninger

unread,
Jul 24, 2011, 6:00:12 AM7/24/11
to erlang-q...@erlang.org
Am 23.07.2011 um 22:48 schrieb Michael Schreckenbauer:

> 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

Tomasz Maciejewski

unread,
Jul 24, 2011, 6:12:09 AM7/24/11
to erlang-q...@erlang.org
Dnia 24-07-2011 o 12:00:12 Frank Goenninger <fr...@me.com> napisał(a):

> [smp:4:4]

Here it is.

--
Tomasz Maciejewski

Frank Goenninger

unread,
Jul 24, 2011, 6:13:52 AM7/24/11
to erlang-q...@erlang.org

Am 24.07.2011 um 12:12 schrieb 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

Sam Elliott

unread,
Jul 24, 2011, 6:42:43 AM7/24/11
to Frank Goenninger, erlang-q...@erlang.org
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

Sam
--
Sam Elliott
s...@lenary.co.uk
--

Frank Goenninger

unread,
Jul 24, 2011, 7:40:37 AM7/24/11
to erlang-q...@erlang.org
Am 24.07.2011 um 12:42 schrieb Sam Elliott:

> 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.

Reply all
Reply to author
Forward
0 new messages