diff options
Diffstat (limited to 'auto-cpu-optimization.sh')
-rwxr-xr-x | auto-cpu-optimization.sh | 80 |
1 files changed, 41 insertions, 39 deletions
diff --git a/auto-cpu-optimization.sh b/auto-cpu-optimization.sh index 4903a69d15d7..4c4b20ea68fb 100755 --- a/auto-cpu-optimization.sh +++ b/auto-cpu-optimization.sh @@ -1,49 +1,51 @@ #!/bin/bash -CPU=$(gcc -Q -march=native --help=target|grep march=|awk '{print $2}'|head -1) -MARCH=$(echo $CPU|tr '[:lower:]' '[:upper:]'&&echo) -if [[ ${MARCH} == "ZNVER1" ]]; then - MARCH="ZEN" -elif [[ ${MARCH} == "ZNVER2" ]]; then - MARCH="ZEN2" -elif [[ ${MARCH} == "ZNVER3" ]]; then - MARCH="ZEN3" -elif [[ ${MARCH} == "ZNVER4" ]]; then - MARCH="ZEN4" -elif [[ ${MARCH} == "BDVER1" ]]; then - MARCH="BULLDOZER" -elif [[ ${MARCH} == "BDVER2" ]]; then - MARCH="PILEDRIVER" -elif [[ ${MARCH} == "BDVER3" ]]; then - MARCH="STEAMROLLER" -elif [[ ${MARCH} == "BDVER4" ]]; then - MARCH="EXCAVATOR" -elif [[ ${MARCH} == "BTVER1" ]]; then - MARCH="BOBCAT" -elif [[ ${MARCH} == "BTVER2" ]]; then - MARCH="JAGUAR" -elif [[ ${MARCH} == "AMDFAM10" ]]; then - MARCH="MK10" -elif [[ ${MARCH} == "K8-SSE3" ]]; then - MARCH="K8SSE3" -elif [[ ${MARCH} == "BONNELL" ]]; then - MARCH="ATOM" -elif [[ ${MARCH} == "GOLDMONT-PLUS" ]]; then - MARCH="GOLDMONTPLUS" -elif [[ ${MARCH} == "SKYLAKE-AVX512" ]]; then - MARCH="SKYLAKE2" -elif [[ ${MARCH} == "MIVYBRIDGE" ]]; then + +# Check if GCC is installed +check_gcc() { + if ! [ -x "$(command -v gcc)" ]; then + # Display error message if GCC is not installed + echo "Error: GCC is not installed. Please install GCC and try again." >&2 + exit 1 + fi +} + +# Call the function before running the rest of the script +check_gcc + +# Get CPU type from GCC and convert to uppercase +MARCH=$(gcc -Q -march=native --help=target|grep -m1 march=|awk '{print toupper($2)}') + +# Check for specific CPU types and set MARCH variable accordingly +case $MARCH in + ZNVER1) MARCH="ZEN";; + ZNVER2) MARCH="ZEN2";; + ZNVER3) MARCH="ZEN3";; + ZNVER4) MARCH="ZEN4";; + BDVER1) MARCH="BULLDOZER";; + BDVER2) MARCH="PILEDRIVER";; + BDVER3) MARCH="STEAMROLLER";; + BDVER4) MARCH="EXCAVATOR";; + BTVER1) MARCH="BOBCAT";; + BTVER2) MARCH="JAGUAR";; + AMDFAM10) MARCH="MK10";; + K8-SSE3) MARCH="K8SSE3";; + BONNELL) MARCH="ATOM";; + GOLDMONT-PLUS) MARCH="GOLDMONTPLUS";; + SKYLAKE-AVX512) MARCH="SKYLAKE2";; + MIVYBRIDGE) scripts/config --disable CONFIG_AGP_AMD64 scripts/config --disable CONFIG_MICROCODE_AMD - MARCH="MIVYBRIDGE" -elif [[ ${MARCH} == "ICELAKE-CLIENT" ]]; then - MARCH="ICELAKE" -fi + MARCH="MIVYBRIDGE";; + ICELAKE-CLIENT) MARCH="ICELAKE";; +esac + +# Add "M" prefix to MARCH variable MARCH2=M${MARCH} -echo + +# Display detected CPU and apply optimization echo "----------------------------------" echo "| APPLYING AUTO-CPU-OPTIMIZATION |" echo "----------------------------------" echo "[*] DETECTED CPU (MARCH) : ${MARCH2}" scripts/config -k --disable CONFIG_GENERIC_CPU scripts/config -k --enable CONFIG_${MARCH2} -sleep 3&&echo |