Skip to content

Commit e1eab96

Browse files
authored
Merge pull request #1931 from martin-frbg/pr1921
Add -mavx2 to TARGET=HASWELL builds
2 parents 942e229 + 76b4b89 commit e1eab96

File tree

2 files changed

+24
-3
lines changed

2 files changed

+24
-3
lines changed

Makefile.x86_64

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,17 @@ endif
2525
endif
2626
endif
2727

28+
ifeq ($(CORE), HASWELL)
29+
ifndef DYNAMIC_ARCH
30+
ifndef NO_AVX2
31+
CCOMMON_OPT += -mavx2
32+
FCOMMON_OPT += -mavx2
33+
endif
34+
endif
35+
endif
36+
37+
38+
2839
ifeq ($(OSNAME), Interix)
2940
ARFLAGS = -m x64
3041
endif

cmake/system.cmake

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,19 @@ if (DEFINED BINARY AND DEFINED TARGET AND BINARY EQUAL 32)
4242
endif ()
4343

4444
if (DEFINED TARGET)
45-
if (${TARGET} STREQUAL "SKYLAKEX" AND NOT NO_AVX512)
46-
set (KERNEL_DEFINITIONS "${KERNEL_DEFINITIONS} -march=skylake-avx512")
47-
endif()
45+
if (${TARGET} STREQUAL "SKYLAKEX" AND NOT NO_AVX512)
46+
set (KERNEL_DEFINITIONS "${KERNEL_DEFINITIONS} -march=skylake-avx512")
47+
endif()
48+
if (${TARGET} STREQUAL "HASWELL" AND NOT NO_AVX2)
49+
if (${CMAKE_C_COMPILER_ID} STREQUAL "GNU")
50+
execute_process(COMMAND ${CMAKE_C_COMPILER} -dumpversion OUTPUT_VARIABLE GCC_VERSION)
51+
if (${GCC_VERSION} VERSION_GREATER 4.7 OR ${GCC_VERSION} VERSION_EQUAL 4.7)
52+
set (KERNEL_DEFINITIONS "${KERNEL_DEFINITIONS} -mavx2")
53+
endif()
54+
elseif (${CMAKE_C_COMPILER_ID} STREQUAL "CLANG")
55+
set (KERNEL_DEFINITIONS "${KERNEL_DEFINITIONS} -mavx2")
56+
endif()
57+
endif()
4858
endif()
4959

5060
if (DEFINED TARGET)

0 commit comments

Comments
 (0)