summaryrefslogtreecommitdiffstats
path: root/config.tests
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2015-07-17 14:46:05 -0700
committerThiago Macieira <thiago.macieira@intel.com>2015-09-25 20:29:22 +0000
commita587ad1e507aa367d55f1954000417271383c685 (patch)
tree8daac675a8a0fff8bc0f1d84500f308d0e469a59 /config.tests
parente79200bf7f8dbd4f8aa03c8be07a6dfc4328fa50 (diff)
configure: Add support for detecting AVX512 instructions
Tested on Linux with Clang 3.7, GCC 4.9, 5.1 and 6.0, ICC 16 beta; on OS X with Clang-XCode 6.4, ICC 16 beta; on Windows with MSVC 2013 and ICC 15. MinGW is not tested. GCC 4.9: AVX512F AVX512ER AVX512CD AVX512PF GCC 5 & 6: AVX512F AVX512ER AVX512CD AVX512PF AVX512DQ AVX512BW AVX512VL AVX512IFMA AVX512VBMI Clang 3.7: AVX512F AVX512ER AVX512CD Clang-XCode: <none> ICC 15 & 16: AVX512F AVX512ER AVX512CD AVX512PF AVX512DQ AVX512BW AVX512VL MSVC 2013: <none> Change-Id: Ib306f8f647014b399b87ffff13f1da1b161c31d7 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'config.tests')
-rw-r--r--config.tests/common/avx512/avx512.cpp97
-rw-r--r--config.tests/common/avx512/avx512.pro12
2 files changed, 109 insertions, 0 deletions
diff --git a/config.tests/common/avx512/avx512.cpp b/config.tests/common/avx512/avx512.cpp
new file mode 100644
index 0000000000..d0c55a09b5
--- /dev/null
+++ b/config.tests/common/avx512/avx512.cpp
@@ -0,0 +1,97 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Intel Corporation.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the configuration of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <immintrin.h>
+
+#ifndef AVX512WANT
+# error ".pro file must define AVX512WANT macro to the AVX-512 feature to be tested"
+#endif
+
+// The following checks if __AVXx__ is defined, where x is the value in
+// AVX512WANT
+#define HAS2(x) __AVX512 ## x ## __
+#define HAS(x) HAS2(x)
+#if !HAS(AVX512WANT)
+# error "Feature not supported"
+#endif
+
+int main(int, char**argv)
+{
+ /* AVX512 Foundation */
+ __m512i i;
+ __m512d d;
+ __m512 f;
+ __mmask16 m = ~1;
+ i = _mm512_maskz_loadu_epi32(0, argv);
+ d = _mm512_loadu_pd((double *)argv + 64);
+ f = _mm512_loadu_ps((float *)argv + 128);
+
+#ifdef __AVX512ER__
+ /* AVX512 Exponential and Reciprocal */
+ f = _mm512_exp2a23_round_ps(f, 8);
+#endif
+#ifdef __AVX512CD__
+ /* AVX512 Conflict Detection */
+ i = _mm512_maskz_conflict_epi32(m, i);
+#endif
+#ifdef __AVX512PF__
+ /* AVX512 Prefetch */
+ _mm512_mask_prefetch_i64scatter_pd(argv, 0xf, i, 2, 2);
+#endif
+#ifdef __AVX512DQ__
+ /* AVX512 Doubleword and Quadword support */
+ m = _mm512_movepi32_mask(i);
+#endif
+#ifdef __AVX512BW__
+ /* AVX512 Byte and Word support */
+ i = _mm512_mask_loadu_epi8(i, m, argv - 8);
+#endif
+#ifdef __AVX512VL__
+ /* AVX512 Vector Length */
+ __m256i i2 = _mm256_maskz_loadu_epi32(0, argv);
+ _mm256_mask_storeu_epi32(argv + 1, m, i2);
+#endif
+#ifdef __AVX512IFMA__
+ /* AVX512 Integer Fused Multiply-Add */
+ i = _mm512_madd52lo_epu64(i, i, i);
+#endif
+#ifdef __AVX512VBMI__
+ /* AVX512 Vector Byte Manipulation Instructions */
+ i = _mm512_permutexvar_epi8(i, i);
+#endif
+
+ _mm512_mask_storeu_epi64(argv, m, i);
+ _mm512_mask_storeu_ps(argv + 64, m, f);
+ _mm512_mask_storeu_pd(argv + 128, m, d);
+ return 0;
+}
diff --git a/config.tests/common/avx512/avx512.pro b/config.tests/common/avx512/avx512.pro
new file mode 100644
index 0000000000..37cfb2ea54
--- /dev/null
+++ b/config.tests/common/avx512/avx512.pro
@@ -0,0 +1,12 @@
+SOURCES = avx512.cpp
+CONFIG -= qt dylib release debug_and_release
+CONFIG += debug console
+
+isEmpty(AVX512): error("You must set the AVX512 variable!")
+
+varname = QMAKE_CFLAGS_AVX512$$AVX512
+value = $$eval($$varname)
+isEmpty($$varname): error("This compiler does not support AVX512")
+
+QMAKE_CXXFLAGS += $$value
+DEFINES += AVX512WANT=$$AVX512