2 * Header file for test utilities
4 * Copyright (C) 2019 Wave Computing, Inc.
5 * Copyright (C) 2019 Aleksandar Markovic <amarkovic@wavecomp.com>
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
22 #ifndef TEST_UTILS_128_H
23 #define TEST_UTILS_128_H
30 #define PRINT_RESULTS 0
31 #define PRINT_FAILURES 0
34 static inline int32_t check_results_128(const char *isa_ase_name
,
35 const char *group_name
,
36 const char *instruction_name
,
37 const uint32_t test_count
,
38 const double elapsed_time
,
39 const uint64_t *b128_result
,
40 const uint64_t *b128_expect
)
45 for (ii
= 0; ii
< test_count
; ii
++) {
47 memcpy(&a
, (b128_result
+ 2 * ii
), 8);
48 memcpy(&b
, (b128_result
+ 2 * ii
+ 1), 8);
50 printf(" { 0x%016llxULL, 0x%016llxULL, },\n", a
, b
);
52 printf(" { 0x%016llxULL, 0x%016llxULL, }, /* %3d */\n",
59 uint32_t pass_count
= 0;
60 uint32_t fail_count
= 0;
62 printf("| %-10s \t| %-20s\t| %-16s \t|",
63 isa_ase_name
, group_name
, instruction_name
);
64 for (i
= 0; i
< test_count
; i
++) {
65 if ((b128_result
[2 * i
] == b128_expect
[2 * i
]) &&
66 (b128_result
[2 * i
+ 1] == b128_expect
[2 * i
+ 1])) {
75 printf("FAILURE for test case %d!\n", i
);
77 memcpy(&a
, (b128_expect
+ 2 * i
), 8);
78 memcpy(&b
, (b128_expect
+ 2 * i
+ 1), 8);
79 printf("Expected result : { 0x%016llxULL, 0x%016llxULL, },\n",
82 memcpy(&a
, (b128_result
+ 2 * i
), 8);
83 memcpy(&b
, (b128_result
+ 2 * i
+ 1), 8);
84 printf("Actual result : { 0x%016llxULL, 0x%016llxULL, },\n",
93 printf(" PASS: %3d \t| FAIL: %3d \t| elapsed time: %5.2f ms \t|\n",
94 pass_count
, fail_count
, elapsed_time
);