From 800ae5b8086a72f3b5ffcc9b01bae7ac73e68544 Mon Sep 17 00:00:00 2001 From: katsu560 Date: Wed, 23 Nov 2022 20:23:35 +0900 Subject: [PATCH] fix AVX,AVX2,FMA,F16C detection on Linux and add flags for OpenBLAS --- Makefile | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 463864f..9c7c59b 100644 --- a/Makefile +++ b/Makefile @@ -50,8 +50,8 @@ endif # 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 ifeq ($(UNAME_M),x86_64) - CFLAGS += -mfma -mf16c ifeq ($(UNAME_S),Darwin) + CFLAGS += -mfma -mf16c AVX1_M := $(shell sysctl machdep.cpu.features) ifneq (,$(findstring AVX1.0,$(AVX1_M))) CFLAGS += -mavx @@ -60,8 +60,26 @@ ifeq ($(UNAME_M),x86_64) ifneq (,$(findstring AVX2,$(AVX2_M))) CFLAGS += -mavx2 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 - CFLAGS += -mavx -mavx2 + CFLAGS += -mfma -mf16c -mavx -mavx2 endif endif ifeq ($(UNAME_M),amd64) @@ -74,6 +92,10 @@ ifndef WHISPER_NO_ACCELERATE LDFLAGS += -framework Accelerate endif endif +ifdef WHISPER_OPENBLAS + CFLAGS += -DGGML_USE_OPENBLAS -I/usr/local/include/openblas + LDFLAGS += -lopenblas +endif ifneq ($(filter aarch64%,$(UNAME_M)),) endif ifneq ($(filter armv6%,$(UNAME_M)),)