aboutsummarylogtreecommitdiffstats
path: root/PKGBUILD
diff options
context:
space:
mode:
authorMark Peschel2023-07-05 20:43:36 -0400
committerMark Peschel2023-07-05 20:43:36 -0400
commit208fe6fd676a578a6775f4f5ffd91f1a3b0bf44a (patch)
tree62f49f4571dad77e939288beae37ab6e357ca8da /PKGBUILD
parent94215e2d1eea277aebb6543ec1a53304fd70c080 (diff)
downloadaur-208fe6fd676a578a6775f4f5ffd91f1a3b0bf44a.tar.gz
Assign "build optimized" automagically
Diffstat (limited to 'PKGBUILD')
-rw-r--r--PKGBUILD19
1 files changed, 17 insertions, 2 deletions
diff --git a/PKGBUILD b/PKGBUILD
index f1b42b18c5f7..19b3468d83e0 100644
--- a/PKGBUILD
+++ b/PKGBUILD
@@ -8,8 +8,23 @@
# Contributor: Thibault Lorrain (fredszaq) <fredszaq@gmail.com>
pkgbase=tensorflow-amd-git
-_build_no_opt=1
-_build_opt=0
+_build_no_opt=auto
+_build_opt=auto
+
+_is_haswell() {
+ [[ " haswell broadwell skylake knl knm skylake-avx512 cannonlake icelake-client icelake-server cascadelake cooperlake tigerlake sapphirerapids rocketlake graniterapids " == *" $1 "* ]] && return 0 || return 1
+}
+
+_get_march() {
+ gcc -march=native -Q --help=target | sed -En "s/^ +-march=[ \t]+([^ ]+)/\1/p"
+}
+
+if [ "$_build_no_opt" == "auto" ]; then
+ _is_haswell `_get_march` && _build_no_opt=0 || _build_no_opt=1
+fi
+if [ "$_build_opt" == "auto" ]; then
+ _is_haswell `_get_march` && _build_opt=1 || _build_opt=0
+fi
[ "$_build_no_opt" -eq 1 ] && pkgname+=(tensorflow-amd-git python-tensorflow-amd-git)
[ "$_build_opt" -eq 1 ] && pkgname+=(tensorflow-opt-amd-git python-tensorflow-opt-amd-git)