katsu560 commited on
Commit
7dc7c48
·
1 Parent(s): 00ac035

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

Browse files
Files changed (1) hide show
  1. Makefile +24 -2
Makefile CHANGED
@@ -50,8 +50,8 @@ endif
50
  # TODO: probably these flags need to be tweaked on some architectures
51
  # feel free to update the Makefile for your architecture and send a pull request or issue
52
  ifeq ($(UNAME_M),x86_64)
53
- CFLAGS += -mfma -mf16c
54
  ifeq ($(UNAME_S),Darwin)
 
55
  AVX1_M := $(shell sysctl machdep.cpu.features)
56
  ifneq (,$(findstring AVX1.0,$(AVX1_M)))
57
  CFLAGS += -mavx
@@ -60,8 +60,26 @@ ifeq ($(UNAME_M),x86_64)
60
  ifneq (,$(findstring AVX2,$(AVX2_M)))
61
  CFLAGS += -mavx2
62
  endif
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
63
  else
64
- CFLAGS += -mavx -mavx2
65
  endif
66
  endif
67
  ifeq ($(UNAME_M),amd64)
@@ -74,6 +92,10 @@ ifndef WHISPER_NO_ACCELERATE
74
  LDFLAGS += -framework Accelerate
75
  endif
76
  endif
 
 
 
 
77
  ifneq ($(filter aarch64%,$(UNAME_M)),)
78
  endif
79
  ifneq ($(filter armv6%,$(UNAME_M)),)
 
50
  # TODO: probably these flags need to be tweaked on some architectures
51
  # feel free to update the Makefile for your architecture and send a pull request or issue
52
  ifeq ($(UNAME_M),x86_64)
 
53
  ifeq ($(UNAME_S),Darwin)
54
+ CFLAGS += -mfma -mf16c
55
  AVX1_M := $(shell sysctl machdep.cpu.features)
56
  ifneq (,$(findstring AVX1.0,$(AVX1_M)))
57
  CFLAGS += -mavx
 
60
  ifneq (,$(findstring AVX2,$(AVX2_M)))
61
  CFLAGS += -mavx2
62
  endif
63
+ endif
64
+ ifeq ($(UNAME_S),Linux)
65
+ AVX1_M := $(shell grep "avx " /proc/cpuinfo)
66
+ ifneq (,$(findstring avx,$(AVX1_M)))
67
+ CFLAGS += -mavx
68
+ endif
69
+ AVX2_M := $(shell grep "avx2 " /proc/cpuinfo)
70
+ ifneq (,$(findstring avx2,$(AVX2_M)))
71
+ CFLAGS += -mavx2
72
+ endif
73
+ FMA_M := $(shell grep "fma " /proc/cpuinfo)
74
+ ifneq (,$(findstring fma,$(FMA_M)))
75
+ CFLAGS += -mfma
76
+ endif
77
+ F16C_M := $(shell grep "f16c " /proc/cpuinfo)
78
+ ifneq (,$(findstring f16c,$(F16C_M)))
79
+ CFLAGS += -mf16c
80
+ endif
81
  else
82
+ CFLAGS += -mfma -mf16c -mavx -mavx2
83
  endif
84
  endif
85
  ifeq ($(UNAME_M),amd64)
 
92
  LDFLAGS += -framework Accelerate
93
  endif
94
  endif
95
+ ifdef WHISPER_OPENBLAS
96
+ CFLAGS += -DGGML_USE_OPENBLAS -I/usr/local/include/openblas
97
+ LDFLAGS += -lopenblas
98
+ endif
99
  ifneq ($(filter aarch64%,$(UNAME_M)),)
100
  endif
101
  ifneq ($(filter armv6%,$(UNAME_M)),)