1*0fdd986aSMateja Marjanovic /* 2*0fdd986aSMateja Marjanovic * Test program for MSA instruction HADD_S.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 = "HADD_S.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 { 0xfffffffffffffffeULL, 0xfffffffffffffffeULL, }, /* 0 */ 45*0fdd986aSMateja Marjanovic { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, 46*0fdd986aSMateja Marjanovic { 0xffffffffaaaaaaa9ULL, 0xffffffffaaaaaaa9ULL, }, 47*0fdd986aSMateja Marjanovic { 0x0000000055555554ULL, 0x0000000055555554ULL, }, 48*0fdd986aSMateja Marjanovic { 0xffffffffcccccccbULL, 0xffffffffcccccccbULL, }, 49*0fdd986aSMateja Marjanovic { 0x0000000033333332ULL, 0x0000000033333332ULL, }, 50*0fdd986aSMateja Marjanovic { 0xffffffff8e38e38dULL, 0xffffffffe38e38e2ULL, }, 51*0fdd986aSMateja Marjanovic { 0x0000000071c71c70ULL, 0x000000001c71c71bULL, }, 52*0fdd986aSMateja Marjanovic { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, /* 8 */ 53*0fdd986aSMateja Marjanovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, 54*0fdd986aSMateja Marjanovic { 0xffffffffaaaaaaaaULL, 0xffffffffaaaaaaaaULL, }, 55*0fdd986aSMateja Marjanovic { 0x0000000055555555ULL, 0x0000000055555555ULL, }, 56*0fdd986aSMateja Marjanovic { 0xffffffffccccccccULL, 0xffffffffccccccccULL, }, 57*0fdd986aSMateja Marjanovic { 0x0000000033333333ULL, 0x0000000033333333ULL, }, 58*0fdd986aSMateja Marjanovic { 0xffffffff8e38e38eULL, 0xffffffffe38e38e3ULL, }, 59*0fdd986aSMateja Marjanovic { 0x0000000071c71c71ULL, 0x000000001c71c71cULL, }, 60*0fdd986aSMateja Marjanovic { 0xffffffffaaaaaaa9ULL, 0xffffffffaaaaaaa9ULL, }, /* 16 */ 61*0fdd986aSMateja Marjanovic { 0xffffffffaaaaaaaaULL, 0xffffffffaaaaaaaaULL, }, 62*0fdd986aSMateja Marjanovic { 0xffffffff55555554ULL, 0xffffffff55555554ULL, }, 63*0fdd986aSMateja Marjanovic { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, 64*0fdd986aSMateja Marjanovic { 0xffffffff77777776ULL, 0xffffffff77777776ULL, }, 65*0fdd986aSMateja Marjanovic { 0xffffffffddddddddULL, 0xffffffffddddddddULL, }, 66*0fdd986aSMateja Marjanovic { 0xffffffff38e38e38ULL, 0xffffffff8e38e38dULL, }, 67*0fdd986aSMateja Marjanovic { 0x000000001c71c71bULL, 0xffffffffc71c71c6ULL, }, 68*0fdd986aSMateja Marjanovic { 0x0000000055555554ULL, 0x0000000055555554ULL, }, /* 24 */ 69*0fdd986aSMateja Marjanovic { 0x0000000055555555ULL, 0x0000000055555555ULL, }, 70*0fdd986aSMateja Marjanovic { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, 71*0fdd986aSMateja Marjanovic { 0x00000000aaaaaaaaULL, 0x00000000aaaaaaaaULL, }, 72*0fdd986aSMateja Marjanovic { 0x0000000022222221ULL, 0x0000000022222221ULL, }, 73*0fdd986aSMateja Marjanovic { 0x0000000088888888ULL, 0x0000000088888888ULL, }, 74*0fdd986aSMateja Marjanovic { 0xffffffffe38e38e3ULL, 0x0000000038e38e38ULL, }, 75*0fdd986aSMateja Marjanovic { 0x00000000c71c71c6ULL, 0x0000000071c71c71ULL, }, 76*0fdd986aSMateja Marjanovic { 0xffffffffcccccccbULL, 0xffffffffcccccccbULL, }, /* 32 */ 77*0fdd986aSMateja Marjanovic { 0xffffffffccccccccULL, 0xffffffffccccccccULL, }, 78*0fdd986aSMateja Marjanovic { 0xffffffff77777776ULL, 0xffffffff77777776ULL, }, 79*0fdd986aSMateja Marjanovic { 0x0000000022222221ULL, 0x0000000022222221ULL, }, 80*0fdd986aSMateja Marjanovic { 0xffffffff99999998ULL, 0xffffffff99999998ULL, }, 81*0fdd986aSMateja Marjanovic { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, 82*0fdd986aSMateja Marjanovic { 0xffffffff5b05b05aULL, 0xffffffffb05b05afULL, }, 83*0fdd986aSMateja Marjanovic { 0x000000003e93e93dULL, 0xffffffffe93e93e8ULL, }, 84*0fdd986aSMateja Marjanovic { 0x0000000033333332ULL, 0x0000000033333332ULL, }, /* 40 */ 85*0fdd986aSMateja Marjanovic { 0x0000000033333333ULL, 0x0000000033333333ULL, }, 86*0fdd986aSMateja Marjanovic { 0xffffffffddddddddULL, 0xffffffffddddddddULL, }, 87*0fdd986aSMateja Marjanovic { 0x0000000088888888ULL, 0x0000000088888888ULL, }, 88*0fdd986aSMateja Marjanovic { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, 89*0fdd986aSMateja Marjanovic { 0x0000000066666666ULL, 0x0000000066666666ULL, }, 90*0fdd986aSMateja Marjanovic { 0xffffffffc16c16c1ULL, 0x0000000016c16c16ULL, }, 91*0fdd986aSMateja Marjanovic { 0x00000000a4fa4fa4ULL, 0x000000004fa4fa4fULL, }, 92*0fdd986aSMateja Marjanovic { 0xffffffffe38e38e2ULL, 0x0000000038e38e37ULL, }, /* 48 */ 93*0fdd986aSMateja Marjanovic { 0xffffffffe38e38e3ULL, 0x0000000038e38e38ULL, }, 94*0fdd986aSMateja Marjanovic { 0xffffffff8e38e38dULL, 0xffffffffe38e38e2ULL, }, 95*0fdd986aSMateja Marjanovic { 0x0000000038e38e38ULL, 0x000000008e38e38dULL, }, 96*0fdd986aSMateja Marjanovic { 0xffffffffb05b05afULL, 0x0000000005b05b04ULL, }, 97*0fdd986aSMateja Marjanovic { 0x0000000016c16c16ULL, 0x000000006c16c16bULL, }, 98*0fdd986aSMateja Marjanovic { 0xffffffff71c71c71ULL, 0x000000001c71c71bULL, }, 99*0fdd986aSMateja Marjanovic { 0x0000000055555554ULL, 0x0000000055555554ULL, }, 100*0fdd986aSMateja Marjanovic { 0x000000001c71c71bULL, 0xffffffffc71c71c6ULL, }, /* 56 */ 101*0fdd986aSMateja Marjanovic { 0x000000001c71c71cULL, 0xffffffffc71c71c7ULL, }, 102*0fdd986aSMateja Marjanovic { 0xffffffffc71c71c6ULL, 0xffffffff71c71c71ULL, }, 103*0fdd986aSMateja Marjanovic { 0x0000000071c71c71ULL, 0x000000001c71c71cULL, }, 104*0fdd986aSMateja Marjanovic { 0xffffffffe93e93e8ULL, 0xffffffff93e93e93ULL, }, 105*0fdd986aSMateja Marjanovic { 0x000000004fa4fa4fULL, 0xfffffffffa4fa4faULL, }, 106*0fdd986aSMateja Marjanovic { 0xffffffffaaaaaaaaULL, 0xffffffffaaaaaaaaULL, }, 107*0fdd986aSMateja Marjanovic { 0x000000008e38e38dULL, 0xffffffffe38e38e3ULL, }, 108*0fdd986aSMateja Marjanovic { 0xffffffffb0cd3c0cULL, 0x0000000049e2bb6aULL, }, /* 64 */ 109*0fdd986aSMateja Marjanovic { 0xffffffffd5feadd4ULL, 0x0000000060a65e5aULL, }, 110*0fdd986aSMateja Marjanovic { 0xffffffff423a724cULL, 0xfffffffff6923072ULL, }, 111*0fdd986aSMateja Marjanovic { 0xffffffffe69cc91aULL, 0xfffffffff4a9edfeULL, }, 112*0fdd986aSMateja Marjanovic { 0x00000000242055a3ULL, 0x0000000011736b26ULL, }, 113*0fdd986aSMateja Marjanovic { 0x000000004951c76bULL, 0x0000000028370e16ULL, }, 114*0fdd986aSMateja Marjanovic { 0xffffffffb58d8be3ULL, 0xffffffffbe22e02eULL, }, 115*0fdd986aSMateja Marjanovic { 0x0000000059efe2b1ULL, 0xffffffffbc3a9dbaULL, }, 116*0fdd986aSMateja Marjanovic { 0xffffffffd4bd03eaULL, 0x000000002654770bULL, }, /* 72 */ 117*0fdd986aSMateja Marjanovic { 0xfffffffff9ee75b2ULL, 0x000000003d1819fbULL, }, 118*0fdd986aSMateja Marjanovic { 0xffffffff662a3a2aULL, 0xffffffffd303ec13ULL, }, 119*0fdd986aSMateja Marjanovic { 0x000000000a8c90f8ULL, 0xffffffffd11ba99fULL, }, 120*0fdd986aSMateja Marjanovic { 0x0000000098b16b8dULL, 0xffffffff8c6d38e4ULL, }, 121*0fdd986aSMateja Marjanovic { 0x00000000bde2dd55ULL, 0xffffffffa330dbd4ULL, }, 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_HADD_S_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_HADD_S_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