11e6bea79SAleksandar Markovic /* 21e6bea79SAleksandar Markovic * Test program for MSA instruction MAX_A.B 31e6bea79SAleksandar 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> 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 361e6bea79SAleksandar Markovic int32_t main(void) 371e6bea79SAleksandar Markovic { 381e6bea79SAleksandar Markovic char *instruction_name = "MAX_A.B"; 391e6bea79SAleksandar Markovic int32_t ret; 401e6bea79SAleksandar Markovic uint32_t i, j; 411e6bea79SAleksandar Markovic struct timeval start, end; 421e6bea79SAleksandar Markovic double elapsed_time; 431e6bea79SAleksandar Markovic 441e6bea79SAleksandar Markovic uint64_t b128_result[TEST_COUNT_TOTAL][2]; 451e6bea79SAleksandar Markovic uint64_t b128_expect[TEST_COUNT_TOTAL][2] = { 461e6bea79SAleksandar Markovic { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, /* 0 */ 471e6bea79SAleksandar Markovic { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, 481e6bea79SAleksandar Markovic { 0xaaaaaaaaaaaaaaaaULL, 0xaaaaaaaaaaaaaaaaULL, }, 491e6bea79SAleksandar Markovic { 0x5555555555555555ULL, 0x5555555555555555ULL, }, 501e6bea79SAleksandar Markovic { 0xccccccccccccccccULL, 0xccccccccccccccccULL, }, 511e6bea79SAleksandar Markovic { 0x3333333333333333ULL, 0x3333333333333333ULL, }, 521e6bea79SAleksandar Markovic { 0xe38e38e38e38e38eULL, 0x38e38e38e38e38e3ULL, }, 531e6bea79SAleksandar Markovic { 0x1c71c71c71c71c71ULL, 0xc71c71c71c71c71cULL, }, 541e6bea79SAleksandar Markovic { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, /* 8 */ 551e6bea79SAleksandar Markovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, 561e6bea79SAleksandar Markovic { 0xaaaaaaaaaaaaaaaaULL, 0xaaaaaaaaaaaaaaaaULL, }, 571e6bea79SAleksandar Markovic { 0x5555555555555555ULL, 0x5555555555555555ULL, }, 581e6bea79SAleksandar Markovic { 0xccccccccccccccccULL, 0xccccccccccccccccULL, }, 591e6bea79SAleksandar Markovic { 0x3333333333333333ULL, 0x3333333333333333ULL, }, 601e6bea79SAleksandar Markovic { 0xe38e38e38e38e38eULL, 0x38e38e38e38e38e3ULL, }, 611e6bea79SAleksandar Markovic { 0x1c71c71c71c71c71ULL, 0xc71c71c71c71c71cULL, }, 621e6bea79SAleksandar Markovic { 0xaaaaaaaaaaaaaaaaULL, 0xaaaaaaaaaaaaaaaaULL, }, /* 16 */ 631e6bea79SAleksandar Markovic { 0xaaaaaaaaaaaaaaaaULL, 0xaaaaaaaaaaaaaaaaULL, }, 641e6bea79SAleksandar Markovic { 0xaaaaaaaaaaaaaaaaULL, 0xaaaaaaaaaaaaaaaaULL, }, 651e6bea79SAleksandar Markovic { 0xaaaaaaaaaaaaaaaaULL, 0xaaaaaaaaaaaaaaaaULL, }, 661e6bea79SAleksandar Markovic { 0xaaaaaaaaaaaaaaaaULL, 0xaaaaaaaaaaaaaaaaULL, }, 671e6bea79SAleksandar Markovic { 0xaaaaaaaaaaaaaaaaULL, 0xaaaaaaaaaaaaaaaaULL, }, 681e6bea79SAleksandar Markovic { 0xaa8eaaaa8eaaaa8eULL, 0xaaaa8eaaaa8eaaaaULL, }, 691e6bea79SAleksandar Markovic { 0xaa71aaaa71aaaa71ULL, 0xaaaa71aaaa71aaaaULL, }, 701e6bea79SAleksandar Markovic { 0x5555555555555555ULL, 0x5555555555555555ULL, }, /* 24 */ 711e6bea79SAleksandar Markovic { 0x5555555555555555ULL, 0x5555555555555555ULL, }, 721e6bea79SAleksandar Markovic { 0xaaaaaaaaaaaaaaaaULL, 0xaaaaaaaaaaaaaaaaULL, }, 731e6bea79SAleksandar Markovic { 0x5555555555555555ULL, 0x5555555555555555ULL, }, 741e6bea79SAleksandar Markovic { 0x5555555555555555ULL, 0x5555555555555555ULL, }, 751e6bea79SAleksandar Markovic { 0x5555555555555555ULL, 0x5555555555555555ULL, }, 761e6bea79SAleksandar Markovic { 0x558e55558e55558eULL, 0x55558e55558e5555ULL, }, 771e6bea79SAleksandar Markovic { 0x5571555571555571ULL, 0x5555715555715555ULL, }, 781e6bea79SAleksandar Markovic { 0xccccccccccccccccULL, 0xccccccccccccccccULL, }, /* 32 */ 791e6bea79SAleksandar Markovic { 0xccccccccccccccccULL, 0xccccccccccccccccULL, }, 801e6bea79SAleksandar Markovic { 0xaaaaaaaaaaaaaaaaULL, 0xaaaaaaaaaaaaaaaaULL, }, 811e6bea79SAleksandar Markovic { 0x5555555555555555ULL, 0x5555555555555555ULL, }, 821e6bea79SAleksandar Markovic { 0xccccccccccccccccULL, 0xccccccccccccccccULL, }, 831e6bea79SAleksandar Markovic { 0xccccccccccccccccULL, 0xccccccccccccccccULL, }, 841e6bea79SAleksandar Markovic { 0xcc8e38cc8e38cc8eULL, 0x38cc8e38cc8e38ccULL, }, 851e6bea79SAleksandar Markovic { 0xcc71c7cc71c7cc71ULL, 0xc7cc71c7cc71c7ccULL, }, 861e6bea79SAleksandar Markovic { 0x3333333333333333ULL, 0x3333333333333333ULL, }, /* 40 */ 871e6bea79SAleksandar Markovic { 0x3333333333333333ULL, 0x3333333333333333ULL, }, 881e6bea79SAleksandar Markovic { 0xaaaaaaaaaaaaaaaaULL, 0xaaaaaaaaaaaaaaaaULL, }, 891e6bea79SAleksandar Markovic { 0x5555555555555555ULL, 0x5555555555555555ULL, }, 901e6bea79SAleksandar Markovic { 0xccccccccccccccccULL, 0xccccccccccccccccULL, }, 911e6bea79SAleksandar Markovic { 0x3333333333333333ULL, 0x3333333333333333ULL, }, 921e6bea79SAleksandar Markovic { 0x338e38338e38338eULL, 0x38338e38338e3833ULL, }, 931e6bea79SAleksandar Markovic { 0x3371c73371c73371ULL, 0xc73371c73371c733ULL, }, 941e6bea79SAleksandar Markovic { 0xe38e38e38e38e38eULL, 0x38e38e38e38e38e3ULL, }, /* 48 */ 951e6bea79SAleksandar Markovic { 0xe38e38e38e38e38eULL, 0x38e38e38e38e38e3ULL, }, 961e6bea79SAleksandar Markovic { 0xaa8eaaaa8eaaaa8eULL, 0xaaaa8eaaaa8eaaaaULL, }, 971e6bea79SAleksandar Markovic { 0x558e55558e55558eULL, 0x55558e55558e5555ULL, }, 981e6bea79SAleksandar Markovic { 0xcc8e38cc8e38cc8eULL, 0x38cc8e38cc8e38ccULL, }, 991e6bea79SAleksandar Markovic { 0x338e38338e38338eULL, 0x38338e38338e3833ULL, }, 1001e6bea79SAleksandar Markovic { 0xe38e38e38e38e38eULL, 0x38e38e38e38e38e3ULL, }, 1011e6bea79SAleksandar Markovic { 0xe38ec7e38ec7e38eULL, 0xc7e38ec7e38ec7e3ULL, }, 1021e6bea79SAleksandar Markovic { 0x1c71c71c71c71c71ULL, 0xc71c71c71c71c71cULL, }, /* 56 */ 1031e6bea79SAleksandar Markovic { 0x1c71c71c71c71c71ULL, 0xc71c71c71c71c71cULL, }, 1041e6bea79SAleksandar Markovic { 0xaa71aaaa71aaaa71ULL, 0xaaaa71aaaa71aaaaULL, }, 1051e6bea79SAleksandar Markovic { 0x5571555571555571ULL, 0x5555715555715555ULL, }, 1061e6bea79SAleksandar Markovic { 0xcc71c7cc71c7cc71ULL, 0xc7cc71c7cc71c7ccULL, }, 1071e6bea79SAleksandar Markovic { 0x3371c73371c73371ULL, 0xc73371c73371c733ULL, }, 1081e6bea79SAleksandar Markovic { 0xe38ec7e38ec7e38eULL, 0xc7e38ec7e38ec7e3ULL, }, 1091e6bea79SAleksandar Markovic { 0x1c71c71c71c71c71ULL, 0xc71c71c71c71c71cULL, }, 1101e6bea79SAleksandar Markovic { 0x886ae6cc28625540ULL, 0x4b670b5efe7bb00cULL, }, /* 64 */ 1111e6bea79SAleksandar Markovic { 0x886ae6634d935540ULL, 0x4b67bb5e157b520cULL, }, 1121e6bea79SAleksandar Markovic { 0x886aaeaab9628b80ULL, 0x4b67c65eab7bb014ULL, }, 1131e6bea79SAleksandar Markovic { 0x886ae64d5e62554eULL, 0x8d67885ea97bb0a0ULL, }, 1141e6bea79SAleksandar Markovic { 0x886ae6634d935540ULL, 0x4b67bb5e157b520cULL, }, 1151e6bea79SAleksandar Markovic { 0xfbbe00634d93c708ULL, 0x12f7bb1a153f52fcULL, }, 1161e6bea79SAleksandar Markovic { 0xac5aae634d938b80ULL, 0x27d8bb1aab3f5214ULL, }, 1171e6bea79SAleksandar Markovic { 0x704f16635e93c74eULL, 0x8df188d8a94252a0ULL, }, 1181e6bea79SAleksandar Markovic { 0x886aaeaab9628b80ULL, 0x4b67c65eab7bb014ULL, }, /* 72 */ 1191e6bea79SAleksandar Markovic { 0xac5aae634d938b80ULL, 0x27d8bb1aab3f5214ULL, }, 1201e6bea79SAleksandar Markovic { 0xac5aaeaab9cf8b80ULL, 0x27d8c6ffab2b2514ULL, }, 1211e6bea79SAleksandar Markovic { 0x705aaeaa5e318b80ULL, 0x8dd888d8a94225a0ULL, }, 1221e6bea79SAleksandar Markovic { 0x886ae64d5e62554eULL, 0x8d67885ea97bb0a0ULL, }, 1231e6bea79SAleksandar Markovic { 0x704f16635e93c74eULL, 0x8df188d8a94252a0ULL, }, 1241e6bea79SAleksandar Markovic { 0x705aaeaa5ecf8b80ULL, 0x8dd888d8a94225a0ULL, }, 1251e6bea79SAleksandar Markovic { 0x704f164d5e31e24eULL, 0x8df188d8a942e2a0ULL, }, 1261e6bea79SAleksandar Markovic }; 1271e6bea79SAleksandar Markovic 1281e6bea79SAleksandar Markovic gettimeofday(&start, NULL); 1291e6bea79SAleksandar Markovic 1301e6bea79SAleksandar Markovic for (i = 0; i < PATTERN_INPUTS_SHORT_COUNT; i++) { 1311e6bea79SAleksandar Markovic for (j = 0; j < PATTERN_INPUTS_SHORT_COUNT; j++) { 1321e6bea79SAleksandar Markovic do_msa_MAX_A_B(b128_pattern[i], b128_pattern[j], 1331e6bea79SAleksandar Markovic b128_result[PATTERN_INPUTS_SHORT_COUNT * i + j]); 1341e6bea79SAleksandar Markovic } 1351e6bea79SAleksandar Markovic } 1361e6bea79SAleksandar Markovic 1371e6bea79SAleksandar Markovic for (i = 0; i < RANDOM_INPUTS_SHORT_COUNT; i++) { 1381e6bea79SAleksandar Markovic for (j = 0; j < RANDOM_INPUTS_SHORT_COUNT; j++) { 1391e6bea79SAleksandar Markovic do_msa_MAX_A_B(b128_random[i], b128_random[j], 1401e6bea79SAleksandar Markovic b128_result[((PATTERN_INPUTS_SHORT_COUNT) * 1411e6bea79SAleksandar Markovic (PATTERN_INPUTS_SHORT_COUNT)) + 1421e6bea79SAleksandar Markovic RANDOM_INPUTS_SHORT_COUNT * i + j]); 1431e6bea79SAleksandar Markovic } 1441e6bea79SAleksandar Markovic } 1451e6bea79SAleksandar Markovic 1461e6bea79SAleksandar Markovic gettimeofday(&end, NULL); 1471e6bea79SAleksandar Markovic 1481e6bea79SAleksandar Markovic elapsed_time = (end.tv_sec - start.tv_sec) * 1000.0; 1491e6bea79SAleksandar Markovic elapsed_time += (end.tv_usec - start.tv_usec) / 1000.0; 1501e6bea79SAleksandar Markovic 1511e6bea79SAleksandar Markovic ret = check_results(instruction_name, TEST_COUNT_TOTAL, elapsed_time, 1521e6bea79SAleksandar Markovic &b128_result[0][0], &b128_expect[0][0]); 1531e6bea79SAleksandar Markovic 1541e6bea79SAleksandar Markovic return ret; 1551e6bea79SAleksandar Markovic } 156