1*0fdd986aSMateja Marjanovic /* 2*0fdd986aSMateja Marjanovic * Test program for MSA instruction ADDS_U.D 3*0fdd986aSMateja Marjanovic * 4*0fdd986aSMateja Marjanovic * Copyright (C) 2019 Wave Computing, Inc. 5*0fdd986aSMateja Marjanovic * Copyright (C) 2019 Mateja Marjanovic <mateja.marjanovic@rt-rk.com> 6*0fdd986aSMateja Marjanovic * 7*0fdd986aSMateja Marjanovic * This program is free software: you can redistribute it and/or modify 8*0fdd986aSMateja Marjanovic * it under the terms of the GNU General Public License as published by 9*0fdd986aSMateja Marjanovic * the Free Software Foundation, either version 2 of the License, or 10*0fdd986aSMateja Marjanovic * (at your option) any later version. 11*0fdd986aSMateja Marjanovic * 12*0fdd986aSMateja Marjanovic * This program is distributed in the hope that it will be useful, 13*0fdd986aSMateja Marjanovic * but WITHOUT ANY WARRANTY; without even the implied warranty of 14*0fdd986aSMateja Marjanovic * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15*0fdd986aSMateja Marjanovic * GNU General Public License for more details. 16*0fdd986aSMateja Marjanovic * 17*0fdd986aSMateja Marjanovic * You should have received a copy of the GNU General Public License 18*0fdd986aSMateja Marjanovic * along with this program. If not, see <https://www.gnu.org/licenses/>. 19*0fdd986aSMateja Marjanovic * 20*0fdd986aSMateja Marjanovic */ 21*0fdd986aSMateja Marjanovic 22*0fdd986aSMateja Marjanovic #include <sys/time.h> 23*0fdd986aSMateja Marjanovic #include <stdint.h> 24*0fdd986aSMateja Marjanovic 25*0fdd986aSMateja Marjanovic #include "../../../../include/wrappers_msa.h" 26*0fdd986aSMateja Marjanovic #include "../../../../include/test_inputs.h" 27*0fdd986aSMateja Marjanovic #include "../../../../include/test_utils.h" 28*0fdd986aSMateja Marjanovic 29*0fdd986aSMateja Marjanovic #define TEST_COUNT_TOTAL ( \ 30*0fdd986aSMateja Marjanovic (PATTERN_INPUTS_SHORT_COUNT) * (PATTERN_INPUTS_SHORT_COUNT) + \ 31*0fdd986aSMateja Marjanovic (RANDOM_INPUTS_SHORT_COUNT) * (RANDOM_INPUTS_SHORT_COUNT)) 32*0fdd986aSMateja Marjanovic 33*0fdd986aSMateja Marjanovic 34*0fdd986aSMateja Marjanovic int32_t main(void) 35*0fdd986aSMateja Marjanovic { 36*0fdd986aSMateja Marjanovic char *instruction_name = "ADDS_U.D"; 37*0fdd986aSMateja Marjanovic int32_t ret; 38*0fdd986aSMateja Marjanovic uint32_t i, j; 39*0fdd986aSMateja Marjanovic struct timeval start, end; 40*0fdd986aSMateja Marjanovic double elapsed_time; 41*0fdd986aSMateja Marjanovic 42*0fdd986aSMateja Marjanovic uint64_t b128_result[TEST_COUNT_TOTAL][2]; 43*0fdd986aSMateja Marjanovic uint64_t b128_expect[TEST_COUNT_TOTAL][2] = { 44*0fdd986aSMateja Marjanovic { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, /* 0 */ 45*0fdd986aSMateja Marjanovic { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, 46*0fdd986aSMateja Marjanovic { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, 47*0fdd986aSMateja Marjanovic { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, 48*0fdd986aSMateja Marjanovic { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, 49*0fdd986aSMateja Marjanovic { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, 50*0fdd986aSMateja Marjanovic { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, 51*0fdd986aSMateja Marjanovic { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, 52*0fdd986aSMateja Marjanovic { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, /* 8 */ 53*0fdd986aSMateja Marjanovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, 54*0fdd986aSMateja Marjanovic { 0xaaaaaaaaaaaaaaaaULL, 0xaaaaaaaaaaaaaaaaULL, }, 55*0fdd986aSMateja Marjanovic { 0x5555555555555555ULL, 0x5555555555555555ULL, }, 56*0fdd986aSMateja Marjanovic { 0xccccccccccccccccULL, 0xccccccccccccccccULL, }, 57*0fdd986aSMateja Marjanovic { 0x3333333333333333ULL, 0x3333333333333333ULL, }, 58*0fdd986aSMateja Marjanovic { 0xe38e38e38e38e38eULL, 0x38e38e38e38e38e3ULL, }, 59*0fdd986aSMateja Marjanovic { 0x1c71c71c71c71c71ULL, 0xc71c71c71c71c71cULL, }, 60*0fdd986aSMateja Marjanovic { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, /* 16 */ 61*0fdd986aSMateja Marjanovic { 0xaaaaaaaaaaaaaaaaULL, 0xaaaaaaaaaaaaaaaaULL, }, 62*0fdd986aSMateja Marjanovic { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, 63*0fdd986aSMateja Marjanovic { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, 64*0fdd986aSMateja Marjanovic { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, 65*0fdd986aSMateja Marjanovic { 0xddddddddddddddddULL, 0xddddddddddddddddULL, }, 66*0fdd986aSMateja Marjanovic { 0xffffffffffffffffULL, 0xe38e38e38e38e38dULL, }, 67*0fdd986aSMateja Marjanovic { 0xc71c71c71c71c71bULL, 0xffffffffffffffffULL, }, 68*0fdd986aSMateja Marjanovic { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, /* 24 */ 69*0fdd986aSMateja Marjanovic { 0x5555555555555555ULL, 0x5555555555555555ULL, }, 70*0fdd986aSMateja Marjanovic { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, 71*0fdd986aSMateja Marjanovic { 0xaaaaaaaaaaaaaaaaULL, 0xaaaaaaaaaaaaaaaaULL, }, 72*0fdd986aSMateja Marjanovic { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, 73*0fdd986aSMateja Marjanovic { 0x8888888888888888ULL, 0x8888888888888888ULL, }, 74*0fdd986aSMateja Marjanovic { 0xffffffffffffffffULL, 0x8e38e38e38e38e38ULL, }, 75*0fdd986aSMateja Marjanovic { 0x71c71c71c71c71c6ULL, 0xffffffffffffffffULL, }, 76*0fdd986aSMateja Marjanovic { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, /* 32 */ 77*0fdd986aSMateja Marjanovic { 0xccccccccccccccccULL, 0xccccccccccccccccULL, }, 78*0fdd986aSMateja Marjanovic { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, 79*0fdd986aSMateja Marjanovic { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, 80*0fdd986aSMateja Marjanovic { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, 81*0fdd986aSMateja Marjanovic { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, 82*0fdd986aSMateja Marjanovic { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, 83*0fdd986aSMateja Marjanovic { 0xe93e93e93e93e93dULL, 0xffffffffffffffffULL, }, 84*0fdd986aSMateja Marjanovic { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, /* 40 */ 85*0fdd986aSMateja Marjanovic { 0x3333333333333333ULL, 0x3333333333333333ULL, }, 86*0fdd986aSMateja Marjanovic { 0xddddddddddddddddULL, 0xddddddddddddddddULL, }, 87*0fdd986aSMateja Marjanovic { 0x8888888888888888ULL, 0x8888888888888888ULL, }, 88*0fdd986aSMateja Marjanovic { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, 89*0fdd986aSMateja Marjanovic { 0x6666666666666666ULL, 0x6666666666666666ULL, }, 90*0fdd986aSMateja Marjanovic { 0xffffffffffffffffULL, 0x6c16c16c16c16c16ULL, }, 91*0fdd986aSMateja Marjanovic { 0x4fa4fa4fa4fa4fa4ULL, 0xfa4fa4fa4fa4fa4fULL, }, 92*0fdd986aSMateja Marjanovic { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, /* 48 */ 93*0fdd986aSMateja Marjanovic { 0xe38e38e38e38e38eULL, 0x38e38e38e38e38e3ULL, }, 94*0fdd986aSMateja Marjanovic { 0xffffffffffffffffULL, 0xe38e38e38e38e38dULL, }, 95*0fdd986aSMateja Marjanovic { 0xffffffffffffffffULL, 0x8e38e38e38e38e38ULL, }, 96*0fdd986aSMateja Marjanovic { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, 97*0fdd986aSMateja Marjanovic { 0xffffffffffffffffULL, 0x6c16c16c16c16c16ULL, }, 98*0fdd986aSMateja Marjanovic { 0xffffffffffffffffULL, 0x71c71c71c71c71c6ULL, }, 99*0fdd986aSMateja Marjanovic { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, 100*0fdd986aSMateja Marjanovic { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, /* 56 */ 101*0fdd986aSMateja Marjanovic { 0x1c71c71c71c71c71ULL, 0xc71c71c71c71c71cULL, }, 102*0fdd986aSMateja Marjanovic { 0xc71c71c71c71c71bULL, 0xffffffffffffffffULL, }, 103*0fdd986aSMateja Marjanovic { 0x71c71c71c71c71c6ULL, 0xffffffffffffffffULL, }, 104*0fdd986aSMateja Marjanovic { 0xe93e93e93e93e93dULL, 0xffffffffffffffffULL, }, 105*0fdd986aSMateja Marjanovic { 0x4fa4fa4fa4fa4fa4ULL, 0xfa4fa4fa4fa4fa4fULL, }, 106*0fdd986aSMateja Marjanovic { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, 107*0fdd986aSMateja Marjanovic { 0x38e38e38e38e38e2ULL, 0xffffffffffffffffULL, }, 108*0fdd986aSMateja Marjanovic { 0xffffffffffffffffULL, 0x96ce16bdfcf76018ULL, }, /* 64 */ 109*0fdd986aSMateja Marjanovic { 0xffffffffffffffffULL, 0x5e5ec67913bb0308ULL, }, 110*0fdd986aSMateja Marjanovic { 0xffffffffffffffffULL, 0x733fd25ea9a6d520ULL, }, 111*0fdd986aSMateja Marjanovic { 0xf8b9fd198694378eULL, 0xd9589437a7be92acULL, }, 112*0fdd986aSMateja Marjanovic { 0xffffffffffffffffULL, 0x5e5ec67913bb0308ULL, }, 113*0fdd986aSMateja Marjanovic { 0xffffffffffffffffULL, 0x25ef76342a7ea5f8ULL, }, 114*0fdd986aSMateja Marjanovic { 0xffffffffffffffffULL, 0x3ad08219c06a7810ULL, }, 115*0fdd986aSMateja Marjanovic { 0xffffffffffffffffULL, 0xa0e943f2be82359cULL, }, 116*0fdd986aSMateja Marjanovic { 0xffffffffffffffffULL, 0x733fd25ea9a6d520ULL, }, /* 72 */ 117*0fdd986aSMateja Marjanovic { 0xffffffffffffffffULL, 0x3ad08219c06a7810ULL, }, 118*0fdd986aSMateja Marjanovic { 0xffffffffffffffffULL, 0x4fb18dff56564a28ULL, }, 119*0fdd986aSMateja Marjanovic { 0xffffffffffffffffULL, 0xb5ca4fd8546e07b4ULL, }, 120*0fdd986aSMateja Marjanovic { 0xf8b9fd198694378eULL, 0xd9589437a7be92acULL, }, 121*0fdd986aSMateja Marjanovic { 0xffffffffffffffffULL, 0xa0e943f2be82359cULL, }, 122*0fdd986aSMateja Marjanovic }; 123*0fdd986aSMateja Marjanovic 124*0fdd986aSMateja Marjanovic gettimeofday(&start, NULL); 125*0fdd986aSMateja Marjanovic 126*0fdd986aSMateja Marjanovic for (i = 0; i < PATTERN_INPUTS_SHORT_COUNT; i++) { 127*0fdd986aSMateja Marjanovic for (j = 0; j < PATTERN_INPUTS_SHORT_COUNT; j++) { 128*0fdd986aSMateja Marjanovic do_msa_ADDS_U_D(b128_pattern[i], b128_pattern[j], 129*0fdd986aSMateja Marjanovic b128_result[PATTERN_INPUTS_SHORT_COUNT * i + j]); 130*0fdd986aSMateja Marjanovic } 131*0fdd986aSMateja Marjanovic } 132*0fdd986aSMateja Marjanovic 133*0fdd986aSMateja Marjanovic for (i = 0; i < RANDOM_INPUTS_SHORT_COUNT; i++) { 134*0fdd986aSMateja Marjanovic for (j = 0; j < RANDOM_INPUTS_SHORT_COUNT; j++) { 135*0fdd986aSMateja Marjanovic do_msa_ADDS_U_D(b128_random[i], b128_random[j], 136*0fdd986aSMateja Marjanovic b128_result[((PATTERN_INPUTS_SHORT_COUNT) * 137*0fdd986aSMateja Marjanovic (PATTERN_INPUTS_SHORT_COUNT)) + 138*0fdd986aSMateja Marjanovic RANDOM_INPUTS_SHORT_COUNT * i + j]); 139*0fdd986aSMateja Marjanovic } 140*0fdd986aSMateja Marjanovic } 141*0fdd986aSMateja Marjanovic 142*0fdd986aSMateja Marjanovic gettimeofday(&end, NULL); 143*0fdd986aSMateja Marjanovic 144*0fdd986aSMateja Marjanovic elapsed_time = (end.tv_sec - start.tv_sec) * 1000.0; 145*0fdd986aSMateja Marjanovic elapsed_time += (end.tv_usec - start.tv_usec) / 1000.0; 146*0fdd986aSMateja Marjanovic 147*0fdd986aSMateja Marjanovic ret = check_results(instruction_name, TEST_COUNT_TOTAL, elapsed_time, 148*0fdd986aSMateja Marjanovic &b128_result[0][0], &b128_expect[0][0]); 149*0fdd986aSMateja Marjanovic 150*0fdd986aSMateja Marjanovic return ret; 151*0fdd986aSMateja Marjanovic } 152