1fc76f486SAleksandar Markovic /*
2fc76f486SAleksandar Markovic  *  Test program for MSA instruction ILVOD.D
3fc76f486SAleksandar Markovic  *
4dd8d6a2dSAleksandar Markovic  *  Copyright (C) 2019  Wave Computing, Inc.
5dd8d6a2dSAleksandar Markovic  *  Copyright (C) 2019  Aleksandar Markovic <amarkovic@wavecomp.com>
6fc76f486SAleksandar Markovic  *
7fc76f486SAleksandar Markovic  *  This program is free software: you can redistribute it and/or modify
8fc76f486SAleksandar Markovic  *  it under the terms of the GNU General Public License as published by
9fc76f486SAleksandar Markovic  *  the Free Software Foundation, either version 2 of the License, or
10fc76f486SAleksandar Markovic  *  (at your option) any later version.
11fc76f486SAleksandar Markovic  *
12fc76f486SAleksandar Markovic  *  This program is distributed in the hope that it will be useful,
13fc76f486SAleksandar Markovic  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
14fc76f486SAleksandar Markovic  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15fc76f486SAleksandar Markovic  *  GNU General Public License for more details.
16fc76f486SAleksandar Markovic  *
17fc76f486SAleksandar Markovic  *  You should have received a copy of the GNU General Public License
18fc76f486SAleksandar Markovic  *  along with this program.  If not, see <https://www.gnu.org/licenses/>.
19fc76f486SAleksandar Markovic  *
20fc76f486SAleksandar Markovic  */
21fc76f486SAleksandar Markovic 
22fc76f486SAleksandar Markovic #include <sys/time.h>
23fc76f486SAleksandar Markovic #include <stdint.h>
24fc76f486SAleksandar Markovic 
25fc76f486SAleksandar Markovic #include "../../../../include/wrappers_msa.h"
2681526dffSAleksandar Markovic #include "../../../../include/test_inputs_128.h"
2781526dffSAleksandar Markovic #include "../../../../include/test_utils_128.h"
28fc76f486SAleksandar Markovic 
29fc76f486SAleksandar Markovic #define TEST_COUNT_TOTAL (                                                \
30fc76f486SAleksandar Markovic             (PATTERN_INPUTS_SHORT_COUNT) * (PATTERN_INPUTS_SHORT_COUNT) + \
31fc76f486SAleksandar Markovic             (RANDOM_INPUTS_SHORT_COUNT) * (RANDOM_INPUTS_SHORT_COUNT))
32fc76f486SAleksandar Markovic 
33fc76f486SAleksandar Markovic 
main(void)34fc76f486SAleksandar Markovic int32_t main(void)
35fc76f486SAleksandar Markovic {
36*8e6fe6b8SAleksandar Markovic     char *isa_ase_name = "MSA";
37*8e6fe6b8SAleksandar Markovic     char *group_name = "Interleave";
38fc76f486SAleksandar Markovic     char *instruction_name =  "ILVOD.D";
39fc76f486SAleksandar Markovic     int32_t ret;
40fc76f486SAleksandar Markovic     uint32_t i, j;
41fc76f486SAleksandar Markovic     struct timeval start, end;
42fc76f486SAleksandar Markovic     double elapsed_time;
43fc76f486SAleksandar Markovic 
44fc76f486SAleksandar Markovic     uint64_t b128_result[TEST_COUNT_TOTAL][2];
45fc76f486SAleksandar Markovic     uint64_t b128_expect[TEST_COUNT_TOTAL][2] = {
46fc76f486SAleksandar Markovic         { 0xffffffffffffffffULL, 0xffffffffffffffffULL, },    /*   0  */
47fc76f486SAleksandar Markovic         { 0x0000000000000000ULL, 0xffffffffffffffffULL, },
48fc76f486SAleksandar Markovic         { 0xaaaaaaaaaaaaaaaaULL, 0xffffffffffffffffULL, },
49fc76f486SAleksandar Markovic         { 0x5555555555555555ULL, 0xffffffffffffffffULL, },
50fc76f486SAleksandar Markovic         { 0xccccccccccccccccULL, 0xffffffffffffffffULL, },
51fc76f486SAleksandar Markovic         { 0x3333333333333333ULL, 0xffffffffffffffffULL, },
52fc76f486SAleksandar Markovic         { 0x38e38e38e38e38e3ULL, 0xffffffffffffffffULL, },
53fc76f486SAleksandar Markovic         { 0xc71c71c71c71c71cULL, 0xffffffffffffffffULL, },
54fc76f486SAleksandar Markovic         { 0xffffffffffffffffULL, 0x0000000000000000ULL, },    /*   8  */
55fc76f486SAleksandar Markovic         { 0x0000000000000000ULL, 0x0000000000000000ULL, },
56fc76f486SAleksandar Markovic         { 0xaaaaaaaaaaaaaaaaULL, 0x0000000000000000ULL, },
57fc76f486SAleksandar Markovic         { 0x5555555555555555ULL, 0x0000000000000000ULL, },
58fc76f486SAleksandar Markovic         { 0xccccccccccccccccULL, 0x0000000000000000ULL, },
59fc76f486SAleksandar Markovic         { 0x3333333333333333ULL, 0x0000000000000000ULL, },
60fc76f486SAleksandar Markovic         { 0x38e38e38e38e38e3ULL, 0x0000000000000000ULL, },
61fc76f486SAleksandar Markovic         { 0xc71c71c71c71c71cULL, 0x0000000000000000ULL, },
62fc76f486SAleksandar Markovic         { 0xffffffffffffffffULL, 0xaaaaaaaaaaaaaaaaULL, },    /*  16  */
63fc76f486SAleksandar Markovic         { 0x0000000000000000ULL, 0xaaaaaaaaaaaaaaaaULL, },
64fc76f486SAleksandar Markovic         { 0xaaaaaaaaaaaaaaaaULL, 0xaaaaaaaaaaaaaaaaULL, },
65fc76f486SAleksandar Markovic         { 0x5555555555555555ULL, 0xaaaaaaaaaaaaaaaaULL, },
66fc76f486SAleksandar Markovic         { 0xccccccccccccccccULL, 0xaaaaaaaaaaaaaaaaULL, },
67fc76f486SAleksandar Markovic         { 0x3333333333333333ULL, 0xaaaaaaaaaaaaaaaaULL, },
68fc76f486SAleksandar Markovic         { 0x38e38e38e38e38e3ULL, 0xaaaaaaaaaaaaaaaaULL, },
69fc76f486SAleksandar Markovic         { 0xc71c71c71c71c71cULL, 0xaaaaaaaaaaaaaaaaULL, },
70fc76f486SAleksandar Markovic         { 0xffffffffffffffffULL, 0x5555555555555555ULL, },    /*  24  */
71fc76f486SAleksandar Markovic         { 0x0000000000000000ULL, 0x5555555555555555ULL, },
72fc76f486SAleksandar Markovic         { 0xaaaaaaaaaaaaaaaaULL, 0x5555555555555555ULL, },
73fc76f486SAleksandar Markovic         { 0x5555555555555555ULL, 0x5555555555555555ULL, },
74fc76f486SAleksandar Markovic         { 0xccccccccccccccccULL, 0x5555555555555555ULL, },
75fc76f486SAleksandar Markovic         { 0x3333333333333333ULL, 0x5555555555555555ULL, },
76fc76f486SAleksandar Markovic         { 0x38e38e38e38e38e3ULL, 0x5555555555555555ULL, },
77fc76f486SAleksandar Markovic         { 0xc71c71c71c71c71cULL, 0x5555555555555555ULL, },
78fc76f486SAleksandar Markovic         { 0xffffffffffffffffULL, 0xccccccccccccccccULL, },    /*  32  */
79fc76f486SAleksandar Markovic         { 0x0000000000000000ULL, 0xccccccccccccccccULL, },
80fc76f486SAleksandar Markovic         { 0xaaaaaaaaaaaaaaaaULL, 0xccccccccccccccccULL, },
81fc76f486SAleksandar Markovic         { 0x5555555555555555ULL, 0xccccccccccccccccULL, },
82fc76f486SAleksandar Markovic         { 0xccccccccccccccccULL, 0xccccccccccccccccULL, },
83fc76f486SAleksandar Markovic         { 0x3333333333333333ULL, 0xccccccccccccccccULL, },
84fc76f486SAleksandar Markovic         { 0x38e38e38e38e38e3ULL, 0xccccccccccccccccULL, },
85fc76f486SAleksandar Markovic         { 0xc71c71c71c71c71cULL, 0xccccccccccccccccULL, },
86fc76f486SAleksandar Markovic         { 0xffffffffffffffffULL, 0x3333333333333333ULL, },    /*  40  */
87fc76f486SAleksandar Markovic         { 0x0000000000000000ULL, 0x3333333333333333ULL, },
88fc76f486SAleksandar Markovic         { 0xaaaaaaaaaaaaaaaaULL, 0x3333333333333333ULL, },
89fc76f486SAleksandar Markovic         { 0x5555555555555555ULL, 0x3333333333333333ULL, },
90fc76f486SAleksandar Markovic         { 0xccccccccccccccccULL, 0x3333333333333333ULL, },
91fc76f486SAleksandar Markovic         { 0x3333333333333333ULL, 0x3333333333333333ULL, },
92fc76f486SAleksandar Markovic         { 0x38e38e38e38e38e3ULL, 0x3333333333333333ULL, },
93fc76f486SAleksandar Markovic         { 0xc71c71c71c71c71cULL, 0x3333333333333333ULL, },
94fc76f486SAleksandar Markovic         { 0xffffffffffffffffULL, 0x38e38e38e38e38e3ULL, },    /*  48  */
95fc76f486SAleksandar Markovic         { 0x0000000000000000ULL, 0x38e38e38e38e38e3ULL, },
96fc76f486SAleksandar Markovic         { 0xaaaaaaaaaaaaaaaaULL, 0x38e38e38e38e38e3ULL, },
97fc76f486SAleksandar Markovic         { 0x5555555555555555ULL, 0x38e38e38e38e38e3ULL, },
98fc76f486SAleksandar Markovic         { 0xccccccccccccccccULL, 0x38e38e38e38e38e3ULL, },
99fc76f486SAleksandar Markovic         { 0x3333333333333333ULL, 0x38e38e38e38e38e3ULL, },
100fc76f486SAleksandar Markovic         { 0x38e38e38e38e38e3ULL, 0x38e38e38e38e38e3ULL, },
101fc76f486SAleksandar Markovic         { 0xc71c71c71c71c71cULL, 0x38e38e38e38e38e3ULL, },
102fc76f486SAleksandar Markovic         { 0xffffffffffffffffULL, 0xc71c71c71c71c71cULL, },    /*  56  */
103fc76f486SAleksandar Markovic         { 0x0000000000000000ULL, 0xc71c71c71c71c71cULL, },
104fc76f486SAleksandar Markovic         { 0xaaaaaaaaaaaaaaaaULL, 0xc71c71c71c71c71cULL, },
105fc76f486SAleksandar Markovic         { 0x5555555555555555ULL, 0xc71c71c71c71c71cULL, },
106fc76f486SAleksandar Markovic         { 0xccccccccccccccccULL, 0xc71c71c71c71c71cULL, },
107fc76f486SAleksandar Markovic         { 0x3333333333333333ULL, 0xc71c71c71c71c71cULL, },
108fc76f486SAleksandar Markovic         { 0x38e38e38e38e38e3ULL, 0xc71c71c71c71c71cULL, },
109fc76f486SAleksandar Markovic         { 0xc71c71c71c71c71cULL, 0xc71c71c71c71c71cULL, },
110fc76f486SAleksandar Markovic         { 0x4b670b5efe7bb00cULL, 0x4b670b5efe7bb00cULL, },    /*  64  */
111fc76f486SAleksandar Markovic         { 0x12f7bb1a153f52fcULL, 0x4b670b5efe7bb00cULL, },
112fc76f486SAleksandar Markovic         { 0x27d8c6ffab2b2514ULL, 0x4b670b5efe7bb00cULL, },
113fc76f486SAleksandar Markovic         { 0x8df188d8a942e2a0ULL, 0x4b670b5efe7bb00cULL, },
114fc76f486SAleksandar Markovic         { 0x4b670b5efe7bb00cULL, 0x12f7bb1a153f52fcULL, },
115fc76f486SAleksandar Markovic         { 0x12f7bb1a153f52fcULL, 0x12f7bb1a153f52fcULL, },
116fc76f486SAleksandar Markovic         { 0x27d8c6ffab2b2514ULL, 0x12f7bb1a153f52fcULL, },
117fc76f486SAleksandar Markovic         { 0x8df188d8a942e2a0ULL, 0x12f7bb1a153f52fcULL, },
118fc76f486SAleksandar Markovic         { 0x4b670b5efe7bb00cULL, 0x27d8c6ffab2b2514ULL, },    /*  72  */
119fc76f486SAleksandar Markovic         { 0x12f7bb1a153f52fcULL, 0x27d8c6ffab2b2514ULL, },
120fc76f486SAleksandar Markovic         { 0x27d8c6ffab2b2514ULL, 0x27d8c6ffab2b2514ULL, },
121fc76f486SAleksandar Markovic         { 0x8df188d8a942e2a0ULL, 0x27d8c6ffab2b2514ULL, },
122fc76f486SAleksandar Markovic         { 0x4b670b5efe7bb00cULL, 0x8df188d8a942e2a0ULL, },
123fc76f486SAleksandar Markovic         { 0x12f7bb1a153f52fcULL, 0x8df188d8a942e2a0ULL, },
124fc76f486SAleksandar Markovic         { 0x27d8c6ffab2b2514ULL, 0x8df188d8a942e2a0ULL, },
125fc76f486SAleksandar Markovic         { 0x8df188d8a942e2a0ULL, 0x8df188d8a942e2a0ULL, },
126fc76f486SAleksandar Markovic     };
127fc76f486SAleksandar Markovic 
128ca693d1cSAleksandar Markovic     reset_msa_registers();
129ca693d1cSAleksandar Markovic 
130fc76f486SAleksandar Markovic     gettimeofday(&start, NULL);
131fc76f486SAleksandar Markovic 
132fc76f486SAleksandar Markovic     for (i = 0; i < PATTERN_INPUTS_SHORT_COUNT; i++) {
133fc76f486SAleksandar Markovic         for (j = 0; j < PATTERN_INPUTS_SHORT_COUNT; j++) {
134fc76f486SAleksandar Markovic             do_msa_ILVOD_D(b128_pattern[i], b128_pattern[j],
135fc76f486SAleksandar Markovic                            b128_result[PATTERN_INPUTS_SHORT_COUNT * i + j]);
136fc76f486SAleksandar Markovic         }
137fc76f486SAleksandar Markovic     }
138fc76f486SAleksandar Markovic 
139fc76f486SAleksandar Markovic     for (i = 0; i < RANDOM_INPUTS_SHORT_COUNT; i++) {
140fc76f486SAleksandar Markovic         for (j = 0; j < RANDOM_INPUTS_SHORT_COUNT; j++) {
141fc76f486SAleksandar Markovic             do_msa_ILVOD_D(b128_random[i], b128_random[j],
142fc76f486SAleksandar Markovic                            b128_result[((PATTERN_INPUTS_SHORT_COUNT) *
143fc76f486SAleksandar Markovic                                         (PATTERN_INPUTS_SHORT_COUNT)) +
144fc76f486SAleksandar Markovic                                        RANDOM_INPUTS_SHORT_COUNT * i + j]);
145fc76f486SAleksandar Markovic         }
146fc76f486SAleksandar Markovic     }
147fc76f486SAleksandar Markovic 
148fc76f486SAleksandar Markovic     gettimeofday(&end, NULL);
149fc76f486SAleksandar Markovic 
150fc76f486SAleksandar Markovic     elapsed_time = (end.tv_sec - start.tv_sec) * 1000.0;
151fc76f486SAleksandar Markovic     elapsed_time += (end.tv_usec - start.tv_usec) / 1000.0;
152fc76f486SAleksandar Markovic 
153*8e6fe6b8SAleksandar Markovic     ret = check_results_128(isa_ase_name, group_name, instruction_name,
154*8e6fe6b8SAleksandar Markovic                             TEST_COUNT_TOTAL, elapsed_time,
155fc76f486SAleksandar Markovic                             &b128_result[0][0], &b128_expect[0][0]);
156fc76f486SAleksandar Markovic 
157fc76f486SAleksandar Markovic     return ret;
158fc76f486SAleksandar Markovic }
159