| 1 |
#include "avx2-check.h" |
| 2 |
|
| 3 |
#define SIZE 256 |
| 4 |
|
| 5 |
TYPE a[SIZE]; |
| 6 |
TYPE b[SIZE]; |
| 7 |
TYPE c[SIZE]; |
| 8 |
volatile TYPE c_ref[SIZE]; |
| 9 |
extern int memcmp (const void *, const void *, size_t); |
| 10 |
|
| 11 |
__attribute__ ((__noinline__)) |
| 12 |
void |
| 13 |
gen_pop () |
| 14 |
{ |
| 15 |
int i; |
| 16 |
for (i = 0; i < SIZE; ++i) |
| 17 |
#ifdef BIN_OP |
| 18 |
c[i] = BIN_OP (a[i], b[i]); |
| 19 |
#else /* Must be UN_OP */ |
| 20 |
c[i] = UN_OP (a[i]); |
| 21 |
#endif /* BIN_OP */ |
| 22 |
} |
| 23 |
|
| 24 |
void |
| 25 |
check_pop () |
| 26 |
{ |
| 27 |
int i; |
| 28 |
for (i = 0; i < SIZE; ++i) |
| 29 |
#ifdef BIN_OP |
| 30 |
c_ref[i] = BIN_OP (a[i], b[i]); |
| 31 |
#else /* Must be UN_OP */ |
| 32 |
c_ref[i] = UN_OP (a[i]); |
| 33 |
#endif /* BIN_OP */ |
| 34 |
} |
| 35 |
|
| 36 |
void static |
| 37 |
avx2_test (void) |
| 38 |
{ |
| 39 |
int i, j; |
| 40 |
for (i = 0; i < 4; ++i ) |
| 41 |
{ |
| 42 |
for ( j = 0; j < SIZE; ++j ) |
| 43 |
{ |
| 44 |
a[i] = i * i + i; |
| 45 |
b[i] = i * i * i; |
| 46 |
} |
| 47 |
|
| 48 |
gen_pop (); |
| 49 |
check_pop (); |
| 50 |
|
| 51 |
/* We need to cast away volatility from c_ref here in order to eliminate |
| 52 |
warning if libc version of memcpy is used here. */ |
| 53 |
if (memcmp (c, (void *) c_ref, SIZE * sizeof (TYPE))) |
| 54 |
abort(); |
| 55 |
} |
| 56 |
} |