Forks-Super
view release on metacpan or search on metacpan
bundle/Sys-CpuAffinity/lib/Sys/CpuAffinity.pm view on Meta::CPAN
|| _getNumCpus_from_lsdev()
|| _getNumCpus_from_bindprocessor()
|| _getNumCpus_from_BSD_Process_Affinity()
|| _getNumCpus_from_sysctl_freebsd()
|| _getNumCpus_from_sysctl()
|| _getNumCpus_from_dmesg_bsd()
|| _getNumCpus_from_xs_solaris()
|| _getNumCpus_from_dmesg_solaris()
|| _getNumCpus_from_psrinfo()
|| _getNumCpus_from_hinv()
|| _getNumCpus_from_hwprefs()
|| _getNumCpus_from_system_profiler()
|| _getNumCpus_from_Win32API_System_Info()
|| _getNumCpus_from_Test_Smoke_SysInfo()
|| _getNumCpus_from_prtconf() # slower than bindprocessor, lsdev
|| _getNumCpus_from_ENV()
|| _getNumCpus_from_taskset()
|| -1;
}
######################################################################
bundle/Sys-CpuAffinity/lib/Sys/CpuAffinity.pm view on Meta::CPAN
if ($ncpu == 0) {
# there might be output like:
# PU 30 at Module 001c35/Slot 0/Slice C: 400 Mhz MIPS R12000 Processor
$ncpu = grep { /^CPU / } @processor;
}
return $ncpu;
}
sub _getNumCpus_from_hwprefs {
return 0 if $^O !~ /darwin/i && $^O !~ /MacOS/i;
return 0 if !_configExternalProgram('hwprefs');
my $cmd = _configExternalProgram('hwprefs');
my $result = qx($cmd cpu_count 2> /dev/null);
$result =~ s/\s+$//;
_debug("\"$cmd cpu_count\" output: ", $result);
return $result || 0;
}
sub _getNumCpus_from_system_profiler { # NOT TESTED darwin
return 0 if $^O !~ /darwin/ && $^O !~ /MacOS/i;
return 0 if !_configExternalProgram('system_profiler');
bundle/Sys-CpuAffinity/lib/Sys/CpuAffinity.pm view on Meta::CPAN
DragonflyBSD: all CPAN tests are from single-core systems, so who knows
whether any of this code works on that platform.
There also hasn't been a CPAN tester with AIX yet.
how to find the number of processors:
AIX: sysconf(_SC_NPROCESSORS_CONF), sysconf(_SC_NPROCESSORS_ONLN)
prtconf | grep "Number Of Processors:" | cut -d: -f2
Solaris: processor_info(), p_online()
MacOS: hwprefs cpu_count, system_profiler | grep Cores: | cut -d: -f2
do something with `sysctl -a`
AIX: prtconf
solaris also has prtconf, but don't think it has cpu data
BSD also has `sysctl`, they tell me
AIX: `smtctl | grep "Bind processor "` ... not reliable
AIX: `lsdev -Cc processor` -- all processors
AIX: `bindprocessor -q` -- all shares of processors
Some systems have a concept of "processor groups" or "cpu sets"
that can we could either exploit or be exploited by
bundle/Sys-CpuAffinity/lib/Sys/CpuAffinity.pm view on Meta::CPAN
Some systems have a concept of the maximum number of processors that
they can suppport.
Currently (0.91-1.04), constant parameters to Win32 API functions are
hard coded, not extracted from the local header files.
##########################################
Issues in 1.02-1.04
1. darwin: hwprefs and sysctl give different results?
www.cpantesters.org/cpan/report/3982d2fa-9c2a-11e0-a04e-9d9517dc0771
2. openbsd: dmesg_bsd and sysctl give different results?
www.cpantesters.org/cpan/report/84d41dda-9942-11e0-a324-58f41aecacb6
www.cpantesters.org/cpan/report/0c6e981c-a2dd-11e0-a324-58f41aecacb6
3. linux: /usr/bin/taskset available but still cannot count CPUs? (x16)
/www.cpantesters.org/cpan/report/92ab9df8-a6fc-11e0-829d-5250641c9bbe
xs_sched_getaffinity keeps segfaulting (x4)
4. getNumCpus_from_Win32API_System_Info: garbage result on WOW64 systems
Issues in 1.09
bundle/Sys-CpuAffinity/t/02-available.t view on Meta::CPAN
BSD::Process::Affinity Math::BigInt)) {
my $avail = Sys::CpuAffinity::_configModule($module);
if ($avail) {
no warnings 'uninitialized';
$avail .= " v" . eval "\$$module" . "::VERSION";
}
print STDERR "module $module: ", ($avail || "not"), " available\n";
}
foreach my $externalProgram (qw(bindprocessor dmesg sysctl psrinfo hinv
hwprefs lsdev system_profiler prtconf
taskset pbind cpuset)) {
my $path = Sys::CpuAffinity::_configExternalProgram($externalProgram);
if ($path) {
print STDERR "$externalProgram available at: $path\n";
} else {
print STDERR "$externalProgram: not found\n";
}
}
print STDERR "\n";
system-limits.PL view on Meta::CPAN
}
if ($ncpu == 0) {
$ncpu = grep /^hw.ncpu:/, qx(sysctl -a 2>/dev/null);
$sys =!!$ncpu;
}
if ($ncpu == 0) {
$ncpu = () = qx(psrinfo 2> /dev/null);
$sys =!!$ncpu;
}
if ($ncpu == 0) {
$ncpu = qx(hwprefs cpu_count 2>/dev/null);
$sys =!!$ncpu;
}
if ($ncpu && $ncpu > 0) {
print "There are $ncpu cpus on this system.\n";
if ($sys) {
write_limits( 'sys|ncpu' => $ncpu + 0 );
} else {
write_limits( ncpu => $ncpu + 0 );
}
( run in 0.792 second using v1.01-cache-2.11-cpan-0bb4e1dffa6 )