| 1 |
/* This file is used to reduce a number of runtime tests for AVX512F |
| 2 |
and AVX512VL instructions. Idea is to create one file per instruction - |
| 3 |
avx512f-insn-2.c - using defines from this file instead of intrinsic |
| 4 |
name, vector length etc. Then dg-options are set with appropriate |
| 5 |
-Dwhatever options in that .c file producing tests for specific |
| 6 |
length. */ |
| 7 |
|
| 8 |
#ifndef AVX512F_HELPER_INCLUDED |
| 9 |
#define AVX512F_HELPER_INCLUDED |
| 10 |
|
| 11 |
#if defined(AVX10) |
| 12 |
#include "avx10-check.h" |
| 13 |
#else |
| 14 |
#include "avx512-check.h" |
| 15 |
#endif |
| 16 |
|
| 17 |
/* Macros expansion. */ |
| 18 |
#define CONCAT(a,b,c) a ## b ## c |
| 19 |
#define EVAL(a,b,c) CONCAT(a,b,c) |
| 20 |
|
| 21 |
/* Value to be written into destination. |
| 22 |
We have one value for all types so it must be small enough |
| 23 |
to fit into signed char. */ |
| 24 |
#ifndef DEFAULT_VALUE |
| 25 |
#define DEFAULT_VALUE 117 |
| 26 |
#endif |
| 27 |
|
| 28 |
#define MAKE_MASK_MERGE(NAME, TYPE) \ |
| 29 |
static void \ |
| 30 |
__attribute__((noinline, unused)) \ |
| 31 |
merge_masking_##NAME (TYPE *arr, unsigned long long mask, int size) \ |
| 32 |
{ \ |
| 33 |
int i; \ |
| 34 |
for (i = 0; i < size; i++) \ |
| 35 |
{ \ |
| 36 |
arr[i] = (mask & (1LL << i)) ? arr[i] : DEFAULT_VALUE; \ |
| 37 |
} \ |
| 38 |
} |
| 39 |
|
| 40 |
MAKE_MASK_MERGE(i_b, char) |
| 41 |
MAKE_MASK_MERGE(i_w, short) |
| 42 |
MAKE_MASK_MERGE(i_d, int) |
| 43 |
MAKE_MASK_MERGE(i_q, long long) |
| 44 |
MAKE_MASK_MERGE(h, _Float16) |
| 45 |
MAKE_MASK_MERGE(, float) |
| 46 |
MAKE_MASK_MERGE(d, double) |
| 47 |
MAKE_MASK_MERGE(i_ub, unsigned char) |
| 48 |
MAKE_MASK_MERGE(i_uw, unsigned short) |
| 49 |
MAKE_MASK_MERGE(bf16_uw, unsigned short) |
| 50 |
MAKE_MASK_MERGE(i_ud, unsigned int) |
| 51 |
MAKE_MASK_MERGE(i_uq, unsigned long long) |
| 52 |
MAKE_MASK_MERGE(bf16_bf, __bf16) |
| 53 |
|
| 54 |
#define MASK_MERGE(TYPE) merge_masking_##TYPE |
| 55 |
|
| 56 |
#define MAKE_MASK_ZERO(NAME, TYPE) \ |
| 57 |
static void \ |
| 58 |
__attribute__((noinline, unused)) \ |
| 59 |
zero_masking_##NAME (TYPE *arr, unsigned long long mask, int size) \ |
| 60 |
{ \ |
| 61 |
int i; \ |
| 62 |
for (i = 0; i < size; i++) \ |
| 63 |
{ \ |
| 64 |
arr[i] = (mask & (1LL << i)) ? arr[i] : 0; \ |
| 65 |
} \ |
| 66 |
} |
| 67 |
|
| 68 |
MAKE_MASK_ZERO(i_b, char) |
| 69 |
MAKE_MASK_ZERO(i_w, short) |
| 70 |
MAKE_MASK_ZERO(i_d, int) |
| 71 |
MAKE_MASK_ZERO(i_q, long long) |
| 72 |
MAKE_MASK_ZERO(h, _Float16) |
| 73 |
MAKE_MASK_ZERO(, float) |
| 74 |
MAKE_MASK_ZERO(d, double) |
| 75 |
MAKE_MASK_ZERO(i_ub, unsigned char) |
| 76 |
MAKE_MASK_ZERO(i_uw, unsigned short) |
| 77 |
MAKE_MASK_ZERO(bf16_uw, unsigned short) |
| 78 |
MAKE_MASK_ZERO(i_ud, unsigned int) |
| 79 |
MAKE_MASK_ZERO(i_uq, unsigned long long) |
| 80 |
MAKE_MASK_ZERO(bf16_bf, __bf16) |
| 81 |
|
| 82 |
|
| 83 |
#define MASK_ZERO(TYPE) zero_masking_##TYPE |
| 84 |
|
| 85 |
|
| 86 |
/* Unions used for testing (for example union512d, union256d etc.). */ |
| 87 |
#define UNION_TYPE(SIZE, NAME) EVAL(union, SIZE, NAME) |
| 88 |
/* Corresponding union check. */ |
| 89 |
#define UNION_CHECK(SIZE, NAME) EVAL(check_union, SIZE, NAME) |
| 90 |
/* Corresponding fp union check. */ |
| 91 |
#define UNION_FP_CHECK(SIZE, NAME) EVAL(check_fp_union, SIZE, NAME) |
| 92 |
/* Corresponding rough union check. */ |
| 93 |
#define UNION_ROUGH_CHECK(SIZE, NAME) \ |
| 94 |
EVAL(check_rough_union, SIZE, NAME) |
| 95 |
/* Function which tests intrinsic for given length. */ |
| 96 |
#define TEST EVAL(test_, AVX512F_LEN,) |
| 97 |
/* Function which calculates result. */ |
| 98 |
#define CALC EVAL(calc_, AVX512F_LEN,) |
| 99 |
|
| 100 |
#if !defined(AVX512VL) || defined(AVX10_512BIT) |
| 101 |
#define AVX512F_LEN 512 |
| 102 |
#define AVX512F_LEN_HALF 256 |
| 103 |
#endif |
| 104 |
|
| 105 |
#endif /* AVX512F_HELPER_INCLUDED */ |
| 106 |
|
| 107 |
/* Intrinsic being tested. It has different deffinitions, |
| 108 |
depending on AVX512F_LEN, so it's outside include guards |
| 109 |
and in undefed away to silence warnings. */ |
| 110 |
#if defined INTRINSIC |
| 111 |
#undef INTRINSIC |
| 112 |
#endif |
| 113 |
|
| 114 |
#if AVX512F_LEN != 128 |
| 115 |
#define INTRINSIC(NAME) EVAL(_mm, AVX512F_LEN, NAME) |
| 116 |
#else |
| 117 |
#define INTRINSIC(NAME) _mm ## NAME |
| 118 |
#endif |