diff options
author | Ilia Taraban <ilia.taraban@intel.com> | 2018-12-13 14:40:20 +0000 |
---|---|---|
committer | Ilia Taraban <ilia.taraban@intel.com> | 2018-12-13 14:40:20 +0000 |
commit | 5ff3a8503dfbcf386947cace46645963fb9989ef (patch) | |
tree | 1eb8ad82daae054bdc6920463b15a73d488f6fc6 /SingleSource/UnitTests/Vector/AVX512F/imul.c | |
parent | 8c55a4b286748bae08b5fcc795562705b4a1c11a (diff) |
test-suite: divide avx512 tests to instruction set subdirectories
Summary:
This patch separates current avx512 tests to avx512f, avx512bw and other instruction set directories.
This allows to specify tests sets on specific avx512 hardware, for example, knl.
Reviewers: RKSimon, MatzeB, craig.topper
Reviewed By: RKSimon
Subscribers: mgorny, llvm-commits
Differential Revision: https://reviews.llvm.org/D55603
git-svn-id: https://llvm.org/svn/llvm-project/test-suite/trunk@349039 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'SingleSource/UnitTests/Vector/AVX512F/imul.c')
-rw-r--r-- | SingleSource/UnitTests/Vector/AVX512F/imul.c | 103 |
1 files changed, 103 insertions, 0 deletions
diff --git a/SingleSource/UnitTests/Vector/AVX512F/imul.c b/SingleSource/UnitTests/Vector/AVX512F/imul.c new file mode 100644 index 00000000..04f28b79 --- /dev/null +++ b/SingleSource/UnitTests/Vector/AVX512F/imul.c @@ -0,0 +1,103 @@ +/* + * Test various integer multiply intrinsics. + * Here we check for _mm512_[mask]mul_ep[i|u]32 intrinsics. + */ + +#include "m512_test_util.h" +#include <stdio.h> +#include <string.h> + +volatile int vol0 = 0; + +V512 i64; +V512 i64_mix; +V512 i64_big; + +void NOINLINE init() { + volatile int i; + + + for (i = 0; i < 8; i++) { + i64.s64[i] = i; + i64_mix.s64[i] = (i & 1) ? i : -i; + i64_big.s64[i] = 1000 * (i + 1); + if ((i & 1) != 0) { + i64_big.s64[i] = -i64_big.s64[i]; + } + } +} + +void NOINLINE do_muldq() { + V512 res; + V512 expected; + __mmask16 k; + volatile int i; + + res.zmmi = _mm512_mul_epi32(i64_mix.zmmi, i64_big.zmmi); + for (i = 0; i < 8; i++) { + expected.s64[i] = (I64)i64_mix.s32[2 * i] * i64_big.s32[2 * i]; + } + check_equal_nd(&res, &expected, 16, "_mm512_mul_epi32", __LINE__); + + /* + * No-op to inhibit PRE of i64_big, thus enabling localized ciscization. + */ + i64_big.xmm[vol0] = i64_big.xmm[vol0]; + + k = 0xcd; + + res.zmmi = _mm512_setzero_epi32(); + res.zmmi = _mm512_mask_mul_epi32(res.zmmi, k, i64.zmmi, i64_big.zmmi); + for (i = 0; i < 8; i++) { + expected.s64[i] = 0; + if ((k & (1 << i)) != 0) { + expected.s64[i] = (I64)i64.s32[2 * i] * i64_big.s32[2 * i]; + } + } + check_equal_nd(&res, &expected, 16, "_mm512_mask_mul_epi32", __LINE__); +} + +void NOINLINE do_muludq() { + V512 res; + V512 expected; + __mmask16 k; + volatile int i; + + res.zmmi = _mm512_mul_epu32(i64_mix.zmmi, i64_big.zmmi); + for (i = 0; i < 8; i++) { + expected.u64[i] = (U64)i64_mix.u32[2 * i] * i64_big.u32[2 * i]; + } + check_equal_nd(&res, &expected, 16, "_mm512_mul_epu32", __LINE__); + + /* + * No-op to inhibit PRE of i64_big, thus enabling localized ciscization. + */ + i64_big.xmm[vol0] = i64_big.xmm[vol0]; + + k = 0xcd; + + res.zmmi = _mm512_setzero_epi32(); + res.zmmi = _mm512_mask_mul_epu32(res.zmmi, k, i64.zmmi, i64_big.zmmi); + for (i = 0; i < 8; i++) { + expected.u64[i] = 0; + if ((k & (1 << i)) != 0) { + expected.u64[i] = (U64)i64.u32[2 * i] * i64_big.u32[2 * i]; + } + } + check_equal_nd(&res, &expected, 16, "_mm512_mask_mul_epu32", __LINE__); +} + +int main(int argc, char *argv[]) { + init(); + + do_muldq(); + do_muludq(); + + if (n_errs != 0) { + printf("FAILED\n"); + return 1; + } + + printf("PASSED\n"); + return 0; +} |