1 /*
2 * Test program for MSA instruction SRA.B
3 *
4 * Copyright (C) 2019 Wave Computing, Inc.
5 * Copyright (C) 2019 Aleksandar Markovic <amarkovic@wavecomp.com>
6 *
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.
11 *
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.
16 *
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/>.
19 *
20 */
21
22 #include <sys/time.h>
23 #include <stdint.h>
24
25 #include "../../../../include/wrappers_msa.h"
26 #include "../../../../include/test_inputs_128.h"
27 #include "../../../../include/test_utils_128.h"
28
29 #define TEST_COUNT_TOTAL ( \
30 (PATTERN_INPUTS_SHORT_COUNT) * (PATTERN_INPUTS_SHORT_COUNT) + \
31 (RANDOM_INPUTS_SHORT_COUNT) * (RANDOM_INPUTS_SHORT_COUNT))
32
33
main(void)34 int32_t main(void)
35 {
36 char *isa_ase_name = "MSA";
37 char *group_name = "Shift";
38 char *instruction_name = "SRA.B";
39 int32_t ret;
40 uint32_t i, j;
41 struct timeval start, end;
42 double elapsed_time;
43
44 uint64_t b128_result[TEST_COUNT_TOTAL][2];
45 uint64_t b128_expect[TEST_COUNT_TOTAL][2] = {
46 { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, /* 0 */
47 { 0xffffffffffffffffULL, 0xffffffffffffffffULL, },
48 { 0xffffffffffffffffULL, 0xffffffffffffffffULL, },
49 { 0xffffffffffffffffULL, 0xffffffffffffffffULL, },
50 { 0xffffffffffffffffULL, 0xffffffffffffffffULL, },
51 { 0xffffffffffffffffULL, 0xffffffffffffffffULL, },
52 { 0xffffffffffffffffULL, 0xffffffffffffffffULL, },
53 { 0xffffffffffffffffULL, 0xffffffffffffffffULL, },
54 { 0x0000000000000000ULL, 0x0000000000000000ULL, }, /* 8 */
55 { 0x0000000000000000ULL, 0x0000000000000000ULL, },
56 { 0x0000000000000000ULL, 0x0000000000000000ULL, },
57 { 0x0000000000000000ULL, 0x0000000000000000ULL, },
58 { 0x0000000000000000ULL, 0x0000000000000000ULL, },
59 { 0x0000000000000000ULL, 0x0000000000000000ULL, },
60 { 0x0000000000000000ULL, 0x0000000000000000ULL, },
61 { 0x0000000000000000ULL, 0x0000000000000000ULL, },
62 { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, /* 16 */
63 { 0xaaaaaaaaaaaaaaaaULL, 0xaaaaaaaaaaaaaaaaULL, },
64 { 0xeaeaeaeaeaeaeaeaULL, 0xeaeaeaeaeaeaeaeaULL, },
65 { 0xfdfdfdfdfdfdfdfdULL, 0xfdfdfdfdfdfdfdfdULL, },
66 { 0xfafafafafafafafaULL, 0xfafafafafafafafaULL, },
67 { 0xf5f5f5f5f5f5f5f5ULL, 0xf5f5f5f5f5f5f5f5ULL, },
68 { 0xf5feaaf5feaaf5feULL, 0xaaf5feaaf5feaaf5ULL, },
69 { 0xfad5fffad5fffad5ULL, 0xfffad5fffad5fffaULL, },
70 { 0x0000000000000000ULL, 0x0000000000000000ULL, }, /* 24 */
71 { 0x5555555555555555ULL, 0x5555555555555555ULL, },
72 { 0x1515151515151515ULL, 0x1515151515151515ULL, },
73 { 0x0202020202020202ULL, 0x0202020202020202ULL, },
74 { 0x0505050505050505ULL, 0x0505050505050505ULL, },
75 { 0x0a0a0a0a0a0a0a0aULL, 0x0a0a0a0a0a0a0a0aULL, },
76 { 0x0a01550a01550a01ULL, 0x550a01550a01550aULL, },
77 { 0x052a00052a00052aULL, 0x00052a00052a0005ULL, },
78 { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, /* 32 */
79 { 0xccccccccccccccccULL, 0xccccccccccccccccULL, },
80 { 0xf3f3f3f3f3f3f3f3ULL, 0xf3f3f3f3f3f3f3f3ULL, },
81 { 0xfefefefefefefefeULL, 0xfefefefefefefefeULL, },
82 { 0xfcfcfcfcfcfcfcfcULL, 0xfcfcfcfcfcfcfcfcULL, },
83 { 0xf9f9f9f9f9f9f9f9ULL, 0xf9f9f9f9f9f9f9f9ULL, },
84 { 0xf9ffccf9ffccf9ffULL, 0xccf9ffccf9ffccf9ULL, },
85 { 0xfce6fffce6fffce6ULL, 0xfffce6fffce6fffcULL, },
86 { 0x0000000000000000ULL, 0x0000000000000000ULL, }, /* 40 */
87 { 0x3333333333333333ULL, 0x3333333333333333ULL, },
88 { 0x0c0c0c0c0c0c0c0cULL, 0x0c0c0c0c0c0c0c0cULL, },
89 { 0x0101010101010101ULL, 0x0101010101010101ULL, },
90 { 0x0303030303030303ULL, 0x0303030303030303ULL, },
91 { 0x0606060606060606ULL, 0x0606060606060606ULL, },
92 { 0x0600330600330600ULL, 0x3306003306003306ULL, },
93 { 0x0319000319000319ULL, 0x0003190003190003ULL, },
94 { 0xffff00ffff00ffffULL, 0x00ffff00ffff00ffULL, }, /* 48 */
95 { 0xe38e38e38e38e38eULL, 0x38e38e38e38e38e3ULL, },
96 { 0xf8e30ef8e30ef8e3ULL, 0x0ef8e30ef8e30ef8ULL, },
97 { 0xfffc01fffc01fffcULL, 0x01fffc01fffc01ffULL, },
98 { 0xfef803fef803fef8ULL, 0x03fef803fef803feULL, },
99 { 0xfcf107fcf107fcf1ULL, 0x07fcf107fcf107fcULL, },
100 { 0xfcfe38fcfe38fcfeULL, 0x38fcfe38fcfe38fcULL, },
101 { 0xfec700fec700fec7ULL, 0x00fec700fec700feULL, },
102 { 0x0000ff0000ff0000ULL, 0xff0000ff0000ff00ULL, }, /* 56 */
103 { 0x1c71c71c71c71c71ULL, 0xc71c71c71c71c71cULL, },
104 { 0x071cf1071cf1071cULL, 0xf1071cf1071cf107ULL, },
105 { 0x0003fe0003fe0003ULL, 0xfe0003fe0003fe00ULL, },
106 { 0x0107fc0107fc0107ULL, 0xfc0107fc0107fc01ULL, },
107 { 0x030ef8030ef8030eULL, 0xf8030ef8030ef803ULL, },
108 { 0x0301c70301c70301ULL, 0xc70301c70301c703ULL, },
109 { 0x0138ff0138ff0138ULL, 0xff0138ff0138ff01ULL, },
110 { 0x881afffc28180240ULL, 0x09000101ff0fb000ULL, }, /* 64 */
111 { 0xf101e6f9010c0040ULL, 0x12000117ff00ec00ULL, },
112 { 0xf81afff314000a40ULL, 0x00670000ff0ffd00ULL, },
113 { 0x8800fffe00311501ULL, 0x02330b5eff1eec0cULL, },
114 { 0xfbef00064de4fe08ULL, 0x02fff700000752ffULL, },
115 { 0xfffe000c02f2ff08ULL, 0x04fff706000014ffULL, },
116 { 0xffef001826fff808ULL, 0x00f7fe00020702ffULL, },
117 { 0xfbff000301c9f100ULL, 0x00fbbb1a0a0f14fcULL, },
118 { 0xac16fefab9f3fc80ULL, 0x04fff8fffe052501ULL, }, /* 72 */
119 { 0xf501aef5fdf9ff80ULL, 0x09fff8fffd000901ULL, },
120 { 0xfa16feeadcfff180ULL, 0x00d8fffff5050101ULL, },
121 { 0xac00fefdfee7e2feULL, 0x01ecc6ffd50a0914ULL, },
122 { 0x701300045e0cff4eULL, 0xf1fff1fffe08e2faULL, },
123 { 0x0e0116090206ff4eULL, 0xe3fff1f6fd00f8faULL, },
124 { 0x071300132f00fc4eULL, 0xfff1fefff508fffaULL, },
125 { 0x700000020118f801ULL, 0xfcf888d8d410f8a0ULL, },
126 };
127
128 reset_msa_registers();
129
130 gettimeofday(&start, NULL);
131
132 for (i = 0; i < PATTERN_INPUTS_SHORT_COUNT; i++) {
133 for (j = 0; j < PATTERN_INPUTS_SHORT_COUNT; j++) {
134 do_msa_SRA_B(b128_pattern[i], b128_pattern[j],
135 b128_result[PATTERN_INPUTS_SHORT_COUNT * i + j]);
136 }
137 }
138
139 for (i = 0; i < RANDOM_INPUTS_SHORT_COUNT; i++) {
140 for (j = 0; j < RANDOM_INPUTS_SHORT_COUNT; j++) {
141 do_msa_SRA_B(b128_random[i], b128_random[j],
142 b128_result[((PATTERN_INPUTS_SHORT_COUNT) *
143 (PATTERN_INPUTS_SHORT_COUNT)) +
144 RANDOM_INPUTS_SHORT_COUNT * i + j]);
145 }
146 }
147
148 gettimeofday(&end, NULL);
149
150 elapsed_time = (end.tv_sec - start.tv_sec) * 1000.0;
151 elapsed_time += (end.tv_usec - start.tv_usec) / 1000.0;
152
153 ret = check_results_128(isa_ase_name, group_name, instruction_name,
154 TEST_COUNT_TOTAL, elapsed_time,
155 &b128_result[0][0], &b128_expect[0][0]);
156
157 return ret;
158 }
159