11e6bea79SAleksandar Markovic /* 21e6bea79SAleksandar Markovic * Test program for MSA instruction MIN_A.B 31e6bea79SAleksandar Markovic * 4*dd8d6a2dSAleksandar Markovic * Copyright (C) 2019 Wave Computing, Inc. 5*dd8d6a2dSAleksandar Markovic * Copyright (C) 2019 Aleksandar Markovic <amarkovic@wavecomp.com> 61e6bea79SAleksandar Markovic * 71e6bea79SAleksandar Markovic * This program is free software: you can redistribute it and/or modify 81e6bea79SAleksandar Markovic * it under the terms of the GNU General Public License as published by 91e6bea79SAleksandar Markovic * the Free Software Foundation, either version 2 of the License, or 101e6bea79SAleksandar Markovic * (at your option) any later version. 111e6bea79SAleksandar Markovic * 121e6bea79SAleksandar Markovic * This program is distributed in the hope that it will be useful, 131e6bea79SAleksandar Markovic * but WITHOUT ANY WARRANTY; without even the implied warranty of 141e6bea79SAleksandar Markovic * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 151e6bea79SAleksandar Markovic * GNU General Public License for more details. 161e6bea79SAleksandar Markovic * 171e6bea79SAleksandar Markovic * You should have received a copy of the GNU General Public License 181e6bea79SAleksandar Markovic * along with this program. If not, see <https://www.gnu.org/licenses/>. 191e6bea79SAleksandar Markovic * 201e6bea79SAleksandar Markovic */ 211e6bea79SAleksandar Markovic 221e6bea79SAleksandar Markovic #include <sys/time.h> 231e6bea79SAleksandar Markovic #include <stdint.h> 241e6bea79SAleksandar Markovic 251e6bea79SAleksandar Markovic #include "../../../../include/wrappers_msa.h" 261e6bea79SAleksandar Markovic #include "../../../../include/test_inputs.h" 271e6bea79SAleksandar Markovic #include "../../../../include/test_utils.h" 281e6bea79SAleksandar Markovic 291e6bea79SAleksandar Markovic #define TEST_COUNT_TOTAL ( \ 301e6bea79SAleksandar Markovic (PATTERN_INPUTS_SHORT_COUNT) * (PATTERN_INPUTS_SHORT_COUNT) + \ 311e6bea79SAleksandar Markovic (RANDOM_INPUTS_SHORT_COUNT) * (RANDOM_INPUTS_SHORT_COUNT)) 321e6bea79SAleksandar Markovic 331e6bea79SAleksandar Markovic 341e6bea79SAleksandar Markovic int32_t main(void) 351e6bea79SAleksandar Markovic { 361e6bea79SAleksandar Markovic char *instruction_name = "MIN_A.B"; 371e6bea79SAleksandar Markovic int32_t ret; 381e6bea79SAleksandar Markovic uint32_t i, j; 391e6bea79SAleksandar Markovic struct timeval start, end; 401e6bea79SAleksandar Markovic double elapsed_time; 411e6bea79SAleksandar Markovic 421e6bea79SAleksandar Markovic uint64_t b128_result[TEST_COUNT_TOTAL][2]; 431e6bea79SAleksandar Markovic uint64_t b128_expect[TEST_COUNT_TOTAL][2] = { 441e6bea79SAleksandar Markovic { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, /* 0 */ 451e6bea79SAleksandar Markovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, 461e6bea79SAleksandar Markovic { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, 471e6bea79SAleksandar Markovic { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, 481e6bea79SAleksandar Markovic { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, 491e6bea79SAleksandar Markovic { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, 501e6bea79SAleksandar Markovic { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, 511e6bea79SAleksandar Markovic { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, 521e6bea79SAleksandar Markovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, /* 8 */ 531e6bea79SAleksandar Markovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, 541e6bea79SAleksandar Markovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, 551e6bea79SAleksandar Markovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, 561e6bea79SAleksandar Markovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, 571e6bea79SAleksandar Markovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, 581e6bea79SAleksandar Markovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, 591e6bea79SAleksandar Markovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, 601e6bea79SAleksandar Markovic { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, /* 16 */ 611e6bea79SAleksandar Markovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, 621e6bea79SAleksandar Markovic { 0xaaaaaaaaaaaaaaaaULL, 0xaaaaaaaaaaaaaaaaULL, }, 631e6bea79SAleksandar Markovic { 0x5555555555555555ULL, 0x5555555555555555ULL, }, 641e6bea79SAleksandar Markovic { 0xccccccccccccccccULL, 0xccccccccccccccccULL, }, 651e6bea79SAleksandar Markovic { 0x3333333333333333ULL, 0x3333333333333333ULL, }, 661e6bea79SAleksandar Markovic { 0xe3aa38e3aa38e3aaULL, 0x38e3aa38e3aa38e3ULL, }, 671e6bea79SAleksandar Markovic { 0x1caac71caac71caaULL, 0xc71caac71caac71cULL, }, 681e6bea79SAleksandar Markovic { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, /* 24 */ 691e6bea79SAleksandar Markovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, 701e6bea79SAleksandar Markovic { 0x5555555555555555ULL, 0x5555555555555555ULL, }, 711e6bea79SAleksandar Markovic { 0x5555555555555555ULL, 0x5555555555555555ULL, }, 721e6bea79SAleksandar Markovic { 0xccccccccccccccccULL, 0xccccccccccccccccULL, }, 731e6bea79SAleksandar Markovic { 0x3333333333333333ULL, 0x3333333333333333ULL, }, 741e6bea79SAleksandar Markovic { 0xe35538e35538e355ULL, 0x38e35538e35538e3ULL, }, 751e6bea79SAleksandar Markovic { 0x1c55c71c55c71c55ULL, 0xc71c55c71c55c71cULL, }, 761e6bea79SAleksandar Markovic { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, /* 32 */ 771e6bea79SAleksandar Markovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, 781e6bea79SAleksandar Markovic { 0xccccccccccccccccULL, 0xccccccccccccccccULL, }, 791e6bea79SAleksandar Markovic { 0xccccccccccccccccULL, 0xccccccccccccccccULL, }, 801e6bea79SAleksandar Markovic { 0xccccccccccccccccULL, 0xccccccccccccccccULL, }, 811e6bea79SAleksandar Markovic { 0x3333333333333333ULL, 0x3333333333333333ULL, }, 821e6bea79SAleksandar Markovic { 0xe3cccce3cccce3ccULL, 0xcce3cccce3cccce3ULL, }, 831e6bea79SAleksandar Markovic { 0x1ccccc1ccccc1cccULL, 0xcc1ccccc1ccccc1cULL, }, 841e6bea79SAleksandar Markovic { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, /* 40 */ 851e6bea79SAleksandar Markovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, 861e6bea79SAleksandar Markovic { 0x3333333333333333ULL, 0x3333333333333333ULL, }, 871e6bea79SAleksandar Markovic { 0x3333333333333333ULL, 0x3333333333333333ULL, }, 881e6bea79SAleksandar Markovic { 0x3333333333333333ULL, 0x3333333333333333ULL, }, 891e6bea79SAleksandar Markovic { 0x3333333333333333ULL, 0x3333333333333333ULL, }, 901e6bea79SAleksandar Markovic { 0xe33333e33333e333ULL, 0x33e33333e33333e3ULL, }, 911e6bea79SAleksandar Markovic { 0x1c33331c33331c33ULL, 0x331c33331c33331cULL, }, 921e6bea79SAleksandar Markovic { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, /* 48 */ 931e6bea79SAleksandar Markovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, 941e6bea79SAleksandar Markovic { 0xe3aa38e3aa38e3aaULL, 0x38e3aa38e3aa38e3ULL, }, 951e6bea79SAleksandar Markovic { 0xe35538e35538e355ULL, 0x38e35538e35538e3ULL, }, 961e6bea79SAleksandar Markovic { 0xe3cccce3cccce3ccULL, 0xcce3cccce3cccce3ULL, }, 971e6bea79SAleksandar Markovic { 0xe33333e33333e333ULL, 0x33e33333e33333e3ULL, }, 981e6bea79SAleksandar Markovic { 0xe38e38e38e38e38eULL, 0x38e38e38e38e38e3ULL, }, 991e6bea79SAleksandar Markovic { 0x1c71381c71381c71ULL, 0x381c71381c71381cULL, }, 1001e6bea79SAleksandar Markovic { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, /* 56 */ 1011e6bea79SAleksandar Markovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, 1021e6bea79SAleksandar Markovic { 0x1caac71caac71caaULL, 0xc71caac71caac71cULL, }, 1031e6bea79SAleksandar Markovic { 0x1c55c71c55c71c55ULL, 0xc71c55c71c55c71cULL, }, 1041e6bea79SAleksandar Markovic { 0x1ccccc1ccccc1cccULL, 0xcc1ccccc1ccccc1cULL, }, 1051e6bea79SAleksandar Markovic { 0x1c33331c33331c33ULL, 0x331c33331c33331cULL, }, 1061e6bea79SAleksandar Markovic { 0x1c71381c71381c71ULL, 0x381c71381c71381cULL, }, 1071e6bea79SAleksandar Markovic { 0x1c71c71c71c71c71ULL, 0xc71c71c71c71c71cULL, }, 1081e6bea79SAleksandar Markovic { 0x886ae6cc28625540ULL, 0x4b670b5efe7bb00cULL, }, /* 64 */ 1091e6bea79SAleksandar Markovic { 0xfbbe00cc2862c708ULL, 0x12f70b1afe3fb0fcULL, }, 1101e6bea79SAleksandar Markovic { 0xac5ae6cc28cf5540ULL, 0x27d80bfffe2b250cULL, }, 1111e6bea79SAleksandar Markovic { 0x704f16cc2831e240ULL, 0x4bf10bd8fe42e20cULL, }, 1121e6bea79SAleksandar Markovic { 0xfbbe00cc2862c708ULL, 0x12f70b1afe3fb0fcULL, }, 1131e6bea79SAleksandar Markovic { 0xfbbe00634d93c708ULL, 0x12f7bb1a153f52fcULL, }, 1141e6bea79SAleksandar Markovic { 0xfbbe00aab9cfc708ULL, 0x12f7c6ff152b25fcULL, }, 1151e6bea79SAleksandar Markovic { 0xfbbe004d4d31e208ULL, 0x12f7bb1a153fe2fcULL, }, 1161e6bea79SAleksandar Markovic { 0xac5ae6cc28cf5540ULL, 0x27d80bfffe2b250cULL, }, /* 72 */ 1171e6bea79SAleksandar Markovic { 0xfbbe00aab9cfc708ULL, 0x12f7c6ff152b25fcULL, }, 1181e6bea79SAleksandar Markovic { 0xac5aaeaab9cf8b80ULL, 0x27d8c6ffab2b2514ULL, }, 1191e6bea79SAleksandar Markovic { 0xac4f164db931e24eULL, 0x27f1c6ffab2be214ULL, }, 1201e6bea79SAleksandar Markovic { 0x704f16cc2831e240ULL, 0x4bf10bd8fe42e20cULL, }, 1211e6bea79SAleksandar Markovic { 0xfbbe004d4d31e208ULL, 0x12f7bb1a153fe2fcULL, }, 1221e6bea79SAleksandar Markovic { 0xac4f164db9cfe24eULL, 0x27f1c6ffab2be214ULL, }, 1231e6bea79SAleksandar Markovic { 0x704f164d5e31e24eULL, 0x8df188d8a942e2a0ULL, }, 1241e6bea79SAleksandar Markovic }; 1251e6bea79SAleksandar Markovic 1261e6bea79SAleksandar Markovic gettimeofday(&start, NULL); 1271e6bea79SAleksandar Markovic 1281e6bea79SAleksandar Markovic for (i = 0; i < PATTERN_INPUTS_SHORT_COUNT; i++) { 1291e6bea79SAleksandar Markovic for (j = 0; j < PATTERN_INPUTS_SHORT_COUNT; j++) { 1301e6bea79SAleksandar Markovic do_msa_MIN_A_B(b128_pattern[i], b128_pattern[j], 1311e6bea79SAleksandar Markovic b128_result[PATTERN_INPUTS_SHORT_COUNT * i + j]); 1321e6bea79SAleksandar Markovic } 1331e6bea79SAleksandar Markovic } 1341e6bea79SAleksandar Markovic 1351e6bea79SAleksandar Markovic for (i = 0; i < RANDOM_INPUTS_SHORT_COUNT; i++) { 1361e6bea79SAleksandar Markovic for (j = 0; j < RANDOM_INPUTS_SHORT_COUNT; j++) { 1371e6bea79SAleksandar Markovic do_msa_MIN_A_B(b128_random[i], b128_random[j], 1381e6bea79SAleksandar Markovic b128_result[((PATTERN_INPUTS_SHORT_COUNT) * 1391e6bea79SAleksandar Markovic (PATTERN_INPUTS_SHORT_COUNT)) + 1401e6bea79SAleksandar Markovic RANDOM_INPUTS_SHORT_COUNT * i + j]); 1411e6bea79SAleksandar Markovic } 1421e6bea79SAleksandar Markovic } 1431e6bea79SAleksandar Markovic 1441e6bea79SAleksandar Markovic gettimeofday(&end, NULL); 1451e6bea79SAleksandar Markovic 1461e6bea79SAleksandar Markovic elapsed_time = (end.tv_sec - start.tv_sec) * 1000.0; 1471e6bea79SAleksandar Markovic elapsed_time += (end.tv_usec - start.tv_usec) / 1000.0; 1481e6bea79SAleksandar Markovic 1491e6bea79SAleksandar Markovic ret = check_results(instruction_name, TEST_COUNT_TOTAL, elapsed_time, 1501e6bea79SAleksandar Markovic &b128_result[0][0], &b128_expect[0][0]); 1511e6bea79SAleksandar Markovic 1521e6bea79SAleksandar Markovic return ret; 1531e6bea79SAleksandar Markovic } 154