Skip to content

Commit 6921a4a

Browse files
Optimized install script
1 parent 526b1eb commit 6921a4a

1 file changed

Lines changed: 39 additions & 0 deletions

File tree

install_optimized.sh

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
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 "$@"

0 commit comments

Comments
 (0)