Makefile: Linux PowerPC (ppc64le) build support — -mcpu, scalar fallback, x86 path untouched (#97)

PowerPC GCC uses -mcpu instead of -march, so the Linux branch failed
with unrecognized option -march=native on ppc64le. Detect ppc64le and
ppc64 via uname -m and use -mcpu=$(ARCH) there. The x86-64 path is
unchanged.

Validated on an IBM POWER8 S824 (Ubuntu 20.04, gcc 9.4): make test-c
passes, teacher forcing 32/32 positions and greedy 20/20 tokens against
the transformers oracle, engine reports the scalar idot fallback.

Signed-off-by: Scott <scottbphone12@gmail.com>
Co-authored-by: Scott <scottbphone12@gmail.com>
This commit is contained in:
AutoJanitor
2026-07-12 15:13:32 -05:00
committed by GitHub
parent f1fbbca352
commit 6aaa8fc37a
+13
View File
@@ -33,6 +33,18 @@ CFLAGS = -D_FILE_OFFSET_BITS=64 -O3 -march=$(ARCH) -fopenmp -Wall -Wextra -Wno-
LDFLAGS = -lm -fopenmp -static LDFLAGS = -lm -fopenmp -static
EXE = .exe EXE = .exe
else else
UNAME_M := $(shell uname -m)
ifneq (,$(filter ppc64le ppc64,$(UNAME_M)))
# --- Linux PowerPC (POWER8/POWER9/POWER10) ---
# PowerPC GCC uses -mcpu, not -march. ARCH=native works on gcc >= 4.7.
# The AVX2/NEON kernels fall back to the portable scalar C path
# (validated token-exact vs the transformers oracle on a POWER8 S824).
CC = gcc
ARCH ?= native
CFLAGS = -O3 -mcpu=$(ARCH) -fopenmp -Wall -Wextra -Wno-unused-parameter -Wno-misleading-indentation -Wno-unused-function
LDFLAGS = -lm -fopenmp
EXE =
else
# --- Linux x86-64 (percorso originale, invariato) --- # --- Linux x86-64 (percorso originale, invariato) ---
CC = gcc CC = gcc
# ARCH=native -> ottimizzato per QUESTA macchina (default, piu' veloce). # ARCH=native -> ottimizzato per QUESTA macchina (default, piu' veloce).
@@ -43,6 +55,7 @@ CFLAGS = -O3 -march=$(ARCH) -fopenmp -Wall -Wextra -Wno-unused-parameter -Wno-m
LDFLAGS = -lm -fopenmp LDFLAGS = -lm -fopenmp
EXE = EXE =
endif endif
endif
# CUDA=1 adds an opt-in backend for resident tensors. The default build remains # CUDA=1 adds an opt-in backend for resident tensors. The default build remains
# pure C and keeps the original zero-dependency runtime. # pure C and keeps the original zero-dependency runtime.