Add support for AVX-512 intrinsics found in MSVC 2017 15.3
It seems the compiler supports /arch:AVX512 and /arch:AVX512F but none of the other switches (and neither are documented). And when you pass those, you also get Conflict Detection (CD), Double & Quad (DQ), Byte & Word (BW) and Vector Length (VL), which matches the ICC switch "-xCORE-AVX512". Unlike ICC, there doesn't seem to be an option to enable only the common part of AVX-512. Support for Intel Xeon Phi's current features (Exponential & Reciprocation and Prefetch) and future ones (IFMA, VBMI, 4FMAPS, 4VNNI and VPOPCNTDQ) seems to be missing altogether. See https://blogs.msdn.microsoft.com/vcblog/2017/07/11/microsoft-visual-studio-2017-supports-intel-avx-512/ Change-Id: I98105cd9616b8097957db680d73eb1f86e487e6d Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
This commit is contained in:
parent
f984c45373
commit
ff1ffa7577
@ -1,6 +1,6 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 Intel Corporation.
|
||||
** Copyright (C) 2017 Intel Corporation.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of the configuration of the Qt Toolkit.
|
||||
@ -39,15 +39,18 @@
|
||||
|
||||
#include <immintrin.h>
|
||||
|
||||
#ifndef AVX512WANT
|
||||
# error ".pro file must define AVX512WANT macro to the AVX-512 feature to be tested"
|
||||
#ifndef __AVX512F__
|
||||
# error "There doesn't seem to be AVX-512 support in this compiler"
|
||||
#endif
|
||||
#ifndef WANT_AVX512
|
||||
# error ".pro file must define WANT_AVX512 macro to the AVX-512 feature to be tested"
|
||||
#endif
|
||||
|
||||
// The following checks if __AVXx__ is defined, where x is the value in
|
||||
// AVX512WANT
|
||||
// WANT_AVX512
|
||||
#define HAS2(x) __AVX512 ## x ## __
|
||||
#define HAS(x) HAS2(x)
|
||||
#if !HAS(AVX512WANT)
|
||||
#if !HAS(WANT_AVX512)
|
||||
# error "Feature not supported"
|
||||
#endif
|
||||
|
||||
@ -62,36 +65,36 @@ int main(int, char**argv)
|
||||
d = _mm512_loadu_pd((double *)argv + 64);
|
||||
f = _mm512_loadu_ps((float *)argv + 128);
|
||||
|
||||
#ifdef __AVX512ER__
|
||||
#ifdef WANT_AVX512ER
|
||||
/* AVX512 Exponential and Reciprocal */
|
||||
f = _mm512_exp2a23_round_ps(f, 8);
|
||||
#endif
|
||||
#ifdef __AVX512CD__
|
||||
#ifdef WANT_AVX512CD
|
||||
/* AVX512 Conflict Detection */
|
||||
i = _mm512_maskz_conflict_epi32(m, i);
|
||||
#endif
|
||||
#ifdef __AVX512PF__
|
||||
#ifdef WANT_AVX512PF
|
||||
/* AVX512 Prefetch */
|
||||
_mm512_mask_prefetch_i64scatter_pd(argv, 0xf, i, 2, 2);
|
||||
#endif
|
||||
#ifdef __AVX512DQ__
|
||||
#ifdef WANT_AVX512DQ
|
||||
/* AVX512 Doubleword and Quadword support */
|
||||
m = _mm512_movepi32_mask(i);
|
||||
#endif
|
||||
#ifdef __AVX512BW__
|
||||
#ifdef WANT_AVX512BW
|
||||
/* AVX512 Byte and Word support */
|
||||
i = _mm512_mask_loadu_epi8(i, m, argv - 8);
|
||||
#endif
|
||||
#ifdef __AVX512VL__
|
||||
#ifdef WANT_AVX512VL
|
||||
/* AVX512 Vector Length */
|
||||
__m256i i2 = _mm256_maskz_loadu_epi32(0, argv);
|
||||
_mm256_mask_storeu_epi32(argv + 1, m, i2);
|
||||
#endif
|
||||
#ifdef __AVX512IFMA__
|
||||
#ifdef WANT_AVX512IFMA
|
||||
/* AVX512 Integer Fused Multiply-Add */
|
||||
i = _mm512_madd52lo_epu64(i, i, i);
|
||||
#endif
|
||||
#ifdef __AVX512VBMI__
|
||||
#ifdef WANT_AVX512VBMI
|
||||
/* AVX512 Vector Byte Manipulation Instructions */
|
||||
i = _mm512_permutexvar_epi8(i, i);
|
||||
#endif
|
||||
|
@ -7,4 +7,4 @@ value = $$eval($$varname)
|
||||
!defined($$varname, "var"): error("This compiler does not support AVX512")
|
||||
|
||||
QMAKE_CXXFLAGS += $$value
|
||||
DEFINES += AVX512WANT=$$AVX512
|
||||
DEFINES += WANT_AVX512=$$AVX512 WANT_AVX512$$AVX512
|
||||
|
@ -82,6 +82,20 @@ greaterThan(QMAKE_MSC_VER, 1909) {
|
||||
MSVC_VER = 15.0
|
||||
COMPAT_MKSPEC = win32-msvc2017
|
||||
QMAKE_CXXFLAGS += -Zc:referenceBinding
|
||||
|
||||
# Only Visual Studio 2017 version 15.3 / Visual C++ 19.11 & up have support
|
||||
# for AVX-512. We enable the switches anyway and let configure check if they
|
||||
# work.
|
||||
QMAKE_CFLAGS_AVX512F = -arch:AVX512
|
||||
QMAKE_CFLAGS_AVX512ER = -arch:AVX512
|
||||
QMAKE_CFLAGS_AVX512CD = -arch:AVX512
|
||||
QMAKE_CFLAGS_AVX512PF = -arch:AVX512
|
||||
QMAKE_CFLAGS_AVX512DQ = -arch:AVX512
|
||||
QMAKE_CFLAGS_AVX512BW = -arch:AVX512
|
||||
QMAKE_CFLAGS_AVX512VL = -arch:AVX512
|
||||
QMAKE_CFLAGS_AVX512IFMA = -arch:AVX512
|
||||
QMAKE_CFLAGS_AVX512VBMI = -arch:AVX512
|
||||
|
||||
# For now permissive fails as soon as UWP API comes into play. In qtbase this
|
||||
# API is used in direct2d, but also in multimedia, positioning and sensors.
|
||||
# We can try again with a later version of Visual Studio.
|
||||
|
Loading…
Reference in New Issue
Block a user