Skip to content

Instantly share code, notes, and snippets.

@fakeboboliu
Last active May 2, 2022 08:25
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fakeboboliu/ecbedafdba0ce979d587b2e844111365 to your computer and use it in GitHub Desktop.
Save fakeboboliu/ecbedafdba0ce979d587b2e844111365 to your computer and use it in GitHub Desktop.
Which X86-64 Microarchitecture level should I use?
#!/bin/sh
if [ `lscpu|grep x86_64|wc -l` -ge 1 ]; then # v1 / baseline
if [ `lscpu|grep sse3|grep sse4_1|grep sse4_2|grep ssse3|grep popcnt|grep lahf|grep cx16|wc -l` -ge 1 ]; then # v2
if [ `lscpu|grep avx|grep avx2|grep bmi1|grep bmi2|grep f16c|grep fma|grep abm|grep movbe|grep xsave|wc -l` -ge 1 ]; then # v3
if [ `lscpu|grep avx512f|grep avx512bw|grep avx512cd|grep avx512dq|grep avx512vl|wc -l` -ge 1 ]; then # v4
echo "v4"
else echo "v3"; fi
else echo "v2"; fi
else echo "v1"; fi
else echo "none x86_64"; fi
@fakeboboliu
Copy link
Author

howto:
curl https://gist.githubusercontent.com/fakeboboliu/ecbedafdba0ce979d587b2e844111365/raw/62068ceff4a5b0285d1e6a03bb07807ae255861d/x86-64-level.sh | sh

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment