parallel: Fixed bug #65723: parallel --number-of-cores=12, should be 16.

This commit is contained in:
Ole Tange 2024-10-20 16:55:22 +02:00
parent 0da890a2bc
commit 0a6ae96002
4 changed files with 115 additions and 3 deletions

View file

@ -8871,10 +8871,20 @@ sub sct_gnu_linux($) {
my $threads_per_core; my $threads_per_core;
my $cores_per_socket; my $cores_per_socket;
for(@lscpu) { for(@lscpu) {
# lscpu
/^CPU.s.:\s*(\d+)/ and $cpu->{'threads'} = $1; /^CPU.s.:\s*(\d+)/ and $cpu->{'threads'} = $1;
/^Thread.s. per core:\s*(\d+)/ and $threads_per_core = $1; /^Thread.s. per core:\s*(\d+)/ and $threads_per_core = $1;
/^Core.s. per socket:\s*(\d+)/ and $cores_per_socket = $1; /^Core.s. per socket:\s*(\d+)/ and $cores_per_socket = $1;
/^(CPU )?Socket.s.:\s*(\d+)/i and $cpu->{'sockets'} = $2; /^(CPU )?Socket.s.:\s*(\d+)/i and $cpu->{'sockets'} = $2;
# lscpu --all --extended
# 3 0 0 1 1:1:1:0 yes 2900.0000 800.0000 1995.6210
# 1 0 0 1 1:1:1 yes 1300.0000 800.0000 800.0000
/^\s+(\d+)\s+\d+\s+(\d+)\s+(\d+)\s+\d+:\d+:\S+\s/ and do {
# Really only the last line matters
$cpu->{'threads'} = $1+1;
$cpu->{'sockets'} = $2+1;
$cpu->{'cores'} = $3+1;
};
} }
if($cores_per_socket and $cpu->{'sockets'}) { if($cores_per_socket and $cpu->{'sockets'}) {
$cpu->{'cores'} = $cores_per_socket * $cpu->{'sockets'}; $cpu->{'cores'} = $cores_per_socket * $cpu->{'sockets'};
@ -8896,7 +8906,7 @@ sub sct_gnu_linux($) {
read_cpuinfo(split/(?<=\n)/,$ENV{'PARALLEL_CPUINFO'}); read_cpuinfo(split/(?<=\n)/,$ENV{'PARALLEL_CPUINFO'});
} elsif($ENV{'PARALLEL_LSCPU'}) { } elsif($ENV{'PARALLEL_LSCPU'}) {
# Use LSCPU from environment - used for testing only # Use LSCPU from environment - used for testing only
read_lscpu(split/(?<=\n)/,$ENV{'PARALLEL_LSCPU'}); read_lscpu(split/\n/,$ENV{'PARALLEL_LSCPU'});
} elsif(-r "$ENV{'PARALLEL_CPUPREFIX'}/cpu0/topology/thread_siblings") { } elsif(-r "$ENV{'PARALLEL_CPUPREFIX'}/cpu0/topology/thread_siblings") {
# Use CPUPREFIX from environment - used for testing only # Use CPUPREFIX from environment - used for testing only
read_topology($ENV{'PARALLEL_CPUPREFIX'}); read_topology($ENV{'PARALLEL_CPUPREFIX'});
@ -8906,7 +8916,7 @@ sub sct_gnu_linux($) {
# Not debugging: Look at this computer # Not debugging: Look at this computer
if(!($cpu->{'sockets'} and $cpu->{'cores'} and $cpu->{'threads'}) if(!($cpu->{'sockets'} and $cpu->{'cores'} and $cpu->{'threads'})
and and
open(my $in_fh, "-|", "lscpu")) { open(my $in_fh, "-|", "lscpu --all --extended")) {
# Parse output from lscpu # Parse output from lscpu
read_lscpu(<$in_fh>); read_lscpu(<$in_fh>);
close $in_fh; close $in_fh;

View file

@ -1369,6 +1369,94 @@ par__test_cpu_detection_lscpu() {
compgen -A function | grep ^cpu | sort | parallel -j0 -k test_one compgen -A function | grep ^cpu | sort | parallel -j0 -k test_one
rm ~/.parallel/tmp/sshlogin/*/cpuspec 2>/dev/null rm ~/.parallel/tmp/sshlogin/*/cpuspec 2>/dev/null
} }
par__test_cpu_detection_lscpu_--all_--extended() {
pack() { zstd -19 | mmencode; }
unpack() { mmencode -u | zstd -d; }
export -f unpack
# ssh server lscpu --all --extended | pack
cpu3() {
echo '1-2-4-2 Core i5-2410M laptop firewall'
echo '
KLUv/QRoBQQA0gYWGHCtDnzPzw76rSjXJHV5twOYLUlfqv43WWq5mbDAYo/P3Rr/alsIFuAc
t+/adX0Jmv63//6KGvO/U8xmmP8fqSFpPZOv5YtYvoflY1Lhl3jAqjwSlZ5BYBEg8ALb2pEO
kGvVfEIAircDrMryswQmQCOci78EmFUDeEAyiFCTmkD1
' | unpack
}
cpu13() {
echo '1-2-2-2 AMD Neo N36L Dual-Core Processor'
echo '
KLUv/QRoTQMAgoURFpBNY2syao8D/vfeGkqOTGuz1NTY0pTEmmc+kEmMAeKQU1L1io8POKT9
0NGeov2vQ5h7C0ynZBole5e3bjZZj3mN53aUFQ4ggALUaxAYHlqAHBGpjAmBGaAzHIBXAmbV
ATDAGAgoKVhdvw==
' | unpack
}
cpu19() {
echo '1-2-4-2 ThinkPad A475 AMD PRO A12-8830B R7 (64g)'
echo '
KLUv/QRoJQQA8kYXGXCtDnzPzw76rSgRSLE7rjbEE0IrrPrfZAGrmTB062XdsOHjM1vXgoH/
xa0fELRjjb/ArsBOSdUffNDxv/+iB2QkD5Fc0mPSejbhxBNGPC+XGt9IJFbmsqj0jhIDEiBg
w3QNIJFcgPBwhAEJIBYx/SYGA8TZTgGYFYADN9xCOVCeG3FI2w==
' | unpack
}
cpu21() {
echo '2-12-24-12 Intel(R) Xeon(R) CPU E5-2620 v3 @ 2.40GHz (kreta)'
echo '
KLUv/QRojQYA8gkdGHBvDlztQ2HSU/8ZXvMutLS0iaTrVP01X4yZl5XlxoX71m1btty7ravb
8lJ2fIwND+H2+9vX7s51e2vNzljzmXu/+wN7VdVAldkt6vpbf/0B5ZCMJBKS/y+UYyrL2Wye
Xe3saeeLZhn+FMiwOC+IRTnEDAE4qOFUMuCwz74BUE8tazGNESBEhBMr/mcCUbkH8CBRaVnR
Utmi0lKbdTtxAhKCFxDgq4qrB4fssyd+hzTUliaPXXMlXeivPoZcFv1AtK+bJxn3SVtkgXx6
tCoL/r+Y
' | unpack
}
cpu22() {
echo '1-16-24-16 12900K https://stackoverflow.com/a/71282744/363028'
echo '
KLUv/QRoHQcAcgwiGHBvDlztQ2HSU/8Yv0AX1nZ3bwlO1V/vBfALb+je992vua+73ee2b7ub
tn9/f+rK1a/eejl3egrTrbSMcAULz210bF9oqJ/7/KSwzi5CuM3tub3fbgPSqqqBqhCNWZm9
aqsNMMhimzqWaVhs22AQhWnslG3KXle2umLjaQhHRkI0kI2iYSw5RDaosXQnWFJDZdk3gE2r
AaEIERhChBNZNPGPBKPKPHiLEhWHkWF4HJyLA2JJed1oAHlHMUYzijHSQmXEO4oxmlEtDApN
QezCFCBrSYSKt5G7ixaw9Ml2VwFqvgJs
' | unpack
}
cpu23() {
echo '1-14-20-14 https://github.com/nodejs/node/issues/52233#issuecomment-2023768771'
echo '
KLUv/QRoJQcAMo0jGnBNc3zPzw76LWIb4GzTPebS0iYy0Qqr/ps4mMdssstf1ov5zEWlvvzl
HiblK5eh5Cd3HeQjVyXK9OMfNxnVQT//XHTIzhM+Yc9S97zxxmZC/vqqT+LPT9HYApB7gbt1
KoFM2l97LYApHNo6CIeG4NC2C1NoTNNsd3sE2x/YuiQapYvFoDSKLoOGKQOhBC6ggXgpkEA0
VO13kKWWA5kQ3YTsJmQz37VJpE2QblKQYrhcIOthvksBHXYsUkQpM6SgX0iEoJ4ZIWhvPggs
iRBrnLZwBFTkfvsVAbMDGgiSg60Cro5aVQ==
' | unpack
}
cpu24() {
echo '1-24-32-24 https://in.mathworks.com/matlabcentral/answers/2100291-matlab-parallel-computing-beyond-8-cores-causing-os-to-crash#comment_3113976'
echo '
KLUv/QRoHQsAttY4GoBNOszTAR2eDUbFsPkwkPbee8skydcXNmkPOgAuAC0AeC1g3amamS1m
6ZQiqbS3ttYCEIVDWwjh8Agc2pZBFBpEom6OzSfXPHJNmUVC0AZjECQYZQYJRB0KQU15PkRP
fGIR3rnhDXvslqE8uqNrqp6XleyS3cc7Xo1sdfDqqphGCxcvu3s+ewE9xnRLHjvlKzcx+cn1
rSMfuWh4/OPeSj9dO5ULLafs7NtdKVMdfXQVOukKrzApn7I+ozzKorkA5FsQ2Z38yd66e+Yz
a6icd3YlzGNWoctfNh273S1vWZTLXw5NqIFYSgIJGFnYyr4BcEsrjQEyCSCIAGQIhiBS4Y+E
TSFiA9wB0VQdkzMaTs9TzcD9lry8sZBCrX3I76Ie/D7KiJraeWFJGDH4wPBHl05EiXgccoB2
OzxYwCGuPxjIfC63kHF+GajpnoHBk33Vzo8heiJL/27jCygcJJ+kCrJLTb4=
' | unpack
}
export -f $(compgen -A function | grep ^cpu)
test_one() {
eval $1 | head -n1
export PARALLEL_LSCPU="$(eval $1 | tail -n +2)"
echo $(parallel --number-of-sockets) \
$(parallel --number-of-cores) \
$(parallel --number-of-threads) \
$(parallel --number-of-cpus)
}
export -f test_one
compgen -A function | grep ^cpu | sort | parallel -j0 -k test_one
rm ~/.parallel/tmp/sshlogin/*/cpuspec 2>/dev/null
}
par_combineexec() { par_combineexec() {
combineexec() { combineexec() {

View file

@ -111,7 +111,7 @@ par_listproc() {
echo "### Test --listproc" echo "### Test --listproc"
sql --listproc :oraunittest | sql --listproc :oraunittest |
perl -ne '/select 1 from dual|user_objects|user_tablespaces|connect_by_filtering/ and next; perl -ne '/select 1 from dual|user_objects|user_tablespaces|connect_by_filtering/ and next;
s/[21 ]\.\d{5}/1.99999/; s/[21 ]\.\d{4,5}/1.99999/;
s/ +/ /g; s/ +/ /g;
print' print'
sql --listproc $MYSQL_TEST_DBURL | sql --listproc $MYSQL_TEST_DBURL |

View file

@ -672,6 +672,20 @@ par__test_cpu_detection_lscpu 1-8-8-8 Huawei P Smart Octa-core (4x2.36 GHz Corte
par__test_cpu_detection_lscpu 2 8 8 8 par__test_cpu_detection_lscpu 2 8 8 8
par__test_cpu_detection_lscpu 1-4-4-4 x96 quad-core Android TV-box par__test_cpu_detection_lscpu 1-4-4-4 x96 quad-core Android TV-box
par__test_cpu_detection_lscpu 1 1 1 1 par__test_cpu_detection_lscpu 1 1 1 1
par__test_cpu_detection_lscpu_--all_--extended 1-2-2-2 AMD Neo N36L Dual-Core Processor
par__test_cpu_detection_lscpu_--all_--extended 1 2 2 2
par__test_cpu_detection_lscpu_--all_--extended 1-2-4-2 ThinkPad A475 AMD PRO A12-8830B R7 (64g)
par__test_cpu_detection_lscpu_--all_--extended 1 2 4 2
par__test_cpu_detection_lscpu_--all_--extended 2-12-24-12 Intel(R) Xeon(R) CPU E5-2620 v3 @ 2.40GHz (kreta)
par__test_cpu_detection_lscpu_--all_--extended 2 12 24 12
par__test_cpu_detection_lscpu_--all_--extended 1-16-24-16 12900K https://stackoverflow.com/a/71282744/363028
par__test_cpu_detection_lscpu_--all_--extended 1 16 24 16
par__test_cpu_detection_lscpu_--all_--extended 1-14-20-14 https://github.com/nodejs/node/issues/52233#issuecomment-2023768771
par__test_cpu_detection_lscpu_--all_--extended 1 14 20 14
par__test_cpu_detection_lscpu_--all_--extended 1-24-32-24 https://in.mathworks.com/matlabcentral/answers/2100291-matlab-parallel-computing-beyond-8-cores-causing-os-to-crash#comment_3113976
par__test_cpu_detection_lscpu_--all_--extended 1 24 32 24
par__test_cpu_detection_lscpu_--all_--extended 1-2-4-2 Core i5-2410M laptop firewall
par__test_cpu_detection_lscpu_--all_--extended 1 2 4 2
par__test_cpu_detection_topology 4-64-64-64 Dell R815 4 CPU 64-core par__test_cpu_detection_topology 4-64-64-64 Dell R815 4 CPU 64-core
par__test_cpu_detection_topology 4 8 8 8 par__test_cpu_detection_topology 4 8 8 8
par__test_cpu_detection_topology 1-2-2-2 AMD Neo N36L Dual-Core Processor par__test_cpu_detection_topology 1-2-2-2 AMD Neo N36L Dual-Core Processor