Skip to content

Commit

Permalink
Support Intel Braswell detection
Browse files Browse the repository at this point in the history
This is probably not the optimal -march flag (i.e. it falls back to
Westmere + RDRND). But since Haswell (after Westmere) includes AVX I
don't dare to take this as -march basis.

Thanks to RJVB for the detailed issue, making this an easy fix.

Fixes: gh-153

Signed-off-by: Matthias Kretz <kretz@kde.org>
  • Loading branch information
mattkretz committed Jan 9, 2017
1 parent b1959cf commit 55121e8
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion cmake/OptimizeForArchitecture.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ macro(AutodetectHostArchitecture)
set(TARGET_ARCHITECTURE "skylake-avx512")
elseif(_cpu_model EQUAL 78 OR _cpu_model EQUAL 94) # 4E, 5E
set(TARGET_ARCHITECTURE "skylake")
elseif(_cpu_model EQUAL 61 OR _cpu_model EQUAL 76)
set(TARGET_ARCHITECTURE "braswell")
elseif(_cpu_model EQUAL 61 OR _cpu_model EQUAL 71 OR _cpu_model EQUAL 86)
set(TARGET_ARCHITECTURE "broadwell")
elseif(_cpu_model EQUAL 60 OR _cpu_model EQUAL 69 OR _cpu_model EQUAL 70 OR _cpu_model EQUAL 63)
Expand Down Expand Up @@ -183,7 +185,7 @@ Using an incorrect setting here can result in crashes of the resulting binary be
Setting the value to \"auto\" will try to optimize for the architecture where cmake is called. \
Other supported values are: \"none\", \"generic\", \"core\", \"merom\" (65nm Core2), \
\"penryn\" (45nm Core2), \"nehalem\", \"westmere\", \"sandy-bridge\", \"ivy-bridge\", \
\"haswell\", \"broadwell\", \"skylake\", \"skylake-avx512\", \"cannonlake\", \"silvermont\", \
\"haswell\", \"broadwell\", \"braswell\", \"skylake\", \"skylake-avx512\", \"cannonlake\", \"silvermont\", \
\"goldmont\", \"knl\" (Knights Landing), \"atom\", \"k8\", \"k8-sse3\", \"barcelona\", \
\"istanbul\", \"magny-cours\", \"bulldozer\", \"interlagos\", \"piledriver\", \
\"AMD 14h\", \"AMD 16h\".")
Expand Down Expand Up @@ -214,6 +216,11 @@ Other supported values are: \"none\", \"generic\", \"core\", \"merom\" (65nm Cor
list(APPEND _march_flag_list "westmere")
_nehalem()
endmacro()
macro(_braswell)
list(APPEND _march_flag_list "braswell")
_westmere()
list(APPEND _available_vector_units_list "rdrnd")
endmacro()
macro(_sandybridge)
list(APPEND _march_flag_list "sandybridge")
list(APPEND _march_flag_list "corei7-avx")
Expand Down Expand Up @@ -282,6 +289,8 @@ Other supported values are: \"none\", \"generic\", \"core\", \"merom\" (65nm Cor
_skylake_avx512()
elseif(TARGET_ARCHITECTURE STREQUAL "skylake")
_skylake()
elseif(TARGET_ARCHITECTURE STREQUAL "braswell")
_braswell()
elseif(TARGET_ARCHITECTURE STREQUAL "broadwell")
_broadwell()
elseif(TARGET_ARCHITECTURE STREQUAL "haswell")
Expand Down

8 comments on commit 55121e8

@RJVB
Copy link

@RJVB RJVB commented on 55121e8 Jan 9, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the speedy fix. I realise I could have made my report maybe a bit even more complete by adding what gcc 6.2 transates -march=native into:

-march=silvermont -mmmx -mno-3dnow -msse -msse2 -msse3 -mssse3 -mno-sse4a -mcx16 -msahf -mmovbe -maes -mno-sha -mpclmul -mpopcnt -mno-abm -mno-lwp -mno-fma -mno-fma4 -mno-xop -mno-bmi -mno-bmi2 -mno-tbm -mno-avx -mno-avx2 -msse4.2 -msse4.1 -mno-lzcnt -mno-rtm -mno-hle -mrdrnd -mno-f16c -mno-fsgsbase -mno-rdseed -mprfchw -mno-adx -mfxsr -mno-xsave -mno-xsaveopt -mno-avx512f -mno-avx512er -mno-avx512cd -mno-avx512pf -mno-prefetchwt1 -mno-clflushopt -mno-xsavec -mno-xsaves -mno-avx512dq -mno-avx512bw -mno-avx512vl -mno-avx512ifma -mno-avx512vbmi -mno-clwb -mno-pcommit -mno-mwaitx -mno-clzero -mno-pku --param l1-cache-size=24 --param l1-cache-line-size=64 --param l2-cache-size=1024 -mtune=generic

clang 3.9.1 also refers to Silvermont, which AFAIK is the predecessor of the "Airmont" series Braswell belongs.

@mattkretz
Copy link
Member Author

@mattkretz mattkretz commented on 55121e8 Jan 9, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, Silvermont. I can add that. Do you have any idea why GCC adds '-mtune=generic'? I would have expected '-mtune=silvermont' to be better.

@RJVB
Copy link

@RJVB RJVB commented on 55121e8 Jan 9, 2017 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mattkretz
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I only know what I just read at Wikipedia. It appears we should just map it directly to Silvermont and skip "Braswell", "Cherry Trail", etc.

@RJVB
Copy link

@RJVB RJVB commented on 55121e8 Jan 9, 2017 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mattkretz
Copy link
Member Author

@mattkretz mattkretz commented on 55121e8 Jan 9, 2017 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@RJVB
Copy link

@RJVB RJVB commented on 55121e8 Jan 9, 2017 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mattkretz
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's actually not about -march itself, but -mtune (which is implied by -march and uses the same list of possible architecture names as -march). I.e. the compiler should tune the instruction sequences according to the specific latencies and throughput values of the CPU.

Please sign in to comment.