-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcpusockets
More file actions
executable file
·31 lines (24 loc) · 1.05 KB
/
cpusockets
File metadata and controls
executable file
·31 lines (24 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/bin/bash
#
# cpusockets
usagestr="
$(basename $0)
Prints the number cpu sockets.
"
[ "$1" == "-h" ] && { echo "$usagestr"; exit 1; }
# check to see if this data exists.
cat /proc/cpuinfo | grep "physical id" >& /dev/null
[ $? -eq 1 ] && exit
num_sockets=$(cat /proc/cpuinfo | grep "physical id" | awk -F ":" ' { print $2 } ' | sort -u | wc -l)
#echo "number of sockets = $num_sockets"
# these two values are per socket
num_physical_cores=$(cat /proc/cpuinfo | grep -m 1 "cpu cores" | awk -F ":" ' { print $2 } ')
#echo "number of physical cores/socket = $num_physical_cores"
num_ht_threads=$(cat /proc/cpuinfo | grep -m 1 "siblings" | awk -F ":" ' { print $2 } ')
#echo "number of threads/socket = $num_ht_threads"
total_physical_cores=$(($num_physical_cores * $num_sockets))
total_ht_threads=$(($num_ht_threads * $num_sockets))
#echo "There are $num_sockets sockets with $total_physical_cores cores and $total_ht_threads threads."
echo $total_physical_cores
#echo "Using -j$total_physical_cores to compile"
#echo "%_smp_mflags -j$total_physical_cores" > ~/.rpmmacros