github.com/kelleygo/clashcore@v1.0.2/check_amd64.sh (about)

     1  #!/bin/sh
     2  flags=$(grep '^flags\b' </proc/cpuinfo | head -n 1)
     3  flags=" ${flags#*:} "
     4  
     5  has_flags () {
     6    for flag; do
     7      case "$flags" in
     8        *" $flag "*) :;;
     9        *) return 1;;
    10      esac
    11    done
    12  }
    13  
    14  determine_level () {
    15    level=0
    16    has_flags lm cmov cx8 fpu fxsr mmx syscall sse2 || return 0
    17    level=1
    18    has_flags cx16 lahf_lm popcnt sse4_1 sse4_2 ssse3 || return 0
    19    level=2
    20    has_flags avx avx2 bmi1 bmi2 f16c fma abm movbe xsave || return 0
    21    level=3
    22    has_flags avx512f avx512bw avx512cd avx512dq avx512vl || return 0
    23    level=4
    24  }
    25  
    26  determine_level
    27  echo "Your CPU supports amd64-v$level"
    28  return $level