1ace44584SAleksandar Markovic /*
2ace44584SAleksandar Markovic * Header file for test utilities
3ace44584SAleksandar Markovic *
4ace44584SAleksandar Markovic * Copyright (C) 2019 Wave Computing, Inc.
5ace44584SAleksandar Markovic * Copyright (C) 2019 Aleksandar Markovic <amarkovic@wavecomp.com>
6ace44584SAleksandar Markovic *
7ace44584SAleksandar Markovic * This program is free software: you can redistribute it and/or modify
8ace44584SAleksandar Markovic * it under the terms of the GNU General Public License as published by
9ace44584SAleksandar Markovic * the Free Software Foundation, either version 2 of the License, or
10ace44584SAleksandar Markovic * (at your option) any later version.
11ace44584SAleksandar Markovic *
12ace44584SAleksandar Markovic * This program is distributed in the hope that it will be useful,
13ace44584SAleksandar Markovic * but WITHOUT ANY WARRANTY; without even the implied warranty of
14ace44584SAleksandar Markovic * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15ace44584SAleksandar Markovic * GNU General Public License for more details.
16ace44584SAleksandar Markovic *
17ace44584SAleksandar Markovic * You should have received a copy of the GNU General Public License
18ace44584SAleksandar Markovic * along with this program. If not, see <https://www.gnu.org/licenses/>.
19ace44584SAleksandar Markovic *
20ace44584SAleksandar Markovic */
21ace44584SAleksandar Markovic
22ace44584SAleksandar Markovic #ifndef TEST_UTILS_64_H
23ace44584SAleksandar Markovic #define TEST_UTILS_64_H
24ace44584SAleksandar Markovic
25ace44584SAleksandar Markovic #include <stdio.h>
26ace44584SAleksandar Markovic #include <stdint.h>
27ace44584SAleksandar Markovic #include <inttypes.h>
28ace44584SAleksandar Markovic #include <string.h>
29ace44584SAleksandar Markovic
30ace44584SAleksandar Markovic #define PRINT_RESULTS 0
31ace44584SAleksandar Markovic
32ace44584SAleksandar Markovic
check_results_64(const char * isa_ase_name,const char * group_name,const char * instruction_name,const uint32_t test_count,const double elapsed_time,const uint64_t * b64_result,const uint64_t * b64_expect)33*8e6fe6b8SAleksandar Markovic static inline int32_t check_results_64(const char *isa_ase_name,
34*8e6fe6b8SAleksandar Markovic const char *group_name,
35*8e6fe6b8SAleksandar Markovic const char *instruction_name,
36ace44584SAleksandar Markovic const uint32_t test_count,
37ace44584SAleksandar Markovic const double elapsed_time,
38ace44584SAleksandar Markovic const uint64_t *b64_result,
39ace44584SAleksandar Markovic const uint64_t *b64_expect)
40ace44584SAleksandar Markovic {
41ace44584SAleksandar Markovic #if PRINT_RESULTS
42ace44584SAleksandar Markovic uint32_t ii;
43ace44584SAleksandar Markovic printf("\n");
44ace44584SAleksandar Markovic for (ii = 0; ii < test_count; ii++) {
45ace44584SAleksandar Markovic uint64_t a;
46ace44584SAleksandar Markovic memcpy(&a, (b64_result + ii), 8);
47ace44584SAleksandar Markovic if (ii % 8 != 0) {
48ace44584SAleksandar Markovic printf(" 0x%016llxULL,\n", a);
49ace44584SAleksandar Markovic } else {
50ace44584SAleksandar Markovic printf(" 0x%016llxULL, /* %3d */\n",
51ace44584SAleksandar Markovic a, ii);
52ace44584SAleksandar Markovic }
53ace44584SAleksandar Markovic }
54ace44584SAleksandar Markovic printf("\n");
55ace44584SAleksandar Markovic #endif
56ace44584SAleksandar Markovic uint32_t i;
57ace44584SAleksandar Markovic uint32_t pass_count = 0;
58ace44584SAleksandar Markovic uint32_t fail_count = 0;
59ace44584SAleksandar Markovic
60*8e6fe6b8SAleksandar Markovic printf("| %-10s \t| %-20s\t| %-16s \t|",
61*8e6fe6b8SAleksandar Markovic isa_ase_name, group_name, instruction_name);
62ace44584SAleksandar Markovic for (i = 0; i < test_count; i++) {
63ace44584SAleksandar Markovic if (b64_result[i] == b64_expect[i]) {
64ace44584SAleksandar Markovic pass_count++;
65ace44584SAleksandar Markovic } else {
66ace44584SAleksandar Markovic fail_count++;
67ace44584SAleksandar Markovic }
68ace44584SAleksandar Markovic }
69ace44584SAleksandar Markovic
70*8e6fe6b8SAleksandar Markovic printf(" PASS: %3d \t| FAIL: %3d \t| elapsed time: %5.2f ms \t|\n",
71ace44584SAleksandar Markovic pass_count, fail_count, elapsed_time);
72ace44584SAleksandar Markovic
73ace44584SAleksandar Markovic if (fail_count > 0) {
74ace44584SAleksandar Markovic return -1;
75ace44584SAleksandar Markovic } else {
76ace44584SAleksandar Markovic return 0;
77ace44584SAleksandar Markovic }
78ace44584SAleksandar Markovic }
79ace44584SAleksandar Markovic
80ace44584SAleksandar Markovic
81ace44584SAleksandar Markovic #endif
82