]> git.djapps.eu Git - pkg/ggml/sources/whisper.cpp/commitdiff
fix AVX,AVX2,FMA,F16C detection on Linux and add flags for OpenBLAS
authorkatsu560 <redacted>
Wed, 23 Nov 2022 11:23:35 +0000 (20:23 +0900)
committerGeorgi Gerganov <redacted>
Wed, 23 Nov 2022 20:16:33 +0000 (22:16 +0200)
Makefile

index 463864f0c33f932c1be67e4f3f0f2c7dc23c60a6..9c7c59b4b22c825b2059be4da7c2bc97e2ba809c 100644 (file)
--- 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)),)