From 9ca429b5ce0c44c54c7515794deb8351c39f5991 Mon Sep 17 00:00:00 2001 From: Ole Tange Date: Fri, 8 Mar 2013 09:49:01 +0100 Subject: [PATCH] parallel: HPUX CPU/core detection. Thanks to Javier Tarradas. --- src/parallel | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/parallel b/src/parallel index b26cd3b3..01ba42ce 100755 --- a/src/parallel +++ b/src/parallel @@ -2931,6 +2931,8 @@ sub no_of_cpus { $no_of_cpus = no_of_cpus_aix(); } elsif ($^O eq 'darwin') { $no_of_cpus = no_of_cpus_darwin(); + } elsif ($^O eq 'hpux') { + $no_of_cpus = no_of_cpus_hpux(); } else { $no_of_cpus = (no_of_cpus_freebsd() || no_of_cpus_netbsd() @@ -2968,6 +2970,8 @@ sub no_of_cores { $no_of_cores = no_of_cores_aix(); } elsif ($^O eq 'darwin') { $no_of_cores = no_of_cores_darwin(); + } elsif ($^O eq 'hpux') { + $no_of_cores = no_of_cores_hpux(); } else { $no_of_cores = (no_of_cores_freebsd() || no_of_cores_netbsd() @@ -3166,6 +3170,24 @@ sub no_of_cores_aix { return $no_of_cores; } +sub no_of_cpus_hpux { + # Returns: + # Number of physical CPUs on HP-UX + # undef if not HP-UX + my $no_of_cpus = + (`/usr/bin/mpsched -s 2>/dev/null | grep 'Locality Domain Count' | awk '{ print \$4 }'`); + return $no_of_cpus; +} + +sub no_of_cores_hpux { + # Returns: + # Number of CPU cores on HP-UX + # undef if not HP-UX + my $no_of_cores = + (`/usr/bin/mpsched -s 2>/dev/null | grep 'Processor Count' | awk '{ print \$4 }'`); + return $no_of_cores; +} + sub sshcommand { my $self = shift; if (not defined $self->{'sshcommand'}) {