11e6bea79SAleksandar Markovic /*
21e6bea79SAleksandar Markovic * Test program for MSA instruction MIN_U.H
31e6bea79SAleksandar Markovic *
4dd8d6a2dSAleksandar Markovic * Copyright (C) 2019 Wave Computing, Inc.
5dd8d6a2dSAleksandar Markovic * Copyright (C) 2019 Aleksandar Markovic <amarkovic@wavecomp.com>
6750541c4SAleksandar Markovic * Copyright (C) 2019 RT-RK Computer Based Systems LLC
7750541c4SAleksandar Markovic * Copyright (C) 2019 Mateja Marjanovic <mateja.marjanovic@rt-rk.com>
81e6bea79SAleksandar Markovic *
91e6bea79SAleksandar Markovic * This program is free software: you can redistribute it and/or modify
101e6bea79SAleksandar Markovic * it under the terms of the GNU General Public License as published by
111e6bea79SAleksandar Markovic * the Free Software Foundation, either version 2 of the License, or
121e6bea79SAleksandar Markovic * (at your option) any later version.
131e6bea79SAleksandar Markovic *
141e6bea79SAleksandar Markovic * This program is distributed in the hope that it will be useful,
151e6bea79SAleksandar Markovic * but WITHOUT ANY WARRANTY; without even the implied warranty of
161e6bea79SAleksandar Markovic * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
171e6bea79SAleksandar Markovic * GNU General Public License for more details.
181e6bea79SAleksandar Markovic *
191e6bea79SAleksandar Markovic * You should have received a copy of the GNU General Public License
201e6bea79SAleksandar Markovic * along with this program. If not, see <https://www.gnu.org/licenses/>.
211e6bea79SAleksandar Markovic *
221e6bea79SAleksandar Markovic */
231e6bea79SAleksandar Markovic
241e6bea79SAleksandar Markovic #include <sys/time.h>
251e6bea79SAleksandar Markovic #include <stdint.h>
261e6bea79SAleksandar Markovic
271e6bea79SAleksandar Markovic #include "../../../../include/wrappers_msa.h"
2881526dffSAleksandar Markovic #include "../../../../include/test_inputs_128.h"
2981526dffSAleksandar Markovic #include "../../../../include/test_utils_128.h"
301e6bea79SAleksandar Markovic
311e6bea79SAleksandar Markovic #define TEST_COUNT_TOTAL ( \
321e6bea79SAleksandar Markovic (PATTERN_INPUTS_SHORT_COUNT) * (PATTERN_INPUTS_SHORT_COUNT) + \
331e6bea79SAleksandar Markovic (RANDOM_INPUTS_SHORT_COUNT) * (RANDOM_INPUTS_SHORT_COUNT))
341e6bea79SAleksandar Markovic
351e6bea79SAleksandar Markovic
main(void)361e6bea79SAleksandar Markovic int32_t main(void)
371e6bea79SAleksandar Markovic {
38*8e6fe6b8SAleksandar Markovic char *isa_ase_name = "MSA";
39*8e6fe6b8SAleksandar Markovic char *group_name = "Int Max Min";
401e6bea79SAleksandar Markovic char *instruction_name = "MIN_U.H";
411e6bea79SAleksandar Markovic int32_t ret;
421e6bea79SAleksandar Markovic uint32_t i, j;
431e6bea79SAleksandar Markovic struct timeval start, end;
441e6bea79SAleksandar Markovic double elapsed_time;
451e6bea79SAleksandar Markovic
461e6bea79SAleksandar Markovic uint64_t b128_result[TEST_COUNT_TOTAL][2];
471e6bea79SAleksandar Markovic uint64_t b128_expect[TEST_COUNT_TOTAL][2] = {
481e6bea79SAleksandar Markovic { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, /* 0 */
491e6bea79SAleksandar Markovic { 0x0000000000000000ULL, 0x0000000000000000ULL, },
501e6bea79SAleksandar Markovic { 0xaaaaaaaaaaaaaaaaULL, 0xaaaaaaaaaaaaaaaaULL, },
511e6bea79SAleksandar Markovic { 0x5555555555555555ULL, 0x5555555555555555ULL, },
521e6bea79SAleksandar Markovic { 0xccccccccccccccccULL, 0xccccccccccccccccULL, },
531e6bea79SAleksandar Markovic { 0x3333333333333333ULL, 0x3333333333333333ULL, },
541e6bea79SAleksandar Markovic { 0xe38e38e38e38e38eULL, 0x38e38e38e38e38e3ULL, },
551e6bea79SAleksandar Markovic { 0x1c71c71c71c71c71ULL, 0xc71c71c71c71c71cULL, },
561e6bea79SAleksandar Markovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, /* 8 */
571e6bea79SAleksandar Markovic { 0x0000000000000000ULL, 0x0000000000000000ULL, },
581e6bea79SAleksandar Markovic { 0x0000000000000000ULL, 0x0000000000000000ULL, },
591e6bea79SAleksandar Markovic { 0x0000000000000000ULL, 0x0000000000000000ULL, },
601e6bea79SAleksandar Markovic { 0x0000000000000000ULL, 0x0000000000000000ULL, },
611e6bea79SAleksandar Markovic { 0x0000000000000000ULL, 0x0000000000000000ULL, },
621e6bea79SAleksandar Markovic { 0x0000000000000000ULL, 0x0000000000000000ULL, },
631e6bea79SAleksandar Markovic { 0x0000000000000000ULL, 0x0000000000000000ULL, },
641e6bea79SAleksandar Markovic { 0xaaaaaaaaaaaaaaaaULL, 0xaaaaaaaaaaaaaaaaULL, }, /* 16 */
651e6bea79SAleksandar Markovic { 0x0000000000000000ULL, 0x0000000000000000ULL, },
661e6bea79SAleksandar Markovic { 0xaaaaaaaaaaaaaaaaULL, 0xaaaaaaaaaaaaaaaaULL, },
671e6bea79SAleksandar Markovic { 0x5555555555555555ULL, 0x5555555555555555ULL, },
681e6bea79SAleksandar Markovic { 0xaaaaaaaaaaaaaaaaULL, 0xaaaaaaaaaaaaaaaaULL, },
691e6bea79SAleksandar Markovic { 0x3333333333333333ULL, 0x3333333333333333ULL, },
701e6bea79SAleksandar Markovic { 0xaaaa38e38e38aaaaULL, 0x38e38e38aaaa38e3ULL, },
711e6bea79SAleksandar Markovic { 0x1c71aaaa71c71c71ULL, 0xaaaa71c71c71aaaaULL, },
721e6bea79SAleksandar Markovic { 0x5555555555555555ULL, 0x5555555555555555ULL, }, /* 24 */
731e6bea79SAleksandar Markovic { 0x0000000000000000ULL, 0x0000000000000000ULL, },
741e6bea79SAleksandar Markovic { 0x5555555555555555ULL, 0x5555555555555555ULL, },
751e6bea79SAleksandar Markovic { 0x5555555555555555ULL, 0x5555555555555555ULL, },
761e6bea79SAleksandar Markovic { 0x5555555555555555ULL, 0x5555555555555555ULL, },
771e6bea79SAleksandar Markovic { 0x3333333333333333ULL, 0x3333333333333333ULL, },
781e6bea79SAleksandar Markovic { 0x555538e355555555ULL, 0x38e35555555538e3ULL, },
791e6bea79SAleksandar Markovic { 0x1c71555555551c71ULL, 0x555555551c715555ULL, },
801e6bea79SAleksandar Markovic { 0xccccccccccccccccULL, 0xccccccccccccccccULL, }, /* 32 */
811e6bea79SAleksandar Markovic { 0x0000000000000000ULL, 0x0000000000000000ULL, },
821e6bea79SAleksandar Markovic { 0xaaaaaaaaaaaaaaaaULL, 0xaaaaaaaaaaaaaaaaULL, },
831e6bea79SAleksandar Markovic { 0x5555555555555555ULL, 0x5555555555555555ULL, },
841e6bea79SAleksandar Markovic { 0xccccccccccccccccULL, 0xccccccccccccccccULL, },
851e6bea79SAleksandar Markovic { 0x3333333333333333ULL, 0x3333333333333333ULL, },
861e6bea79SAleksandar Markovic { 0xcccc38e38e38ccccULL, 0x38e38e38cccc38e3ULL, },
871e6bea79SAleksandar Markovic { 0x1c71c71c71c71c71ULL, 0xc71c71c71c71c71cULL, },
881e6bea79SAleksandar Markovic { 0x3333333333333333ULL, 0x3333333333333333ULL, }, /* 40 */
891e6bea79SAleksandar Markovic { 0x0000000000000000ULL, 0x0000000000000000ULL, },
901e6bea79SAleksandar Markovic { 0x3333333333333333ULL, 0x3333333333333333ULL, },
911e6bea79SAleksandar Markovic { 0x3333333333333333ULL, 0x3333333333333333ULL, },
921e6bea79SAleksandar Markovic { 0x3333333333333333ULL, 0x3333333333333333ULL, },
931e6bea79SAleksandar Markovic { 0x3333333333333333ULL, 0x3333333333333333ULL, },
941e6bea79SAleksandar Markovic { 0x3333333333333333ULL, 0x3333333333333333ULL, },
951e6bea79SAleksandar Markovic { 0x1c71333333331c71ULL, 0x333333331c713333ULL, },
961e6bea79SAleksandar Markovic { 0xe38e38e38e38e38eULL, 0x38e38e38e38e38e3ULL, }, /* 48 */
971e6bea79SAleksandar Markovic { 0x0000000000000000ULL, 0x0000000000000000ULL, },
981e6bea79SAleksandar Markovic { 0xaaaa38e38e38aaaaULL, 0x38e38e38aaaa38e3ULL, },
991e6bea79SAleksandar Markovic { 0x555538e355555555ULL, 0x38e35555555538e3ULL, },
1001e6bea79SAleksandar Markovic { 0xcccc38e38e38ccccULL, 0x38e38e38cccc38e3ULL, },
1011e6bea79SAleksandar Markovic { 0x3333333333333333ULL, 0x3333333333333333ULL, },
1021e6bea79SAleksandar Markovic { 0xe38e38e38e38e38eULL, 0x38e38e38e38e38e3ULL, },
1031e6bea79SAleksandar Markovic { 0x1c7138e371c71c71ULL, 0x38e371c71c7138e3ULL, },
1041e6bea79SAleksandar Markovic { 0x1c71c71c71c71c71ULL, 0xc71c71c71c71c71cULL, }, /* 56 */
1051e6bea79SAleksandar Markovic { 0x0000000000000000ULL, 0x0000000000000000ULL, },
1061e6bea79SAleksandar Markovic { 0x1c71aaaa71c71c71ULL, 0xaaaa71c71c71aaaaULL, },
1071e6bea79SAleksandar Markovic { 0x1c71555555551c71ULL, 0x555555551c715555ULL, },
1081e6bea79SAleksandar Markovic { 0x1c71c71c71c71c71ULL, 0xc71c71c71c71c71cULL, },
1091e6bea79SAleksandar Markovic { 0x1c71333333331c71ULL, 0x333333331c713333ULL, },
1101e6bea79SAleksandar Markovic { 0x1c7138e371c71c71ULL, 0x38e371c71c7138e3ULL, },
1111e6bea79SAleksandar Markovic { 0x1c71c71c71c71c71ULL, 0xc71c71c71c71c71cULL, },
1121e6bea79SAleksandar Markovic { 0x886ae6cc28625540ULL, 0x4b670b5efe7bb00cULL, }, /* 64 */
1131e6bea79SAleksandar Markovic { 0x886a006328625540ULL, 0x12f70b5e153f52fcULL, },
1141e6bea79SAleksandar Markovic { 0x886aaeaa28625540ULL, 0x27d80b5eab2b2514ULL, },
1151e6bea79SAleksandar Markovic { 0x704f164d28625540ULL, 0x4b670b5ea942b00cULL, },
1161e6bea79SAleksandar Markovic { 0x886a006328625540ULL, 0x12f70b5e153f52fcULL, },
1171e6bea79SAleksandar Markovic { 0xfbbe00634d93c708ULL, 0x12f7bb1a153f52fcULL, },
1181e6bea79SAleksandar Markovic { 0xac5a00634d938b80ULL, 0x12f7bb1a153f2514ULL, },
1191e6bea79SAleksandar Markovic { 0x704f00634d93c708ULL, 0x12f788d8153f52fcULL, },
1201e6bea79SAleksandar Markovic { 0x886aaeaa28625540ULL, 0x27d80b5eab2b2514ULL, }, /* 72 */
1211e6bea79SAleksandar Markovic { 0xac5a00634d938b80ULL, 0x12f7bb1a153f2514ULL, },
1221e6bea79SAleksandar Markovic { 0xac5aaeaab9cf8b80ULL, 0x27d8c6ffab2b2514ULL, },
1231e6bea79SAleksandar Markovic { 0x704f164d5e318b80ULL, 0x27d888d8a9422514ULL, },
1241e6bea79SAleksandar Markovic { 0x704f164d28625540ULL, 0x4b670b5ea942b00cULL, },
1251e6bea79SAleksandar Markovic { 0x704f00634d93c708ULL, 0x12f788d8153f52fcULL, },
1261e6bea79SAleksandar Markovic { 0x704f164d5e318b80ULL, 0x27d888d8a9422514ULL, },
1271e6bea79SAleksandar Markovic { 0x704f164d5e31e24eULL, 0x8df188d8a942e2a0ULL, },
1281e6bea79SAleksandar Markovic };
1291e6bea79SAleksandar Markovic
130ca693d1cSAleksandar Markovic reset_msa_registers();
131ca693d1cSAleksandar Markovic
1321e6bea79SAleksandar Markovic gettimeofday(&start, NULL);
1331e6bea79SAleksandar Markovic
1341e6bea79SAleksandar Markovic for (i = 0; i < PATTERN_INPUTS_SHORT_COUNT; i++) {
1351e6bea79SAleksandar Markovic for (j = 0; j < PATTERN_INPUTS_SHORT_COUNT; j++) {
1361e6bea79SAleksandar Markovic do_msa_MIN_U_H(b128_pattern[i], b128_pattern[j],
1371e6bea79SAleksandar Markovic b128_result[PATTERN_INPUTS_SHORT_COUNT * i + j]);
1381e6bea79SAleksandar Markovic }
1391e6bea79SAleksandar Markovic }
1401e6bea79SAleksandar Markovic
1411e6bea79SAleksandar Markovic for (i = 0; i < RANDOM_INPUTS_SHORT_COUNT; i++) {
1421e6bea79SAleksandar Markovic for (j = 0; j < RANDOM_INPUTS_SHORT_COUNT; j++) {
1431e6bea79SAleksandar Markovic do_msa_MIN_U_H(b128_random[i], b128_random[j],
1441e6bea79SAleksandar Markovic b128_result[((PATTERN_INPUTS_SHORT_COUNT) *
1451e6bea79SAleksandar Markovic (PATTERN_INPUTS_SHORT_COUNT)) +
1461e6bea79SAleksandar Markovic RANDOM_INPUTS_SHORT_COUNT * i + j]);
1471e6bea79SAleksandar Markovic }
1481e6bea79SAleksandar Markovic }
1491e6bea79SAleksandar Markovic
1501e6bea79SAleksandar Markovic gettimeofday(&end, NULL);
1511e6bea79SAleksandar Markovic
1521e6bea79SAleksandar Markovic elapsed_time = (end.tv_sec - start.tv_sec) * 1000.0;
1531e6bea79SAleksandar Markovic elapsed_time += (end.tv_usec - start.tv_usec) / 1000.0;
1541e6bea79SAleksandar Markovic
155*8e6fe6b8SAleksandar Markovic ret = check_results_128(isa_ase_name, group_name, instruction_name,
156*8e6fe6b8SAleksandar Markovic TEST_COUNT_TOTAL, elapsed_time,
1571e6bea79SAleksandar Markovic &b128_result[0][0], &b128_expect[0][0]);
1581e6bea79SAleksandar Markovic
1591e6bea79SAleksandar Markovic return ret;
1601e6bea79SAleksandar Markovic }
161