From 82b50467ce0e6cc72cacac444d0d9665f21a32b9 Mon Sep 17 00:00:00 2001 From: Ole Tange Date: Fri, 29 Jul 2011 17:44:37 +0200 Subject: [PATCH] parallel: CPU detection improved for Mac OSX (Thanks to Wayne E. Seguin). --- src/parallel | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/parallel b/src/parallel index 3098f21d..b97213f5 100755 --- a/src/parallel +++ b/src/parallel @@ -2462,7 +2462,10 @@ sub no_of_cpus_darwin { # Returns: # Number of physical CPUs on Mac Darwin # undef if not Mac Darwin - my $no_of_cpus = `sysctl -a hw 2>/dev/null | grep -w physicalcpu | awk '{ print \$2 }'`; + my $no_of_cpus = + (`sysctl -n hw.physicalcpu` + or + `sysctl -a hw 2>/dev/null | grep -w physicalcpu | awk '{ print \$2 }'`); return $no_of_cpus; } @@ -2470,7 +2473,10 @@ sub no_of_cores_darwin { # Returns: # Number of CPU cores on Mac Darwin # undef if not Mac Darwin - my $no_of_cores = `sysctl -a hw 2>/dev/null | grep -w logicalcpu | awk '{ print \$2 }'`; + my $no_of_cores = + (`sysctl -n hw.logicalcpu` + or + `sysctl -a hw 2>/dev/null | grep -w logicalcpu | awk '{ print \$2 }'`); return $no_of_cores; }