omega-blas
aien-dev/omega-blas
Brought by drakestapleton
omega-blas / Makefile
| 1 | # omega-blas build. The compute unit om/blas.om is compiled by the pinned OM-2 omc and bound by |
| 2 | # omega-bridge tools/native (ABI v2); libomegablas.so links that binding with the interim C layer. |
| 3 | # make BRIDGE=<omega-bridge checkout> OMC=<seeded omc> OMC2=<OM-2 omc> |
| 4 | # make ... GB10=1 CUDAPP=<CUDApp checkout> the GB10 device path (README.md), into build-gb10/: |
| 5 | # links CUDApp's libomega_gpu.a, built position-independent into $(CUDAPP)/build/omegablas-pic |
| 6 | # Pins: see PINS (parent omega-mv sha, omc sha256s, omega-bridge sha, CUDApp sha). |
| 7 | BRIDGE ?= ../omega-bridge |
| 8 | OMC ?= $(error set OMC to the seeded omc (sha256 in PINS)) |
| 9 | OMC2 ?= $(error set OMC2 to the OM-2 omc (sha256 in PINS)) |
| 10 | CC ?= cc |
| 11 | CFLAGS ?= -O2 |
| 12 | GB10 ?= 0 |
| 13 | N := build/native |
| 14 | ifeq ($(GB10),1) |
| 15 | CUDAPP ?= $(error set CUDAPP to a CUDApp checkout (sha in PINS)) |
| 16 | B := build-gb10 |
| 17 | GPU_LIB := $(CUDAPP)/build/omegablas-pic/libomega_gpu.a |
| 18 | GPU_CFLAGS := -DOMB_GB10 -I$(CUDAPP)/src \ |
| 19 | -DOMB_CUDAPP_REV='"$(shell git -C $(CUDAPP) rev-parse HEAD)$(shell git -C $(CUDAPP) diff --quiet HEAD || echo -dirty)"' |
| 20 | GPU_LIBS := $(GPU_LIB) -lm |
| 21 | else |
| 22 | B := build |
| 23 | endif |
| 24 | |
| 25 | all: $(B)/libomegablas.so |
| 26 | |
| 27 | $(N)/omega_native.c: om/blas.om |
| 28 | OMEGA_NATIVE_OMC=$(OMC) OMEGA_NATIVE_OMC2=$(OMC2) $(BRIDGE)/tools/native $(N) om/blas.om |
| 29 | |
| 30 | $(B)/libomegablas.so: $(N)/omega_native.c src/omegablas.c include/omegablas.h $(GPU_LIB) |
| 31 | mkdir -p $(B) |
| 32 | $(CC) -std=gnu11 $(CFLAGS) -Wall -Wextra -Werror -fPIC -shared -Wl,-soname,libomegablas.so \ |
| 33 | -Iinclude -I$(N) -include $(N)/omega_native.h $(GPU_CFLAGS) -o $@ src/omegablas.c \ |
| 34 | $(N)/omega_native.c $(GPU_LIBS) -lpthread |
| 35 | |
| 36 | ifeq ($(GB10),1) |
| 37 | # CUDApp's own build with -fPIC added to the compiler; its CFLAGS, including the gemm_ex |
| 38 | # migration-pending switch of mk/gemm-ex.mk, stay as CUDApp sets them. |
| 39 | $(GPU_LIB): FORCE |
| 40 | $(MAKE) -C $(CUDAPP) OUT_DIR=build/omegablas-pic CC="$(CC) -fPIC" build/omegablas-pic/libomega_gpu.a |
| 41 | endif |
| 42 | |
| 43 | clean: |
| 44 | rm -rf build build-gb10 |
| 45 | |
| 46 | .PHONY: all clean FORCE |