Define BLAS variables in Makefile

makes it a little easier to change the BLAS library used,
doesn't hardcode the mingw headers. Works on Linux with openblas installed.
Should be no change on Windows.
This commit is contained in:
Joost VandeVondele
2020-09-06 21:46:08 +02:00
committed by nodchip
parent 3bf418e63f
commit 3a06de298b
+22 -13
View File
@@ -28,6 +28,21 @@ else
EXE = stockfish EXE = stockfish
endif endif
### Establish the operating system name
KERNEL = $(shell uname -s)
ifeq ($(KERNEL),Linux)
OS = $(shell uname -o)
endif
### BLAS libraries
ifeq ($(KERNEL),Linux)
BLASCXXFLAGS =
BLASLDFLAGS = -lopenblas
else
BLASCXXFLAGS = -I/mingw64/include/OpenBLAS
BLASLDFLAGS = -lopenblas -Wl,-s -static
endif
### Installation dir definitions ### Installation dir definitions
PREFIX = /usr/local PREFIX = /usr/local
BINDIR = $(PREFIX)/bin BINDIR = $(PREFIX)/bin
@@ -61,12 +76,6 @@ OBJS = $(notdir $(SRCS:.cpp=.o))
VPATH = syzygy:nnue:nnue/features:eval:extra:learn VPATH = syzygy:nnue:nnue/features:eval:extra:learn
### Establish the operating system name
KERNEL = $(shell uname -s)
ifeq ($(KERNEL),Linux)
OS = $(shell uname -o)
endif
### ========================================================================== ### ==========================================================================
### Section 2. High-level Configuration ### Section 2. High-level Configuration
### ========================================================================== ### ==========================================================================
@@ -308,7 +317,7 @@ endif
### ========================================================================== ### ==========================================================================
### 3.1 Selecting compiler (default = gcc) ### 3.1 Selecting compiler (default = gcc)
CXXFLAGS += -Wall -Wcast-qual -fno-exceptions -std=c++17 $(EXTRACXXFLAGS) $(LEARNCXXFLAGS) CXXFLAGS += -g -Wall -Wcast-qual -fno-exceptions -std=c++17 $(EXTRACXXFLAGS) $(LEARNCXXFLAGS)
DEPENDFLAGS += -std=c++17 DEPENDFLAGS += -std=c++17
LDFLAGS += $(EXTRALDFLAGS) $(LEARNLDFLAGS) LDFLAGS += $(EXTRALDFLAGS) $(LEARNLDFLAGS)
@@ -890,16 +899,16 @@ icc-profile-use:
learn: config-sanity learn: config-sanity
$(MAKE) ARCH=$(ARCH) COMP=$(COMP) \ $(MAKE) ARCH=$(ARCH) COMP=$(COMP) \
EXTRACXXFLAGS=' -DEVAL_LEARN -DEVAL_NNUE -DENABLE_TEST_CMD -DUSE_BLAS -I/mingw64/include/OpenBLAS -fopenmp ' \ EXTRACXXFLAGS=' -DEVAL_LEARN -DEVAL_NNUE -DENABLE_TEST_CMD -DUSE_BLAS $(BLASCXXFLAGS) -fopenmp ' \
EXTRALDFLAGS=' -lopenblas -fopenmp -Wl,-s -static ' \ EXTRALDFLAGS=' $(BLASLDFLAGS) -fopenmp ' \
all all
profile-learn: config-sanity objclean profileclean profile-learn: config-sanity objclean profileclean
@echo "" @echo ""
@echo "Step 1/4. Building instrumented executable ..." @echo "Step 1/4. Building instrumented executable ..."
$(MAKE) ARCH=$(ARCH) COMP=$(COMP) $(profile_make) \ $(MAKE) ARCH=$(ARCH) COMP=$(COMP) $(profile_make) \
LEARNCXXFLAGS=' -DEVAL_LEARN -DEVAL_NNUE -DENABLE_TEST_CMD -DUSE_BLAS -I/mingw64/include/OpenBLAS -fopenmp ' \ LEARNCXXFLAGS=' -DEVAL_LEARN -DEVAL_NNUE -DENABLE_TEST_CMD -DUSE_BLAS $(BLASCXXFLAGS) -fopenmp ' \
LEARNLDFLAGS=' -lopenblas -fopenmp -Wl,-s -static ' LEARNLDFLAGS=' $(BLASLDLAGS) -fopenmp '
@echo "" @echo ""
@echo "Step 2/4. Running benchmark for pgo-build ..." @echo "Step 2/4. Running benchmark for pgo-build ..."
$(PGOGENSFEN) $(PGOGENSFEN)
@@ -907,8 +916,8 @@ profile-learn: config-sanity objclean profileclean
@echo "Step 3/4. Building optimized executable ..." @echo "Step 3/4. Building optimized executable ..."
$(MAKE) ARCH=$(ARCH) COMP=$(COMP) objclean $(MAKE) ARCH=$(ARCH) COMP=$(COMP) objclean
$(MAKE) ARCH=$(ARCH) COMP=$(COMP) $(profile_use) \ $(MAKE) ARCH=$(ARCH) COMP=$(COMP) $(profile_use) \
LEARNCXXFLAGS=' -DEVAL_LEARN -DEVAL_NNUE -DENABLE_TEST_CMD -DUSE_BLAS -I/mingw64/include/OpenBLAS -fopenmp ' \ LEARNCXXFLAGS=' -DEVAL_LEARN -DEVAL_NNUE -DENABLE_TEST_CMD -DUSE_BLAS $(BLASCXXFLAGS) -fopenmp ' \
LEARNLDFLAGS=' -lopenblas -fopenmp -Wl,-s -static ' LEARNLDFLAGS=' $(BLASLDFLAGS) -fopenmp '
@echo "" @echo ""
@echo "Step 4/4. Deleting profile data ..." @echo "Step 4/4. Deleting profile data ..."
$(MAKE) ARCH=$(ARCH) COMP=$(COMP) profileclean $(MAKE) ARCH=$(ARCH) COMP=$(COMP) profileclean