fix AVX,AVX2,FMA,F16C detection on Linux and add flags for OpenBLAS

pull/179/head
katsu560 2 years ago committed by Georgi Gerganov
parent 83456076f0
commit 800ae5b808

@ -50,8 +50,8 @@ endif
# TODO: probably these flags need to be tweaked on some architectures # TODO: probably these flags need to be tweaked on some architectures
# feel free to update the Makefile for your architecture and send a pull request or issue # feel free to update the Makefile for your architecture and send a pull request or issue
ifeq ($(UNAME_M),x86_64) ifeq ($(UNAME_M),x86_64)
CFLAGS += -mfma -mf16c
ifeq ($(UNAME_S),Darwin) ifeq ($(UNAME_S),Darwin)
CFLAGS += -mfma -mf16c
AVX1_M := $(shell sysctl machdep.cpu.features) AVX1_M := $(shell sysctl machdep.cpu.features)
ifneq (,$(findstring AVX1.0,$(AVX1_M))) ifneq (,$(findstring AVX1.0,$(AVX1_M)))
CFLAGS += -mavx CFLAGS += -mavx
@ -60,8 +60,26 @@ ifeq ($(UNAME_M),x86_64)
ifneq (,$(findstring AVX2,$(AVX2_M))) ifneq (,$(findstring AVX2,$(AVX2_M)))
CFLAGS += -mavx2 CFLAGS += -mavx2
endif endif
endif
ifeq ($(UNAME_S),Linux)
AVX1_M := $(shell grep "avx " /proc/cpuinfo)
ifneq (,$(findstring avx,$(AVX1_M)))
CFLAGS += -mavx
endif
AVX2_M := $(shell grep "avx2 " /proc/cpuinfo)
ifneq (,$(findstring avx2,$(AVX2_M)))
CFLAGS += -mavx2
endif
FMA_M := $(shell grep "fma " /proc/cpuinfo)
ifneq (,$(findstring fma,$(FMA_M)))
CFLAGS += -mfma
endif
F16C_M := $(shell grep "f16c " /proc/cpuinfo)
ifneq (,$(findstring f16c,$(F16C_M)))
CFLAGS += -mf16c
endif
else else
CFLAGS += -mavx -mavx2 CFLAGS += -mfma -mf16c -mavx -mavx2
endif endif
endif endif
ifeq ($(UNAME_M),amd64) ifeq ($(UNAME_M),amd64)
@ -74,6 +92,10 @@ ifndef WHISPER_NO_ACCELERATE
LDFLAGS += -framework Accelerate LDFLAGS += -framework Accelerate
endif endif
endif endif
ifdef WHISPER_OPENBLAS
CFLAGS += -DGGML_USE_OPENBLAS -I/usr/local/include/openblas
LDFLAGS += -lopenblas
endif
ifneq ($(filter aarch64%,$(UNAME_M)),) ifneq ($(filter aarch64%,$(UNAME_M)),)
endif endif
ifneq ($(filter armv6%,$(UNAME_M)),) ifneq ($(filter armv6%,$(UNAME_M)),)

Loading…
Cancel
Save