1520e210cSAleksandar Markovic /*
2520e210cSAleksandar Markovic  *  Test program for MSA instruction CLT_S.D
3520e210cSAleksandar Markovic  *
4dd8d6a2dSAleksandar Markovic  *  Copyright (C) 2019  Wave Computing, Inc.
5dd8d6a2dSAleksandar Markovic  *  Copyright (C) 2019  Aleksandar Markovic <amarkovic@wavecomp.com>
6*750541c4SAleksandar Markovic  *  Copyright (C) 2019  RT-RK Computer Based Systems LLC
7*750541c4SAleksandar Markovic  *  Copyright (C) 2019  Mateja Marjanovic <mateja.marjanovic@rt-rk.com>
8520e210cSAleksandar Markovic  *
9520e210cSAleksandar Markovic  *  This program is free software: you can redistribute it and/or modify
10520e210cSAleksandar Markovic  *  it under the terms of the GNU General Public License as published by
11520e210cSAleksandar Markovic  *  the Free Software Foundation, either version 2 of the License, or
12520e210cSAleksandar Markovic  *  (at your option) any later version.
13520e210cSAleksandar Markovic  *
14520e210cSAleksandar Markovic  *  This program is distributed in the hope that it will be useful,
15520e210cSAleksandar Markovic  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
16520e210cSAleksandar Markovic  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17520e210cSAleksandar Markovic  *  GNU General Public License for more details.
18520e210cSAleksandar Markovic  *
19520e210cSAleksandar Markovic  *  You should have received a copy of the GNU General Public License
20520e210cSAleksandar Markovic  *  along with this program.  If not, see <https://www.gnu.org/licenses/>.
21520e210cSAleksandar Markovic  *
22520e210cSAleksandar Markovic  */
23520e210cSAleksandar Markovic 
24520e210cSAleksandar Markovic #include <sys/time.h>
25520e210cSAleksandar Markovic #include <stdint.h>
26520e210cSAleksandar Markovic 
27520e210cSAleksandar Markovic #include "../../../../include/wrappers_msa.h"
2881526dffSAleksandar Markovic #include "../../../../include/test_inputs_128.h"
2981526dffSAleksandar Markovic #include "../../../../include/test_utils_128.h"
30520e210cSAleksandar Markovic 
31520e210cSAleksandar Markovic #define TEST_COUNT_TOTAL (                                                \
32520e210cSAleksandar Markovic             (PATTERN_INPUTS_SHORT_COUNT) * (PATTERN_INPUTS_SHORT_COUNT) + \
33520e210cSAleksandar Markovic             (RANDOM_INPUTS_SHORT_COUNT) * (RANDOM_INPUTS_SHORT_COUNT))
34520e210cSAleksandar Markovic 
35520e210cSAleksandar Markovic 
36520e210cSAleksandar Markovic int32_t main(void)
37520e210cSAleksandar Markovic {
38520e210cSAleksandar Markovic     char *instruction_name = "CLT_S.D";
39520e210cSAleksandar Markovic     int32_t ret;
40520e210cSAleksandar Markovic     uint32_t i, j;
41520e210cSAleksandar Markovic     struct timeval start, end;
42520e210cSAleksandar Markovic     double elapsed_time;
43520e210cSAleksandar Markovic 
44520e210cSAleksandar Markovic     uint64_t b128_result[TEST_COUNT_TOTAL][2];
45520e210cSAleksandar Markovic     uint64_t b128_expect[TEST_COUNT_TOTAL][2] = {
46520e210cSAleksandar Markovic         { 0x0000000000000000ULL, 0x0000000000000000ULL, },    /*   0  */
47520e210cSAleksandar Markovic         { 0xffffffffffffffffULL, 0xffffffffffffffffULL, },
48520e210cSAleksandar Markovic         { 0x0000000000000000ULL, 0x0000000000000000ULL, },
49520e210cSAleksandar Markovic         { 0xffffffffffffffffULL, 0xffffffffffffffffULL, },
50520e210cSAleksandar Markovic         { 0x0000000000000000ULL, 0x0000000000000000ULL, },
51520e210cSAleksandar Markovic         { 0xffffffffffffffffULL, 0xffffffffffffffffULL, },
52520e210cSAleksandar Markovic         { 0x0000000000000000ULL, 0xffffffffffffffffULL, },
53520e210cSAleksandar Markovic         { 0xffffffffffffffffULL, 0x0000000000000000ULL, },
54520e210cSAleksandar Markovic         { 0x0000000000000000ULL, 0x0000000000000000ULL, },    /*   8  */
55520e210cSAleksandar Markovic         { 0x0000000000000000ULL, 0x0000000000000000ULL, },
56520e210cSAleksandar Markovic         { 0x0000000000000000ULL, 0x0000000000000000ULL, },
57520e210cSAleksandar Markovic         { 0xffffffffffffffffULL, 0xffffffffffffffffULL, },
58520e210cSAleksandar Markovic         { 0x0000000000000000ULL, 0x0000000000000000ULL, },
59520e210cSAleksandar Markovic         { 0xffffffffffffffffULL, 0xffffffffffffffffULL, },
60520e210cSAleksandar Markovic         { 0x0000000000000000ULL, 0xffffffffffffffffULL, },
61520e210cSAleksandar Markovic         { 0xffffffffffffffffULL, 0x0000000000000000ULL, },
62520e210cSAleksandar Markovic         { 0xffffffffffffffffULL, 0xffffffffffffffffULL, },    /*  16  */
63520e210cSAleksandar Markovic         { 0xffffffffffffffffULL, 0xffffffffffffffffULL, },
64520e210cSAleksandar Markovic         { 0x0000000000000000ULL, 0x0000000000000000ULL, },
65520e210cSAleksandar Markovic         { 0xffffffffffffffffULL, 0xffffffffffffffffULL, },
66520e210cSAleksandar Markovic         { 0xffffffffffffffffULL, 0xffffffffffffffffULL, },
67520e210cSAleksandar Markovic         { 0xffffffffffffffffULL, 0xffffffffffffffffULL, },
68520e210cSAleksandar Markovic         { 0xffffffffffffffffULL, 0xffffffffffffffffULL, },
69520e210cSAleksandar Markovic         { 0xffffffffffffffffULL, 0xffffffffffffffffULL, },
70520e210cSAleksandar Markovic         { 0x0000000000000000ULL, 0x0000000000000000ULL, },    /*  24  */
71520e210cSAleksandar Markovic         { 0x0000000000000000ULL, 0x0000000000000000ULL, },
72520e210cSAleksandar Markovic         { 0x0000000000000000ULL, 0x0000000000000000ULL, },
73520e210cSAleksandar Markovic         { 0x0000000000000000ULL, 0x0000000000000000ULL, },
74520e210cSAleksandar Markovic         { 0x0000000000000000ULL, 0x0000000000000000ULL, },
75520e210cSAleksandar Markovic         { 0x0000000000000000ULL, 0x0000000000000000ULL, },
76520e210cSAleksandar Markovic         { 0x0000000000000000ULL, 0x0000000000000000ULL, },
77520e210cSAleksandar Markovic         { 0x0000000000000000ULL, 0x0000000000000000ULL, },
78520e210cSAleksandar Markovic         { 0xffffffffffffffffULL, 0xffffffffffffffffULL, },    /*  32  */
79520e210cSAleksandar Markovic         { 0xffffffffffffffffULL, 0xffffffffffffffffULL, },
80520e210cSAleksandar Markovic         { 0x0000000000000000ULL, 0x0000000000000000ULL, },
81520e210cSAleksandar Markovic         { 0xffffffffffffffffULL, 0xffffffffffffffffULL, },
82520e210cSAleksandar Markovic         { 0x0000000000000000ULL, 0x0000000000000000ULL, },
83520e210cSAleksandar Markovic         { 0xffffffffffffffffULL, 0xffffffffffffffffULL, },
84520e210cSAleksandar Markovic         { 0xffffffffffffffffULL, 0xffffffffffffffffULL, },
85520e210cSAleksandar Markovic         { 0xffffffffffffffffULL, 0x0000000000000000ULL, },
86520e210cSAleksandar Markovic         { 0x0000000000000000ULL, 0x0000000000000000ULL, },    /*  40  */
87520e210cSAleksandar Markovic         { 0x0000000000000000ULL, 0x0000000000000000ULL, },
88520e210cSAleksandar Markovic         { 0x0000000000000000ULL, 0x0000000000000000ULL, },
89520e210cSAleksandar Markovic         { 0xffffffffffffffffULL, 0xffffffffffffffffULL, },
90520e210cSAleksandar Markovic         { 0x0000000000000000ULL, 0x0000000000000000ULL, },
91520e210cSAleksandar Markovic         { 0x0000000000000000ULL, 0x0000000000000000ULL, },
92520e210cSAleksandar Markovic         { 0x0000000000000000ULL, 0xffffffffffffffffULL, },
93520e210cSAleksandar Markovic         { 0x0000000000000000ULL, 0x0000000000000000ULL, },
94520e210cSAleksandar Markovic         { 0xffffffffffffffffULL, 0x0000000000000000ULL, },    /*  48  */
95520e210cSAleksandar Markovic         { 0xffffffffffffffffULL, 0x0000000000000000ULL, },
96520e210cSAleksandar Markovic         { 0x0000000000000000ULL, 0x0000000000000000ULL, },
97520e210cSAleksandar Markovic         { 0xffffffffffffffffULL, 0xffffffffffffffffULL, },
98520e210cSAleksandar Markovic         { 0x0000000000000000ULL, 0x0000000000000000ULL, },
99520e210cSAleksandar Markovic         { 0xffffffffffffffffULL, 0x0000000000000000ULL, },
100520e210cSAleksandar Markovic         { 0x0000000000000000ULL, 0x0000000000000000ULL, },
101520e210cSAleksandar Markovic         { 0xffffffffffffffffULL, 0x0000000000000000ULL, },
102520e210cSAleksandar Markovic         { 0x0000000000000000ULL, 0xffffffffffffffffULL, },    /*  56  */
103520e210cSAleksandar Markovic         { 0x0000000000000000ULL, 0xffffffffffffffffULL, },
104520e210cSAleksandar Markovic         { 0x0000000000000000ULL, 0x0000000000000000ULL, },
105520e210cSAleksandar Markovic         { 0xffffffffffffffffULL, 0xffffffffffffffffULL, },
106520e210cSAleksandar Markovic         { 0x0000000000000000ULL, 0xffffffffffffffffULL, },
107520e210cSAleksandar Markovic         { 0xffffffffffffffffULL, 0xffffffffffffffffULL, },
108520e210cSAleksandar Markovic         { 0x0000000000000000ULL, 0xffffffffffffffffULL, },
109520e210cSAleksandar Markovic         { 0x0000000000000000ULL, 0x0000000000000000ULL, },
110520e210cSAleksandar Markovic         { 0x0000000000000000ULL, 0x0000000000000000ULL, },    /*  64  */
111520e210cSAleksandar Markovic         { 0xffffffffffffffffULL, 0x0000000000000000ULL, },
112520e210cSAleksandar Markovic         { 0xffffffffffffffffULL, 0x0000000000000000ULL, },
113520e210cSAleksandar Markovic         { 0xffffffffffffffffULL, 0x0000000000000000ULL, },
114520e210cSAleksandar Markovic         { 0x0000000000000000ULL, 0xffffffffffffffffULL, },
115520e210cSAleksandar Markovic         { 0x0000000000000000ULL, 0x0000000000000000ULL, },
116520e210cSAleksandar Markovic         { 0x0000000000000000ULL, 0xffffffffffffffffULL, },
117520e210cSAleksandar Markovic         { 0xffffffffffffffffULL, 0x0000000000000000ULL, },
118520e210cSAleksandar Markovic         { 0x0000000000000000ULL, 0xffffffffffffffffULL, },    /*  72  */
119520e210cSAleksandar Markovic         { 0xffffffffffffffffULL, 0x0000000000000000ULL, },
120520e210cSAleksandar Markovic         { 0x0000000000000000ULL, 0x0000000000000000ULL, },
121520e210cSAleksandar Markovic         { 0xffffffffffffffffULL, 0x0000000000000000ULL, },
122520e210cSAleksandar Markovic         { 0x0000000000000000ULL, 0xffffffffffffffffULL, },
123520e210cSAleksandar Markovic         { 0x0000000000000000ULL, 0xffffffffffffffffULL, },
124520e210cSAleksandar Markovic         { 0x0000000000000000ULL, 0xffffffffffffffffULL, },
125520e210cSAleksandar Markovic         { 0x0000000000000000ULL, 0x0000000000000000ULL, },
126520e210cSAleksandar Markovic     };
127520e210cSAleksandar Markovic 
128520e210cSAleksandar Markovic     gettimeofday(&start, NULL);
129520e210cSAleksandar Markovic 
130520e210cSAleksandar Markovic     for (i = 0; i < PATTERN_INPUTS_SHORT_COUNT; i++) {
131520e210cSAleksandar Markovic         for (j = 0; j < PATTERN_INPUTS_SHORT_COUNT; j++) {
132520e210cSAleksandar Markovic             do_msa_CLT_S_D(b128_pattern[i], b128_pattern[j],
133520e210cSAleksandar Markovic                           b128_result[PATTERN_INPUTS_SHORT_COUNT * i + j]);
134520e210cSAleksandar Markovic         }
135520e210cSAleksandar Markovic     }
136520e210cSAleksandar Markovic 
137520e210cSAleksandar Markovic     for (i = 0; i < RANDOM_INPUTS_SHORT_COUNT; i++) {
138520e210cSAleksandar Markovic         for (j = 0; j < RANDOM_INPUTS_SHORT_COUNT; j++) {
139520e210cSAleksandar Markovic             do_msa_CLT_S_D(b128_random[i], b128_random[j],
140520e210cSAleksandar Markovic                            b128_result[((PATTERN_INPUTS_SHORT_COUNT) *
141520e210cSAleksandar Markovic                                         (PATTERN_INPUTS_SHORT_COUNT)) +
142520e210cSAleksandar Markovic                                        RANDOM_INPUTS_SHORT_COUNT * i + j]);
143520e210cSAleksandar Markovic         }
144520e210cSAleksandar Markovic     }
145520e210cSAleksandar Markovic 
146520e210cSAleksandar Markovic     gettimeofday(&end, NULL);
147520e210cSAleksandar Markovic 
148520e210cSAleksandar Markovic     elapsed_time = (end.tv_sec - start.tv_sec) * 1000.0;
149520e210cSAleksandar Markovic     elapsed_time += (end.tv_usec - start.tv_usec) / 1000.0;
150520e210cSAleksandar Markovic 
151520e210cSAleksandar Markovic     ret = check_results(instruction_name, TEST_COUNT_TOTAL, elapsed_time,
152520e210cSAleksandar Markovic                         &b128_result[0][0], &b128_expect[0][0]);
153520e210cSAleksandar Markovic 
154520e210cSAleksandar Markovic     return ret;
155520e210cSAleksandar Markovic }
156