Page 1 of 1

Linux x86-64-v2 CPU compatibility check

Posted: 2025 Feb 16, 19:51
by serveroffer
How to check if your Linux system CPU does support x86-64-v2?
Open nano:

Code: Select all

nano check_cpu

Paste code:

Code: Select all

#!/bin/sh -eu

flags=$(cat /proc/cpuinfo | grep flags | head -n 1 | cut -d: -f2)

supports_v2='awk "/cx16/&&/lahf/&&/popcnt/&&/sse4_1/&&/sse4_2/&&/ssse3/ {found=1} END {exit !found}"'
supports_v3='awk "/avx/&&/avx2/&&/bmi1/&&/bmi2/&&/f16c/&&/fma/&&/abm/&&/movbe/&&/xsave/ {found=1} END {exit !found}"'
supports_v4='awk "/avx512f/&&/avx512bw/&&/avx512cd/&&/avx512dq/&&/avx512vl/ {found=1} END {exit !found}"'

echo "$flags" | eval $supports_v2 || exit 2 && echo "CPU supports x86-64-v2"
echo "$flags" | eval $supports_v3 || exit 3 && echo "CPU supports x86-64-v3"
echo "$flags" | eval $supports_v4 || exit 4 && echo "CPU supports x86-64-v4"

Exit nano and save CTRL+x -> yes
Make file executable:

Code: Select all

chmod +x check_cpu

Run script:

Code: Select all

./check_cpu

Information message will be shown. If there is no message, system CPU does not support x86-64-v2.