From f27fce8654a5b9c4de4cead3c10b81afe94e5291 Mon Sep 17 00:00:00 2001 From: MetaStrawman <136662325+MetaStrawman@users.noreply.github.com> Date: Sun, 1 Oct 2023 19:58:29 -0500 Subject: [PATCH] Update configure.sh --- configure.sh | 37 ++++++++++++++++++++++++++++++++++--- 1 file changed, 34 insertions(+), 3 deletions(-) diff --git a/configure.sh b/configure.sh index d7f7fa5f0a..e620406612 100755 --- a/configure.sh +++ b/configure.sh @@ -1,6 +1,37 @@ -# To change the cuda arch, edit Makefile.am and run ./build.sh +#!/bin/bash -extracflags="-march=native -D_REENTRANT -falign-functions=16 -falign-jumps=16 -falign-labels=16" +# Get CPU information +arch=$(lscpu | awk '/Architecture:/ { print $2 }') +model_name=$(lscpu | awk -F ': +' '/Model name:/ { print $2 }') -./configure CXXFLAGS="-O2 $extracflags" +# Common compiler flags +common_flags="-O3 -ffinite-loops -ffast-math -D_REENTRANT -finline-functions -falign-functions=16 -fomit-frame-pointer -fpic -pthread -flto -fuse-ld=lld -fno-stack-protector" +# Set architecture-specific flags +if [[ "$arch" == "aarch64" ]]; then + if [[ "$model_name" == *"Cortex-A53"* ]]; then + cpu_flags="-march=armv8-a+crypto -mtune=cortex-a53 -mfix-cortex-a53-835769" + elif [[ "$model_name" == *"Cortex-A73"* ]]; then + cpu_flags="-march=armv8-a+crypto -mtune=cortex-a73" + else + # Default to ARMv8-A architecture (Cortex-A53) if unknown + echo "Unknown or unsupported model: $model_name. Defaulting to ARMv8-A." + cpu_flags="-march=armv8-a+crypto -mtune=cortex-a53" + fi +else + # Default to ARMv8-A architecture (Cortex-A53) if unknown architecture + echo "Unknown or unsupported architecture: $arch. Defaulting to Native Tuning." + cpu_flags="-mtune=native" +fi + +# Set vectorization flags +vectorization_flags="-Rpass-missed=loop-vectorize -Rpass-analysis=loop-vectorize -Wl" + +# Combine all flags +all_flags="$common_flags $cpu_flags $vectorization_flags" + +# Configure and build +./configure --target=aarch64-linux-gnu --host=x86_64-linux-gnu --build=x86_64-linux-gnu \ + CXXFLAGS="-Wl,-hugetlbfs-align -funroll-loops -finline-functions $all_flags" \ +            CFLAGS="-Wl,-hugetlbfs-align -finline-functions $all_flags" \ +            CXX=clang++ CC=clang LDFLAGS="-v -flto -Wl,-hugetlbfs-align"