mirror of
https://github.com/Alex313031/thorium.git
synced 2025-01-09 03:07:48 -03:00
update simd script
This commit is contained in:
parent
b4342767b0
commit
d10a7d3d79
1 changed files with 35 additions and 15 deletions
|
@ -1,6 +1,6 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# Copyright (c) 2023 Alex313031.
|
# Copyright (c) 2024 Alex313031.
|
||||||
|
|
||||||
program="Thorium Browser." # The program we are checking for.
|
program="Thorium Browser." # The program we are checking for.
|
||||||
|
|
||||||
|
@ -19,11 +19,13 @@ try() { "$@" || die "${RED}Failed $*"; }
|
||||||
|
|
||||||
script_name=${0##*/}
|
script_name=${0##*/}
|
||||||
|
|
||||||
|
clear &&
|
||||||
|
|
||||||
check_result() { # Message calls
|
check_result() { # Message calls
|
||||||
local ret="$1"
|
local ret="$1"
|
||||||
local msg="$2"
|
local msg="$2"
|
||||||
[ "$ret" -ne 0 ] && { printf "${RED}FAIL:" && tput sgr0 && echo " $msg"; }
|
[ "$ret" -ne 0 ] && { printf " ${RED}FAIL:" && tput sgr0 && echo " $msg"; }
|
||||||
printf "${GRE}SUCCESS:" && tput sgr0 && echo " $msg"
|
printf " ${GRE}SUCCESS:" && tput sgr0 && echo " $msg"
|
||||||
}
|
}
|
||||||
|
|
||||||
get_cpuinfo() { # return details of the first CPU only
|
get_cpuinfo() { # return details of the first CPU only
|
||||||
|
@ -35,6 +37,22 @@ have_cpu_feature() {
|
||||||
get_cpuinfo | egrep -q "^flags.*\<$feature\>"
|
get_cpuinfo | egrep -q "^flags.*\<$feature\>"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
have_64bit_cpu() {
|
||||||
|
local feature="lm" # "Long mode"
|
||||||
|
local desc="64-bit x86 CPU"
|
||||||
|
local need="$desc ($feature)"
|
||||||
|
have_cpu_feature "$feature"
|
||||||
|
check_result "$?" "$need"
|
||||||
|
}
|
||||||
|
|
||||||
|
have_sse2_cpu_feature () {
|
||||||
|
local feature="sse2"
|
||||||
|
local desc="Streaming SIMD Extensions 2"
|
||||||
|
local need="$desc ($feature)"
|
||||||
|
have_cpu_feature "$feature"
|
||||||
|
check_result "$?" "$need"
|
||||||
|
}
|
||||||
|
|
||||||
have_sse3_cpu_feature () {
|
have_sse3_cpu_feature () {
|
||||||
local feature="pni"
|
local feature="pni"
|
||||||
local desc="Streaming SIMD Extensions 3"
|
local desc="Streaming SIMD Extensions 3"
|
||||||
|
@ -51,6 +69,14 @@ have_sse41_cpu_feature () {
|
||||||
check_result "$?" "$need"
|
check_result "$?" "$need"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
have_sse42_cpu_feature () {
|
||||||
|
local feature="sse4_2"
|
||||||
|
local desc="Streaming SIMD Extensions 4.2"
|
||||||
|
local need="$desc ($feature)"
|
||||||
|
have_cpu_feature "$feature"
|
||||||
|
check_result "$?" "$need"
|
||||||
|
}
|
||||||
|
|
||||||
have_aes_cpu_feature () {
|
have_aes_cpu_feature () {
|
||||||
local feature="aes"
|
local feature="aes"
|
||||||
local desc="Advanced Encryption Standard Extensions"
|
local desc="Advanced Encryption Standard Extensions"
|
||||||
|
@ -75,29 +101,23 @@ have_avx2_cpu_feature () {
|
||||||
check_result "$?" "$need"
|
check_result "$?" "$need"
|
||||||
}
|
}
|
||||||
|
|
||||||
have_64bit_cpu() {
|
|
||||||
local feature="lm" # "Long mode"
|
|
||||||
local desc="64-bit x86 CPU"
|
|
||||||
local need="$desc ($feature)"
|
|
||||||
have_cpu_feature "$feature"
|
|
||||||
check_result "$?" "$need"
|
|
||||||
}
|
|
||||||
|
|
||||||
common_checks() {
|
common_checks() {
|
||||||
have_64bit_cpu && have_sse3_cpu_feature && have_sse41_cpu_feature && \
|
have_64bit_cpu && have_sse2_cpu_feature && have_sse3_cpu_feature && have_sse41_cpu_feature && \
|
||||||
have_aes_cpu_feature && have_avx_cpu_feature && have_avx2_cpu_feature
|
have_sse42_cpu_feature && have_aes_cpu_feature && have_avx_cpu_feature && have_avx2_cpu_feature
|
||||||
}
|
}
|
||||||
|
|
||||||
check_host() {
|
check_host() {
|
||||||
printf "\n" &&
|
printf "\n" &&
|
||||||
printf "${YEL}Checking if host is capable of building/running $program\n" && tput sgr0; echo
|
printf " ${YEL}Checking host CPU instruction extensions...${c0}\n"; echo
|
||||||
common_checks
|
common_checks
|
||||||
|
printf "\n" &&
|
||||||
|
printf " ${YEL}If your CPU has AVX, you can build/run $program${c0}\n" && tput sgr0;
|
||||||
}
|
}
|
||||||
|
|
||||||
main() {
|
main() {
|
||||||
case "$1" in
|
case "$1" in
|
||||||
host) check_host ;;
|
host) check_host ;;
|
||||||
*) printf "${RED}ERROR: Invalid type specified: '$1'\n" 2>&1 && tput sgr0; exit 1 ;;
|
*) printf " ${RED}ERROR: Invalid type specified: '$1'\n" 2>&1 && tput sgr0; exit 1 ;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue