1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22#ifndef TEST_UTILS_128_H
23#define TEST_UTILS_128_H
24
25#include <stdio.h>
26#include <stdint.h>
27#include <inttypes.h>
28#include <string.h>
29
30#define PRINT_RESULTS 0
31
32
33static inline int32_t check_results_128(const char *isa_ase_name,
34 const char *group_name,
35 const char *instruction_name,
36 const uint32_t test_count,
37 const double elapsed_time,
38 const uint64_t *b128_result,
39 const uint64_t *b128_expect)
40{
41#if PRINT_RESULTS
42 uint32_t ii;
43 printf("\n");
44 for (ii = 0; ii < test_count; ii++) {
45 uint64_t a, b;
46 memcpy(&a, (b128_result + 2 * ii), 8);
47 memcpy(&b, (b128_result + 2 * ii + 1), 8);
48 if (ii % 8 != 0) {
49 printf(" { 0x%016llxULL, 0x%016llxULL, },\n", a, b);
50 } else {
51 printf(" { 0x%016llxULL, 0x%016llxULL, }, /* %3d */\n",
52 a, b, ii);
53 }
54 }
55 printf("\n");
56#endif
57 uint32_t i;
58 uint32_t pass_count = 0;
59 uint32_t fail_count = 0;
60
61 printf("| %-10s \t| %-20s\t| %-16s \t|",
62 isa_ase_name, group_name, instruction_name);
63 for (i = 0; i < test_count; i++) {
64 if ((b128_result[2 * i] == b128_expect[2 * i]) &&
65 (b128_result[2 * i + 1] == b128_expect[2 * i + 1])) {
66 pass_count++;
67 } else {
68 fail_count++;
69 }
70 }
71
72 printf(" PASS: %3d \t| FAIL: %3d \t| elapsed time: %5.2f ms \t|\n",
73 pass_count, fail_count, elapsed_time);
74
75 if (fail_count > 0) {
76 return -1;
77 } else {
78 return 0;
79 }
80}
81
82#endif
83