diff options
author | Thiago Macieira <thiago.macieira@intel.com> | 2018-05-23 00:54:19 -0300 |
---|---|---|
committer | Thiago Macieira <thiago.macieira@intel.com> | 2018-07-09 00:18:24 +0000 |
commit | c3a4ec5d0bbd5f2710f4fd1d3bd4a2d7f0f507ad (patch) | |
tree | f18c0e54743eb213df0e5374bb5fdf4281aa5c4e /mkspecs | |
parent | 746f15d0c213fef0e46207682815bd839a36ecc6 (diff) |
SIMD: Add a haswell sub-architecture selection to our support
As the comment says, Haswell is a nice divider and is a good
optimization target.
I'm using -march=core-avx2 instead of -march=haswell because the latter
form was only added to GCC 4.9 but we still support 4.7 and that has
support for AVX2.
This commit changes the AVX2-optimized code in QtGui to Haswell-
optimized instead. That means, for example, that qdrawhelper_avx2.cpp
can now use the FMA instructions.
Change-Id: If025d476890745368955fffd153129c1716ba006
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'mkspecs')
-rw-r--r-- | mkspecs/common/gcc-base.conf | 3 | ||||
-rw-r--r-- | mkspecs/features/simd.prf | 24 |
2 files changed, 26 insertions, 1 deletions
diff --git a/mkspecs/common/gcc-base.conf b/mkspecs/common/gcc-base.conf index e51b173276..c2669e4833 100644 --- a/mkspecs/common/gcc-base.conf +++ b/mkspecs/common/gcc-base.conf @@ -108,6 +108,9 @@ QMAKE_CFLAGS_NEON += -mfpu=neon QMAKE_CFLAGS_MIPS_DSP += -mdsp QMAKE_CFLAGS_MIPS_DSPR2 += -mdspr2 +# -march=haswell is supported as of GCC 4.9 and Clang 3.6 +QMAKE_CFLAGS_ARCH_HASWELL = -march=core-avx2 + # Wrapper tools that understand .o/.a files with GIMPLE instead of machine code QMAKE_AR_LTCG = gcc-ar cqs QMAKE_NM_LTCG = gcc-nm -P diff --git a/mkspecs/features/simd.prf b/mkspecs/features/simd.prf index 65ba4b0d08..a0b40fcf11 100644 --- a/mkspecs/features/simd.prf +++ b/mkspecs/features/simd.prf @@ -141,6 +141,28 @@ addSimdCompiler(neon) addSimdCompiler(mips_dsp) addSimdCompiler(mips_dspr2) +# Haswell sub-architecture +defineTest(addSimdArch) { + name = arch_$$1 + dependencies = $$2 + upname = $$upper($$name) + + cpu_features_missing = + for(part, dependencies) { + !contains(QT_CPU_FEATURES, $$part): cpu_features_missing = 1 + } + + CONFIG += $$name + isEmpty(cpu_features_missing): QT_CPU_FEATURES += $$name + + export(QT_CPU_FEATURES) + export(CONFIG) + addSimdCompiler($$name) +} + +isEmpty(QMAKE_CFLAGS_ARCH_HASWELL): QMAKE_CFLAGS_ARCH_HASWELL = $$QMAKE_CFLAGS_AVX2 +avx2: addSimdArch(haswell, avx2 bmi bmi2 f16c fma lzcnt popcnt) + # Follow the Intel compiler's lead and define profiles of AVX512 instructions defineTest(addAvx512Profile) { name = $$1 @@ -149,7 +171,7 @@ defineTest(addAvx512Profile) { varname = QMAKE_CFLAGS_$$upname cpu_features_missing = - cflags = $$QMAKE_CFLAGS_AVX512F + cflags = $$QMAKE_CFLAGS_ARCH_HASWELL $$QMAKE_CFLAGS_AVX512F for(part, dependencies) { !CONFIG($$part): return() # Profile isn't supported by the compiler |