Skip to content

Commit ab1aa6b

Browse files
committed
docker: AVX-512 pinned Dockerfile for server/Railway deployment
target-cpu=x86-64-v4: native AVX-512, all SIMD inlined, no LazyLock overhead. ~24% faster than portable build. ONLY for AVX-512 hardware. Select Dockerfile.avx512 in Railway dashboard for server deployment. Default Dockerfile stays portable (AVX2 CI, LazyLock dispatch). https://claude.ai/code/session_01ChLvBfpJS8dQhHxRD4pYNp
1 parent 9ab9507 commit ab1aa6b

1 file changed

Lines changed: 41 additions & 0 deletions

File tree

Dockerfile.avx512

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# ndarray — AVX-512 pinned build (server/Railway)
2+
# target-cpu=x86-64-v4: native AVX-512, all SIMD inlined, no LazyLock dispatch.
3+
# ~24% faster than portable build (780 vs 630 on L1 kernel benchmarks).
4+
#
5+
# ONLY deploy on AVX-512 hardware (Skylake-X, Ice Lake, Sapphire Rapids, EPYC Genoa).
6+
# Will SIGILL on older CPUs.
7+
#
8+
# Build: docker build -f Dockerfile.avx512 -t ndarray-avx512 .
9+
# Run: docker run --rm ndarray-avx512
10+
11+
FROM debian:bookworm-slim AS builder
12+
13+
RUN apt-get update && apt-get install -y --no-install-recommends \
14+
curl ca-certificates gcc libc6-dev pkg-config libssl-dev \
15+
&& rm -rf /var/lib/apt/lists/*
16+
17+
ENV RUSTUP_HOME=/usr/local/rustup \
18+
CARGO_HOME=/usr/local/cargo \
19+
PATH=/usr/local/cargo/bin:$PATH
20+
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | \
21+
sh -s -- -y --default-toolchain 1.94.0 --profile minimal \
22+
&& rustc --version | grep -q "1.94.0"
23+
24+
WORKDIR /app
25+
26+
COPY Cargo.toml Cargo.lock ./
27+
COPY ndarray-rand/Cargo.toml ndarray-rand/Cargo.toml
28+
COPY crates/ crates/
29+
COPY src/ src/
30+
COPY ndarray-rand/src/ ndarray-rand/src/
31+
32+
# AVX-512 pinned: compile-time dispatch, everything inlined
33+
ENV RUSTFLAGS="-C target-cpu=x86-64-v4"
34+
35+
RUN cargo build --release 2>&1 && echo "=== AVX-512 BUILD OK ==="
36+
RUN cargo build --release --features jit-native 2>&1 && echo "=== AVX-512 JIT BUILD OK ==="
37+
RUN cargo test --release --lib -- hpc:: 2>&1 && echo "=== AVX-512 HPC TESTS OK ==="
38+
39+
FROM debian:bookworm-slim
40+
COPY --from=builder /app/target/release/libndarray.rlib /usr/local/lib/
41+
CMD ["echo", "ndarray AVX-512 build verified — Rust 1.94.0, target-cpu=x86-64-v4"]

0 commit comments

Comments
 (0)