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