Line data Source code
1 : #ifndef HEADER_fd_src_util_simd_test_avx512_h
2 : #define HEADER_fd_src_util_simd_test_avx512_h
3 :
4 : /* This header provides common functionality for the various AVX-512
5 : unit tests */
6 :
7 : #include "../fd_util.h"
8 : #include "fd_avx512.h"
9 :
10 : FD_STATIC_ASSERT( WW_WIDTH ==16, unit_test );
11 : FD_STATIC_ASSERT( WW_FOOTPRINT ==64, unit_test );
12 : FD_STATIC_ASSERT( WW_ALIGN ==64, unit_test );
13 : FD_STATIC_ASSERT( WW_LG_WIDTH == 4, unit_test );
14 : FD_STATIC_ASSERT( WW_LG_FOOTPRINT== 6, unit_test );
15 : FD_STATIC_ASSERT( WW_LG_ALIGN == 6, unit_test );
16 :
17 128000000 : #define WWI_TEST( x, x0,x1,x2,x3,x4,x5,x6,x7,x8,x9,xa,xb,xc,xd,xe,xf ) do { \
18 128000000 : int _t[16] WW_ATTR; \
19 128000000 : int _u[16] WW_ATTR; \
20 128000000 : wwi_st( _t, (x) ); \
21 128000000 : _u[ 0] = (x0); _u[ 1] = (x1); _u[ 2] = (x2); _u[ 3] = (x3); _u[ 4] = (x4); _u[ 5] = (x5); _u[ 6] = (x6); _u[ 7] = (x7); \
22 128000000 : _u[ 8] = (x8); _u[ 9] = (x9); _u[10] = (xa); _u[11] = (xb); _u[12] = (xc); _u[13] = (xd); _u[14] = (xe); _u[15] = (xf); \
23 2176000000 : for( int _lane=0; _lane<16; _lane++ ) \
24 2048000000 : if( FD_UNLIKELY( _t[_lane]!=_u[_lane] ) ) \
25 2048000000 : FD_LOG_ERR(( "FAIL: %s @ lane %i\n\t" \
26 128000000 : " got 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x " \
27 128000000 : "0x%08x 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x\n\t" \
28 128000000 : " exp 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x " \
29 128000000 : "0x%08x 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x", \
30 128000000 : #x, _lane, \
31 128000000 : (uint)_t[ 0], (uint)_t[ 1], (uint)_t[ 2], (uint)_t[ 3], (uint)_t[ 4], (uint)_t[ 5], (uint)_t[ 6], (uint)_t[ 7], \
32 128000000 : (uint)_t[ 8], (uint)_t[ 9], (uint)_t[10], (uint)_t[11], (uint)_t[12], (uint)_t[13], (uint)_t[14], (uint)_t[15], \
33 128000000 : (uint)_u[ 0], (uint)_u[ 1], (uint)_u[ 2], (uint)_u[ 3], (uint)_u[ 4], (uint)_u[ 5], (uint)_u[ 6], (uint)_u[ 7], \
34 128000000 : (uint)_u[ 8], (uint)_u[ 9], (uint)_u[10], (uint)_u[11], (uint)_u[12], (uint)_u[13], (uint)_u[14], (uint)_u[15] )); \
35 128000000 : } while(0)
36 :
37 127000000 : #define WWU_TEST( x, x0,x1,x2,x3,x4,x5,x6,x7,x8,x9,xa,xb,xc,xd,xe,xf ) do { \
38 127000000 : uint _t[16] WW_ATTR; \
39 127000000 : uint _u[16] WW_ATTR; \
40 127000000 : wwu_st( _t, (x) ); \
41 127000000 : _u[ 0] = (x0); _u[ 1] = (x1); _u[ 2] = (x2); _u[ 3] = (x3); _u[ 4] = (x4); _u[ 5] = (x5); _u[ 6] = (x6); _u[ 7] = (x7); \
42 127000000 : _u[ 8] = (x8); _u[ 9] = (x9); _u[10] = (xa); _u[11] = (xb); _u[12] = (xc); _u[13] = (xd); _u[14] = (xe); _u[15] = (xf); \
43 2159000000 : for( int _lane=0; _lane<16; _lane++ ) \
44 2032000000 : if( FD_UNLIKELY( _t[_lane]!=_u[_lane] ) ) \
45 2032000000 : FD_LOG_ERR(( "FAIL: %s @ lane %i\n\t" \
46 127000000 : " got 0x%08xU 0x%08xU 0x%08xU 0x%08xU 0x%08xU 0x%08xU 0x%08xU 0x%08xU " \
47 127000000 : "0x%08xU 0x%08xU 0x%08xU 0x%08xU 0x%08xU 0x%08xU 0x%08xU 0x%08xU\n\t" \
48 127000000 : " exp 0x%08xU 0x%08xU 0x%08xU 0x%08xU 0x%08xU 0x%08xU 0x%08xU 0x%08xU " \
49 127000000 : "0x%08xU 0x%08xU 0x%08xU 0x%08xU 0x%08xU 0x%08xU 0x%08xU 0x%08xU", \
50 127000000 : #x, _lane, \
51 127000000 : _t[ 0], _t[ 1], _t[ 2], _t[ 3], _t[ 4], _t[ 5], _t[ 6], _t[ 7], \
52 127000000 : _t[ 8], _t[ 9], _t[10], _t[11], _t[12], _t[13], _t[14], _t[15], \
53 127000000 : _u[ 0], _u[ 1], _u[ 2], _u[ 3], _u[ 4], _u[ 5], _u[ 6], _u[ 7], \
54 127000000 : _u[ 8], _u[ 9], _u[10], _u[11], _u[12], _u[13], _u[14], _u[15] )); \
55 127000000 : } while(0)
56 :
57 189000000 : #define WWL_TEST( x, x0,x1,x2,x3,x4,x5,x6,x7 ) do { \
58 189000000 : long _t[8] WW_ATTR; \
59 189000000 : long _u[8] WW_ATTR; \
60 189000000 : wwl_st( _t, (x) ); \
61 189000000 : _u[0] = (x0); _u[1] = (x1); _u[2] = (x2); _u[3] = (x3); _u[4] = (x4); _u[5] = (x5); _u[6] = (x6); _u[7] = (x7); \
62 1701000000 : for( int _lane=0; _lane<8; _lane++ ) \
63 1512000000 : if( FD_UNLIKELY( _t[_lane]!=_u[_lane] ) ) \
64 1512000000 : FD_LOG_ERR(( "FAIL: %s @ lane %i\n\t" \
65 189000000 : " got 0x%016lxL 0x%016lxL 0x%016lxL 0x%016lxL 0x%016lxL 0x%016lxL 0x%016lxL 0x%016lxL\n\t" \
66 189000000 : " exp 0x%016lxL 0x%016lxL 0x%016lxL 0x%016lxL 0x%016lxL 0x%016lxL 0x%016lxL 0x%016lxL", \
67 189000000 : #x, _lane, \
68 189000000 : (ulong)_t[0], (ulong)_t[1], (ulong)_t[2], (ulong)_t[3], \
69 189000000 : (ulong)_t[4], (ulong)_t[5], (ulong)_t[6], (ulong)_t[7], \
70 189000000 : (ulong)_u[0], (ulong)_u[1], (ulong)_u[2], (ulong)_u[3], \
71 189000000 : (ulong)_u[4], (ulong)_u[5], (ulong)_u[6], (ulong)_u[7] )); \
72 189000000 : } while(0)
73 :
74 188000000 : #define WWV_TEST( x, x0,x1,x2,x3,x4,x5,x6,x7 ) do { \
75 188000000 : ulong _t[8] WW_ATTR; \
76 188000000 : ulong _u[8] WW_ATTR; \
77 188000000 : wwv_st( _t, (x) ); \
78 188000000 : _u[0] = (x0); _u[1] = (x1); _u[2] = (x2); _u[3] = (x3); _u[4] = (x4); _u[5] = (x5); _u[6] = (x6); _u[7] = (x7); \
79 1692000000 : for( int _lane=0; _lane<8; _lane++ ) \
80 1504000000 : if( FD_UNLIKELY( _t[_lane]!=_u[_lane] ) ) \
81 1504000000 : FD_LOG_ERR(( "FAIL: %s @ lane %i\n\t" \
82 188000000 : " got 0x%016lxUL 0x%016lxUL 0x%016lxUL 0x%016lxUL 0x%016lxUL 0x%016lxUL 0x%016lxUL 0x%016lxUL\n\t" \
83 188000000 : " exp 0x%016lxUL 0x%016lxUL 0x%016lxUL 0x%016lxUL 0x%016lxUL 0x%016lxUL 0x%016lxUL 0x%016lxUL", \
84 188000000 : #x, _lane, \
85 188000000 : _t[0], _t[1], _t[2], _t[3], _t[4], _t[5], _t[6], _t[7], \
86 188000000 : _u[0], _u[1], _u[2], _u[3], _u[4], _u[5], _u[6], _u[7] )); \
87 188000000 : } while(0)
88 :
89 :
90 : /* Some utility macros for testing functions that need compile time
91 : values.
92 : EXPAND_n( F, j ) expands F n times with j, j+1, ..., j+n-1 as the
93 : argument (not a literal, but a compile time constant).
94 :
95 : COMPARE_n( C, p, fn1, fn2, j ) uses comparator function C to test the
96 : result of fn1(p, j) against fn2(p0, j), fn2(p1, j), ... fn3(p{n-1},
97 : j), where the counters for p, the prefix, are in hex. C must take
98 : n+1 arguments. */
99 :
100 96000000 : #define EXPAND_4( F, j) F(j) F((j)+1) F((j)+2) F((j)+3)
101 24000000 : #define EXPAND_16(F, j) EXPAND_4( F, (j)) EXPAND_4( F, (j)+ 4) EXPAND_4( F, (j)+ 8) EXPAND_4( F, (j)+12)
102 12000000 : #define EXPAND_32(F, j) EXPAND_16(F, (j)) EXPAND_16(F, (j)+16)
103 4000000 : #define EXPAND_64(F, j) EXPAND_32(F, (j)) EXPAND_32(F, (j)+32)
104 :
105 256000000 : #define COMPARE8( C, p, fn1, fn2, j) C( fn1(p, j), fn2( p##0, j ), fn2( p##1, j ), fn2( p##2, j ), fn2( p##3, j ), \
106 256000000 : fn2( p##4, j ), fn2( p##5, j ), fn2( p##6, j ), fn2( p##7, j ) )
107 :
108 128000000 : #define COMPARE16(C, p, fn1, fn2, j) C( fn1(p, j), fn2( p##0, j ), fn2( p##1, j ), fn2( p##2, j ), fn2( p##3, j ), \
109 128000000 : fn2( p##4, j ), fn2( p##5, j ), fn2( p##6, j ), fn2( p##7, j ), \
110 128000000 : fn2( p##8, j ), fn2( p##9, j ), fn2( p##a, j ), fn2( p##b, j ), \
111 128000000 : fn2( p##c, j ), fn2( p##d, j ), fn2( p##e, j ), fn2( p##f, j ) )
112 :
113 :
114 : #endif /* HEADER_fd_src_util_simd_test_avx512_h */
|