Skip to content

Commit 8724503

Browse files
ppigazziniDisservin
authored andcommitted
Simplify the code to get the native flags
closes official-stockfish#4908 No functional change
1 parent 53ad6d2 commit 8724503

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

scripts/get_native_properties.sh

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,9 @@ check_flags() {
1414
}
1515

1616
# Set the CPU flags list
17+
# remove underscores and points from flags, e.g. gcc uses avx512vnni, while some cpuinfo can have avx512_vnni, some systems use sse4_1 others sse4.1
1718
get_flags() {
18-
flags="$(awk '/^flags[ \t]*:/{gsub(/^flags[ \t]*:[ \t]*/, ""); line=$0} END{print line}' /proc/cpuinfo) $(awk '/^Features[ \t]*:/{gsub(/^Features[ \t]*:[ \t]*/, ""); line=$0} END{print line}' /proc/cpuinfo)"
19-
# remove underscores and points from flags, e.g. gcc uses avx512vnni, while some cpuinfo can have avx512_vnni, some systems use sse4_1 others sse4.1
20-
flags=$(printf '%s' "$flags" | sed "s/[_.]//g")
19+
flags=$(awk '/^flags[ \t]*:|^Features[ \t]*:/{gsub(/^flags[ \t]*:[ \t]*|^Features[ \t]*:[ \t]*|[_.]/, ""); line=$0} END{print line}' /proc/cpuinfo)
2120
}
2221

2322
# Check for gcc march "znver1" or "znver2" https://en.wikichip.org/wiki/amd/cpuid
@@ -55,7 +54,7 @@ case $uname_s in
5554
file_arch='x86-64-sse41-popcnt' # Supported by Rosetta 2
5655
;;
5756
'x86_64')
58-
flags=$(sysctl -n machdep.cpu.features machdep.cpu.leaf7_features | tr '\n' ' ' | tr '[:upper:]' '[:lower:]' | sed "s/[_.]//g")
57+
flags=$(sysctl -n machdep.cpu.features machdep.cpu.leaf7_features | tr '\n' ' ' | tr '[:upper:]' '[:lower:]' | tr -d '_.')
5958
set_arch_x86_64
6059
if [ "$true_arch" = 'x86-64-vnni256' ] || [ "$true_arch" = 'x86-64-avx512' ]; then
6160
file_arch='x86-64-bmi2'

0 commit comments

Comments
 (0)