mirror of
https://github.com/ggerganov/whisper.cpp.git
synced 2024-12-27 09:08:55 +01:00
make : improve cpuinfo handling on x86 hosts (#1238)
* make : simplify and correct x86 ISA extensions detection on the host It got broken in commitc5f9acf4b7
for Haiku and Mac OS (Intel), which report CPU features in upper case. Now we're finding the names in case-insensitive manner and as words. SSE3 detection has been corrected for Linux, which uses PNI for that (Prescott New Instructions). * make : use dmesg.boot in FreeBSD/DragonFlyBSD to detect x86 ISA extensions on the host * make : enable x86 ISA extensions on the host both in CFLAGS and CXXFLAGS * make : correct AVX x86 ISA extension detection on macOS (Intel) host It got broken in commitc5f9acf4b7
. macOS calls it AVX1.0.
This commit is contained in:
parent
59a3d0cb57
commit
ba3c333611
60
Makefile
60
Makefile
@ -65,57 +65,57 @@ endif
|
|||||||
# Architecture specific
|
# Architecture specific
|
||||||
# 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),$(filter $(UNAME_M),x86_64 i686))
|
ifeq ($(UNAME_M),$(filter $(UNAME_M),x86_64 i686 amd64))
|
||||||
ifeq ($(UNAME_S),Darwin)
|
ifeq ($(UNAME_S),Darwin)
|
||||||
CPUINFO_CMD := sysctl machdep.cpu.features
|
CPUINFO_CMD := sysctl machdep.cpu.features
|
||||||
else ifeq ($(UNAME_S),Linux)
|
else ifeq ($(UNAME_S),Linux)
|
||||||
CPUINFO_CMD := cat /proc/cpuinfo
|
CPUINFO_CMD := cat /proc/cpuinfo
|
||||||
else ifneq (,$(filter MINGW32_NT% MINGW64_NT%,$(UNAME_S)))
|
else ifneq (,$(filter MINGW32_NT% MINGW64_NT%,$(UNAME_S)))
|
||||||
CPUINFO_CMD := cat /proc/cpuinfo
|
CPUINFO_CMD := cat /proc/cpuinfo
|
||||||
|
else ifneq (,$(filter DragonFly FreeBSD,$(UNAME_S)))
|
||||||
|
CPUINFO_CMD := grep Features /var/run/dmesg.boot
|
||||||
else ifeq ($(UNAME_S),Haiku)
|
else ifeq ($(UNAME_S),Haiku)
|
||||||
CPUINFO_CMD := sysinfo -cpu
|
CPUINFO_CMD := sysinfo -cpu
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifdef CPUINFO_CMD
|
ifdef CPUINFO_CMD
|
||||||
AVX_M := $(shell $(CPUINFO_CMD) | grep -m 1 "avx ")
|
AVX_M := $(shell $(CPUINFO_CMD) | grep -iwE 'AVX|AVX1.0')
|
||||||
ifneq (,$(findstring avx,$(AVX_M)))
|
ifneq (,$(AVX_M))
|
||||||
CFLAGS += -mavx
|
CFLAGS += -mavx
|
||||||
endif
|
CXXFLAGS += -mavx
|
||||||
|
|
||||||
AVX2_M := $(shell $(CPUINFO_CMD) | grep -m 1 "avx2 ")
|
|
||||||
ifneq (,$(findstring avx2,$(AVX2_M)))
|
|
||||||
CFLAGS += -mavx2
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
FMA_M := $(shell $(CPUINFO_CMD) | grep -m 1 "fma ")
|
AVX2_M := $(shell $(CPUINFO_CMD) | grep -iw 'AVX2')
|
||||||
ifneq (,$(findstring fma,$(FMA_M)))
|
ifneq (,$(AVX2_M))
|
||||||
CFLAGS += -mfma
|
CFLAGS += -mavx2
|
||||||
|
CXXFLAGS += -mavx2
|
||||||
endif
|
endif
|
||||||
|
|
||||||
F16C_M := $(shell $(CPUINFO_CMD) | grep -m 1 "f16c ")
|
FMA_M := $(shell $(CPUINFO_CMD) | grep -iw 'FMA')
|
||||||
ifneq (,$(findstring f16c,$(F16C_M)))
|
ifneq (,$(FMA_M))
|
||||||
CFLAGS += -mf16c
|
CFLAGS += -mfma
|
||||||
|
CXXFLAGS += -mfma
|
||||||
AVX1_M := $(shell $(CPUINFO_CMD) | grep -m 1 "avx ")
|
|
||||||
ifneq (,$(findstring avx,$(AVX1_M)))
|
|
||||||
CFLAGS += -mavx
|
|
||||||
endif
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
SSE3_M := $(shell $(CPUINFO_CMD) | grep -m 1 "sse3 ")
|
F16C_M := $(shell $(CPUINFO_CMD) | grep -iw 'F16C')
|
||||||
ifneq (,$(findstring sse3,$(SSE3_M)))
|
ifneq (,$(F16C_M))
|
||||||
CFLAGS += -msse3
|
CFLAGS += -mf16c
|
||||||
|
CXXFLAGS += -mf16c
|
||||||
endif
|
endif
|
||||||
|
|
||||||
SSSE3_M := $(shell $(CPUINFO_CMD) | grep -m 1 "ssse3 ")
|
SSE3_M := $(shell $(CPUINFO_CMD) | grep -iwE 'PNI|SSE3')
|
||||||
ifneq (,$(findstring ssse3,$(SSSE3_M)))
|
ifneq (,$(SSE3_M))
|
||||||
CFLAGS += -mssse3
|
CFLAGS += -msse3
|
||||||
|
CXXFLAGS += -msse3
|
||||||
|
endif
|
||||||
|
|
||||||
|
SSSE3_M := $(shell $(CPUINFO_CMD) | grep -iw 'SSSE3')
|
||||||
|
ifneq (,$(SSSE3_M))
|
||||||
|
CFLAGS += -mssse3
|
||||||
|
CXXFLAGS += -mssse3
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
ifeq ($(UNAME_M),amd64)
|
|
||||||
CFLAGS += -mavx -mavx2 -mfma -mf16c
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifneq ($(filter ppc64%,$(UNAME_M)),)
|
ifneq ($(filter ppc64%,$(UNAME_M)),)
|
||||||
POWER9_M := $(shell grep "POWER9" /proc/cpuinfo)
|
POWER9_M := $(shell grep "POWER9" /proc/cpuinfo)
|
||||||
|
Loading…
Reference in New Issue
Block a user