1 /*
2  *  Test program for MSA instruction SLL.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 =  "SLL.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         { 0x8080808080808080ULL, 0x8080808080808080ULL, },    /*   0  */
47         { 0xffffffffffffffffULL, 0xffffffffffffffffULL, },
48         { 0xfcfcfcfcfcfcfcfcULL, 0xfcfcfcfcfcfcfcfcULL, },
49         { 0xe0e0e0e0e0e0e0e0ULL, 0xe0e0e0e0e0e0e0e0ULL, },
50         { 0xf0f0f0f0f0f0f0f0ULL, 0xf0f0f0f0f0f0f0f0ULL, },
51         { 0xf8f8f8f8f8f8f8f8ULL, 0xf8f8f8f8f8f8f8f8ULL, },
52         { 0xf8c0fff8c0fff8c0ULL, 0xfff8c0fff8c0fff8ULL, },
53         { 0xf0fe80f0fe80f0feULL, 0x80f0fe80f0fe80f0ULL, },
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         { 0x0000000000000000ULL, 0x0000000000000000ULL, },    /*  16  */
63         { 0xaaaaaaaaaaaaaaaaULL, 0xaaaaaaaaaaaaaaaaULL, },
64         { 0xa8a8a8a8a8a8a8a8ULL, 0xa8a8a8a8a8a8a8a8ULL, },
65         { 0x4040404040404040ULL, 0x4040404040404040ULL, },
66         { 0xa0a0a0a0a0a0a0a0ULL, 0xa0a0a0a0a0a0a0a0ULL, },
67         { 0x5050505050505050ULL, 0x5050505050505050ULL, },
68         { 0x5080aa5080aa5080ULL, 0xaa5080aa5080aa50ULL, },
69         { 0xa05400a05400a054ULL, 0x00a05400a05400a0ULL, },
70         { 0x8080808080808080ULL, 0x8080808080808080ULL, },    /*  24  */
71         { 0x5555555555555555ULL, 0x5555555555555555ULL, },
72         { 0x5454545454545454ULL, 0x5454545454545454ULL, },
73         { 0xa0a0a0a0a0a0a0a0ULL, 0xa0a0a0a0a0a0a0a0ULL, },
74         { 0x5050505050505050ULL, 0x5050505050505050ULL, },
75         { 0xa8a8a8a8a8a8a8a8ULL, 0xa8a8a8a8a8a8a8a8ULL, },
76         { 0xa84055a84055a840ULL, 0x55a84055a84055a8ULL, },
77         { 0x50aa8050aa8050aaULL, 0x8050aa8050aa8050ULL, },
78         { 0x0000000000000000ULL, 0x0000000000000000ULL, },    /*  32  */
79         { 0xccccccccccccccccULL, 0xccccccccccccccccULL, },
80         { 0x3030303030303030ULL, 0x3030303030303030ULL, },
81         { 0x8080808080808080ULL, 0x8080808080808080ULL, },
82         { 0xc0c0c0c0c0c0c0c0ULL, 0xc0c0c0c0c0c0c0c0ULL, },
83         { 0x6060606060606060ULL, 0x6060606060606060ULL, },
84         { 0x6000cc6000cc6000ULL, 0xcc6000cc6000cc60ULL, },
85         { 0xc09800c09800c098ULL, 0x00c09800c09800c0ULL, },
86         { 0x8080808080808080ULL, 0x8080808080808080ULL, },    /*  40  */
87         { 0x3333333333333333ULL, 0x3333333333333333ULL, },
88         { 0xccccccccccccccccULL, 0xccccccccccccccccULL, },
89         { 0x6060606060606060ULL, 0x6060606060606060ULL, },
90         { 0x3030303030303030ULL, 0x3030303030303030ULL, },
91         { 0x9898989898989898ULL, 0x9898989898989898ULL, },
92         { 0x98c03398c03398c0ULL, 0x3398c03398c03398ULL, },
93         { 0x3066803066803066ULL, 0x8030668030668030ULL, },
94         { 0x8000008000008000ULL, 0x0080000080000080ULL, },    /*  48  */
95         { 0xe38e38e38e38e38eULL, 0x38e38e38e38e38e3ULL, },
96         { 0x8c38e08c38e08c38ULL, 0xe08c38e08c38e08cULL, },
97         { 0x60c00060c00060c0ULL, 0x0060c00060c00060ULL, },
98         { 0x30e08030e08030e0ULL, 0x8030e08030e08030ULL, },
99         { 0x1870c01870c01870ULL, 0xc01870c01870c018ULL, },
100         { 0x1880381880381880ULL, 0x3818803818803818ULL, },
101         { 0x301c00301c00301cULL, 0x00301c00301c0030ULL, },
102         { 0x0080800080800080ULL, 0x8000808000808000ULL, },    /*  56  */
103         { 0x1c71c71c71c71c71ULL, 0xc71c71c71c71c71cULL, },
104         { 0x70c41c70c41c70c4ULL, 0x1c70c41c70c41c70ULL, },
105         { 0x8020e08020e08020ULL, 0xe08020e08020e080ULL, },
106         { 0xc01070c01070c010ULL, 0x70c01070c01070c0ULL, },
107         { 0xe08838e08838e088ULL, 0x38e08838e08838e0ULL, },
108         { 0xe040c7e040c7e040ULL, 0xc7e040c7e040c7e0ULL, },
109         { 0xc0e280c0e280c0e2ULL, 0x80c0e280c0e280c0ULL, },
110         { 0x88a880c02888a040ULL, 0x5880588080d8b0c0ULL, },    /*  64  */
111         { 0x4080e66000108040ULL, 0x2c805878c080c0c0ULL, },
112         { 0x80a880305000a840ULL, 0x8067c000f0d800c0ULL, },
113         { 0x8800808000c45400ULL, 0x60ce0b5efcecc00cULL, },
114         { 0xfbf800304d4ce008ULL, 0x9080d88040f852c0ULL, },
115         { 0xd8800018a0988008ULL, 0x4880d868a08048c0ULL, },
116         { 0xb0f8008c9a803808ULL, 0x00f7c000a8f840c0ULL, },
117         { 0xfb00006040261c00ULL, 0x40eebb1a2afc48fcULL, },
118         { 0xac6880a0b93c6080ULL, 0x380030c0c0582540ULL, },    /*  72  */
119         { 0x6080ae5020788080ULL, 0x9c0030fc60809440ULL, },
120         { 0xc06880a872805880ULL, 0x80d880805858a040ULL, },
121         { 0xac008040409e2c00ULL, 0xe0b0c6ff56ac9414ULL, },
122         { 0x703c80d05ec4404eULL, 0x688040004010e200ULL, },
123         { 0x80c01668c088004eULL, 0x3480406020008800ULL, },
124         { 0x003c8034bc80104eULL, 0x80f1000048104000ULL, },
125         { 0x708080a080628880ULL, 0xa0e288d8520888a0ULL, },
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_SLL_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_SLL_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