File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ #! /usr/bin/env bash
2+ set -euo pipefail
3+
4+ # Optimized (non-portable) build for local x86_64 Linux hosts.
5+ # Uses native CPU tuning, IPO/LTO, and optional OpenMP runtime override.
6+ # Usage: ./install_optimized.sh [pip args...]
7+
8+ here=" $( cd " $( dirname " ${BASH_SOURCE[0]} " ) " && pwd) "
9+ cd " $here "
10+
11+ os=" $( uname -s) "
12+ arch=" $( uname -m) "
13+
14+ if [[ " $os " == " Darwin" ]]; then
15+ echo " [INFO] macOS detected; the default portable build is already optimized for Apple targets."
16+ echo " [INFO] Run 'pip install .' directly or set CMAKE_ARGS manually if you want to experiment."
17+ python -m pip install " $@ "
18+ exit 0
19+ fi
20+
21+ if [[ " $arch " != " x86_64" && " $arch " != " amd64" ]]; then
22+ echo " [WARN] Non-x86_64 architecture ($arch ) detected; skipping native flags. Running portable build."
23+ python -m pip install " $@ "
24+ exit 0
25+ fi
26+
27+ native_cxxflags=" -march=native -mtune=native -O3 -ffp-contract=fast -funroll-loops -fomit-frame-pointer -fno-strict-aliasing"
28+ runtime=" ${ACTIONET_OPENMP_RUNTIME:- AUTO} " # set to INTEL/GNU/LLVM to force, otherwise auto
29+
30+ cmake_args=" -DCMAKE_CXX_FLAGS='${native_cxxflags} ' -DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON"
31+ if [[ " $runtime " != " AUTO" ]]; then
32+ cmake_args+=" -DLIBACTIONET_OPENMP_RUNTIME=${runtime} "
33+ fi
34+
35+ export CMAKE_ARGS=" ${CMAKE_ARGS:- } ${cmake_args} "
36+
37+ echo " [INFO] Using CMAKE_ARGS=${CMAKE_ARGS} "
38+ echo " [INFO] Invoking pip install with optimized flags..."
39+ python -m pip install " $@ "
You can’t perform that action at this time.
0 commit comments