| 1 |
#include <immintrin.h> |
| 2 |
#include "m128-check.h" |
| 3 |
|
| 4 |
#ifndef max |
| 5 |
#define max(a, b) (((a) > (b)) ? (a):(b)) |
| 6 |
#endif |
| 7 |
#ifndef min |
| 8 |
#define min(a, b) (((a) < (b)) ? (a):(b)) |
| 9 |
#endif |
| 10 |
|
| 11 |
typedef union |
| 12 |
{ |
| 13 |
__m256i x; |
| 14 |
char a[32]; |
| 15 |
} union256i_b; |
| 16 |
|
| 17 |
typedef union |
| 18 |
{ |
| 19 |
__m256i x; |
| 20 |
short a[16]; |
| 21 |
} union256i_w; |
| 22 |
|
| 23 |
typedef union |
| 24 |
{ |
| 25 |
__m256i x; |
| 26 |
int a[8]; |
| 27 |
} union256i_d; |
| 28 |
|
| 29 |
typedef union |
| 30 |
{ |
| 31 |
__m256i x; |
| 32 |
long long a[4]; |
| 33 |
} union256i_q; |
| 34 |
|
| 35 |
typedef union |
| 36 |
{ |
| 37 |
__m256 x; |
| 38 |
float a[8]; |
| 39 |
} union256; |
| 40 |
|
| 41 |
typedef union |
| 42 |
{ |
| 43 |
__m256d x; |
| 44 |
double a[4]; |
| 45 |
} union256d; |
| 46 |
|
| 47 |
typedef union |
| 48 |
{ |
| 49 |
__m256i x; |
| 50 |
unsigned char a[32]; |
| 51 |
} union256i_ub; |
| 52 |
|
| 53 |
typedef union |
| 54 |
{ |
| 55 |
__m256i x; |
| 56 |
unsigned short a[16]; |
| 57 |
} union256i_uw; |
| 58 |
|
| 59 |
typedef union |
| 60 |
{ |
| 61 |
__m256i x; |
| 62 |
unsigned int a[8]; |
| 63 |
} union256i_ud; |
| 64 |
|
| 65 |
typedef union |
| 66 |
{ |
| 67 |
__m256i x; |
| 68 |
unsigned long long a[4]; |
| 69 |
} union256i_uq; |
| 70 |
|
| 71 |
CHECK_EXP (union256i_b, char, "%d") |
| 72 |
CHECK_EXP (union256i_w, short, "%d") |
| 73 |
CHECK_EXP (union256i_d, int, "0x%x") |
| 74 |
CHECK_EXP (union256i_q, long long, "0x%llx") |
| 75 |
CHECK_EXP (union256, float, "%f") |
| 76 |
CHECK_EXP (union256d, double, "%f") |
| 77 |
CHECK_EXP (union256i_ub, unsigned char, "%d") |
| 78 |
CHECK_EXP (union256i_uw, unsigned short, "%d") |
| 79 |
CHECK_EXP (union256i_ud, unsigned int, "0x%x") |
| 80 |
CHECK_EXP (union256i_uq, unsigned long long, "0x%llx") |
| 81 |
|
| 82 |
#define CHECK_FP_EXP(UNION_TYPE, VALUE_TYPE, ESP, FMT) \ |
| 83 |
static int \ |
| 84 |
__attribute__((noinline, unused)) \ |
| 85 |
check_fp_##UNION_TYPE (UNION_TYPE u, const VALUE_TYPE *v) \ |
| 86 |
{ \ |
| 87 |
int i; \ |
| 88 |
int err = 0; \ |
| 89 |
\ |
| 90 |
for (i = 0; i < ARRAY_SIZE (u.a); i++) \ |
| 91 |
if (u.a[i] > (v[i] + (ESP)) || u.a[i] < (v[i] - (ESP))) \ |
| 92 |
{ \ |
| 93 |
err++; \ |
| 94 |
PRINTF ("%i: " FMT " != " FMT "\n", \ |
| 95 |
i, v[i], u.a[i]); \ |
| 96 |
} \ |
| 97 |
return err; \ |
| 98 |
} |
| 99 |
|
| 100 |
CHECK_FP_EXP (union256, float, ESP_FLOAT, "%f") |
| 101 |
CHECK_FP_EXP (union256d, double, ESP_DOUBLE, "%f") |