Skip to content

Commit c4f89d8

Browse files
authored
make : use -march=native -mtune=native on x86 (#609)
1 parent 5b70e7d commit c4f89d8

File tree

1 file changed

+2
-89
lines changed

1 file changed

+2
-89
lines changed

Makefile

Lines changed: 2 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -70,95 +70,8 @@ endif
7070
# TODO: probably these flags need to be tweaked on some architectures
7171
# feel free to update the Makefile for your architecture and send a pull request or issue
7272
ifeq ($(UNAME_M),$(filter $(UNAME_M),x86_64 i686))
73-
ifeq ($(UNAME_S),Darwin)
74-
F16C_M := $(shell sysctl machdep.cpu.features)
75-
ifneq (,$(findstring F16C,$(F16C_M)))
76-
CFLAGS += -mf16c
77-
endif
78-
AVX1_M := $(shell sysctl machdep.cpu.features)
79-
ifneq (,$(findstring FMA,$(AVX1_M)))
80-
CFLAGS += -mfma
81-
endif
82-
ifneq (,$(findstring AVX1.0,$(AVX1_M)))
83-
CFLAGS += -mavx
84-
endif
85-
AVX2_M := $(shell sysctl machdep.cpu.leaf7_features)
86-
ifneq (,$(findstring AVX2,$(AVX2_M)))
87-
CFLAGS += -mavx2
88-
endif
89-
else ifeq ($(UNAME_S),Linux)
90-
AVX1_M := $(shell grep "avx " /proc/cpuinfo)
91-
ifneq (,$(findstring avx,$(AVX1_M)))
92-
CFLAGS += -mavx
93-
endif
94-
AVX2_M := $(shell grep "avx2 " /proc/cpuinfo)
95-
ifneq (,$(findstring avx2,$(AVX2_M)))
96-
CFLAGS += -mavx2
97-
endif
98-
FMA_M := $(shell grep "fma " /proc/cpuinfo)
99-
ifneq (,$(findstring fma,$(FMA_M)))
100-
CFLAGS += -mfma
101-
endif
102-
F16C_M := $(shell grep "f16c " /proc/cpuinfo)
103-
ifneq (,$(findstring f16c,$(F16C_M)))
104-
CFLAGS += -mf16c
105-
endif
106-
SSE3_M := $(shell grep "sse3 " /proc/cpuinfo)
107-
ifneq (,$(findstring sse3,$(SSE3_M)))
108-
CFLAGS += -msse3
109-
endif
110-
AVX512F_M := $(shell grep "avx512f " /proc/cpuinfo)
111-
ifneq (,$(findstring avx512f,$(AVX512F_M)))
112-
CFLAGS += -mavx512f
113-
endif
114-
AVX512BW_M := $(shell grep "avx512bw " /proc/cpuinfo)
115-
ifneq (,$(findstring avx512bw,$(AVX512BW_M)))
116-
CFLAGS += -mavx512bw
117-
endif
118-
AVX512DQ_M := $(shell grep "avx512dq " /proc/cpuinfo)
119-
ifneq (,$(findstring avx512dq,$(AVX512DQ_M)))
120-
CFLAGS += -mavx512dq
121-
endif
122-
AVX512VL_M := $(shell grep "avx512vl " /proc/cpuinfo)
123-
ifneq (,$(findstring avx512vl,$(AVX512VL_M)))
124-
CFLAGS += -mavx512vl
125-
endif
126-
AVX512CD_M := $(shell grep "avx512cd " /proc/cpuinfo)
127-
ifneq (,$(findstring avx512cd,$(AVX512CD_M)))
128-
CFLAGS += -mavx512cd
129-
endif
130-
AVX512ER_M := $(shell grep "avx512er " /proc/cpuinfo)
131-
ifneq (,$(findstring avx512er,$(AVX512ER_M)))
132-
CFLAGS += -mavx512er
133-
endif
134-
AVX512IFMA_M := $(shell grep "avx512ifma " /proc/cpuinfo)
135-
ifneq (,$(findstring avx512ifma,$(AVX512IFMA_M)))
136-
CFLAGS += -mavx512ifma
137-
endif
138-
AVX512PF_M := $(shell grep "avx512pf " /proc/cpuinfo)
139-
ifneq (,$(findstring avx512pf,$(AVX512PF_M)))
140-
CFLAGS += -mavx512pf
141-
endif
142-
else ifeq ($(UNAME_S),Haiku)
143-
AVX1_M := $(shell sysinfo -cpu | grep -w "AVX")
144-
ifneq (,$(findstring AVX,$(AVX1_M)))
145-
CFLAGS += -mavx
146-
endif
147-
AVX2_M := $(shell sysinfo -cpu | grep -w "AVX2")
148-
ifneq (,$(findstring AVX2,$(AVX2_M)))
149-
CFLAGS += -mavx2
150-
endif
151-
FMA_M := $(shell sysinfo -cpu | grep -w "FMA")
152-
ifneq (,$(findstring FMA,$(FMA_M)))
153-
CFLAGS += -mfma
154-
endif
155-
F16C_M := $(shell sysinfo -cpu | grep -w "F16C")
156-
ifneq (,$(findstring F16C,$(F16C_M)))
157-
CFLAGS += -mf16c
158-
endif
159-
else
160-
CFLAGS += -mfma -mf16c -mavx -mavx2
161-
endif
73+
# Use all CPU extensions that are available:
74+
CFLAGS += -march=native -mtune=native
16275
endif
16376
ifneq ($(filter ppc64%,$(UNAME_M)),)
16477
POWER9_M := $(shell grep "POWER9" /proc/cpuinfo)

0 commit comments

Comments
 (0)