Skip to content

Instantly share code, notes, and snippets.

@ValentinColin
Created September 30, 2021 09:49
Show Gist options
  • Save ValentinColin/964f2801fe137b4805ec3e84e00e4484 to your computer and use it in GitHub Desktop.
Save ValentinColin/964f2801fe137b4805ec3e84e00e4484 to your computer and use it in GitHub Desktop.
A short script to detect the features of the current device (OS, CPU features, CPU flags)
#!/bin/bash
OS=$(uname -s)
#CPU flag detection
echo "****Getting CPU flag capabilities and number of cores"
if [ "$OS" = "Linux" ]; then
cat /proc/cpuinfo | egrep "(flags|model name|vendor)" | sort | uniq -c
elif [ "$OS" = "Darwin" ]; then
sysctl -a | grep machdep.cpu.features
fi
#Compiler capabilities. -march=native is required!
echo "****Getting GCC capabilities (SSE|AVX)"
gcc -march=native -dM -E - < /dev/null | egrep "SSE|AVX" | sort
#OS kernel version
echo "****Getting OS Kernel Version"
uname -a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment