1*0fdd986aSMateja Marjanovic /* 2*0fdd986aSMateja Marjanovic * Test program for MSA instruction ADD_A.W 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 = "ADD_A.W"; 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 { 0x0000000200000002ULL, 0x0000000200000002ULL, }, /* 0 */ 45*0fdd986aSMateja Marjanovic { 0x0000000100000001ULL, 0x0000000100000001ULL, }, 46*0fdd986aSMateja Marjanovic { 0x5555555755555557ULL, 0x5555555755555557ULL, }, 47*0fdd986aSMateja Marjanovic { 0x5555555655555556ULL, 0x5555555655555556ULL, }, 48*0fdd986aSMateja Marjanovic { 0x3333333533333335ULL, 0x3333333533333335ULL, }, 49*0fdd986aSMateja Marjanovic { 0x3333333433333334ULL, 0x3333333433333334ULL, }, 50*0fdd986aSMateja Marjanovic { 0x1c71c71e71c71c73ULL, 0x38e38e391c71c71eULL, }, 51*0fdd986aSMateja Marjanovic { 0x1c71c71d71c71c72ULL, 0x38e38e3a1c71c71dULL, }, 52*0fdd986aSMateja Marjanovic { 0x0000000100000001ULL, 0x0000000100000001ULL, }, /* 8 */ 53*0fdd986aSMateja Marjanovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, 54*0fdd986aSMateja Marjanovic { 0x5555555655555556ULL, 0x5555555655555556ULL, }, 55*0fdd986aSMateja Marjanovic { 0x5555555555555555ULL, 0x5555555555555555ULL, }, 56*0fdd986aSMateja Marjanovic { 0x3333333433333334ULL, 0x3333333433333334ULL, }, 57*0fdd986aSMateja Marjanovic { 0x3333333333333333ULL, 0x3333333333333333ULL, }, 58*0fdd986aSMateja Marjanovic { 0x1c71c71d71c71c72ULL, 0x38e38e381c71c71dULL, }, 59*0fdd986aSMateja Marjanovic { 0x1c71c71c71c71c71ULL, 0x38e38e391c71c71cULL, }, 60*0fdd986aSMateja Marjanovic { 0x5555555755555557ULL, 0x5555555755555557ULL, }, /* 16 */ 61*0fdd986aSMateja Marjanovic { 0x5555555655555556ULL, 0x5555555655555556ULL, }, 62*0fdd986aSMateja Marjanovic { 0xaaaaaaacaaaaaaacULL, 0xaaaaaaacaaaaaaacULL, }, 63*0fdd986aSMateja Marjanovic { 0xaaaaaaabaaaaaaabULL, 0xaaaaaaabaaaaaaabULL, }, 64*0fdd986aSMateja Marjanovic { 0x8888888a8888888aULL, 0x8888888a8888888aULL, }, 65*0fdd986aSMateja Marjanovic { 0x8888888988888889ULL, 0x8888888988888889ULL, }, 66*0fdd986aSMateja Marjanovic { 0x71c71c73c71c71c8ULL, 0x8e38e38e71c71c73ULL, }, 67*0fdd986aSMateja Marjanovic { 0x71c71c72c71c71c7ULL, 0x8e38e38f71c71c72ULL, }, 68*0fdd986aSMateja Marjanovic { 0x5555555655555556ULL, 0x5555555655555556ULL, }, /* 24 */ 69*0fdd986aSMateja Marjanovic { 0x5555555555555555ULL, 0x5555555555555555ULL, }, 70*0fdd986aSMateja Marjanovic { 0xaaaaaaabaaaaaaabULL, 0xaaaaaaabaaaaaaabULL, }, 71*0fdd986aSMateja Marjanovic { 0xaaaaaaaaaaaaaaaaULL, 0xaaaaaaaaaaaaaaaaULL, }, 72*0fdd986aSMateja Marjanovic { 0x8888888988888889ULL, 0x8888888988888889ULL, }, 73*0fdd986aSMateja Marjanovic { 0x8888888888888888ULL, 0x8888888888888888ULL, }, 74*0fdd986aSMateja Marjanovic { 0x71c71c72c71c71c7ULL, 0x8e38e38d71c71c72ULL, }, 75*0fdd986aSMateja Marjanovic { 0x71c71c71c71c71c6ULL, 0x8e38e38e71c71c71ULL, }, 76*0fdd986aSMateja Marjanovic { 0x3333333533333335ULL, 0x3333333533333335ULL, }, /* 32 */ 77*0fdd986aSMateja Marjanovic { 0x3333333433333334ULL, 0x3333333433333334ULL, }, 78*0fdd986aSMateja Marjanovic { 0x8888888a8888888aULL, 0x8888888a8888888aULL, }, 79*0fdd986aSMateja Marjanovic { 0x8888888988888889ULL, 0x8888888988888889ULL, }, 80*0fdd986aSMateja Marjanovic { 0x6666666866666668ULL, 0x6666666866666668ULL, }, 81*0fdd986aSMateja Marjanovic { 0x6666666766666667ULL, 0x6666666766666667ULL, }, 82*0fdd986aSMateja Marjanovic { 0x4fa4fa51a4fa4fa6ULL, 0x6c16c16c4fa4fa51ULL, }, 83*0fdd986aSMateja Marjanovic { 0x4fa4fa50a4fa4fa5ULL, 0x6c16c16d4fa4fa50ULL, }, 84*0fdd986aSMateja Marjanovic { 0x3333333433333334ULL, 0x3333333433333334ULL, }, /* 40 */ 85*0fdd986aSMateja Marjanovic { 0x3333333333333333ULL, 0x3333333333333333ULL, }, 86*0fdd986aSMateja Marjanovic { 0x8888888988888889ULL, 0x8888888988888889ULL, }, 87*0fdd986aSMateja Marjanovic { 0x8888888888888888ULL, 0x8888888888888888ULL, }, 88*0fdd986aSMateja Marjanovic { 0x6666666766666667ULL, 0x6666666766666667ULL, }, 89*0fdd986aSMateja Marjanovic { 0x6666666666666666ULL, 0x6666666666666666ULL, }, 90*0fdd986aSMateja Marjanovic { 0x4fa4fa50a4fa4fa5ULL, 0x6c16c16b4fa4fa50ULL, }, 91*0fdd986aSMateja Marjanovic { 0x4fa4fa4fa4fa4fa4ULL, 0x6c16c16c4fa4fa4fULL, }, 92*0fdd986aSMateja Marjanovic { 0x1c71c71e71c71c73ULL, 0x38e38e391c71c71eULL, }, /* 48 */ 93*0fdd986aSMateja Marjanovic { 0x1c71c71d71c71c72ULL, 0x38e38e381c71c71dULL, }, 94*0fdd986aSMateja Marjanovic { 0x71c71c73c71c71c8ULL, 0x8e38e38e71c71c73ULL, }, 95*0fdd986aSMateja Marjanovic { 0x71c71c72c71c71c7ULL, 0x8e38e38d71c71c72ULL, }, 96*0fdd986aSMateja Marjanovic { 0x4fa4fa51a4fa4fa6ULL, 0x6c16c16c4fa4fa51ULL, }, 97*0fdd986aSMateja Marjanovic { 0x4fa4fa50a4fa4fa5ULL, 0x6c16c16b4fa4fa50ULL, }, 98*0fdd986aSMateja Marjanovic { 0x38e38e3ae38e38e4ULL, 0x71c71c7038e38e3aULL, }, 99*0fdd986aSMateja Marjanovic { 0x38e38e39e38e38e3ULL, 0x71c71c7138e38e39ULL, }, 100*0fdd986aSMateja Marjanovic { 0x1c71c71d71c71c72ULL, 0x38e38e3a1c71c71dULL, }, /* 56 */ 101*0fdd986aSMateja Marjanovic { 0x1c71c71c71c71c71ULL, 0x38e38e391c71c71cULL, }, 102*0fdd986aSMateja Marjanovic { 0x71c71c72c71c71c7ULL, 0x8e38e38f71c71c72ULL, }, 103*0fdd986aSMateja Marjanovic { 0x71c71c71c71c71c6ULL, 0x8e38e38e71c71c71ULL, }, 104*0fdd986aSMateja Marjanovic { 0x4fa4fa50a4fa4fa5ULL, 0x6c16c16d4fa4fa50ULL, }, 105*0fdd986aSMateja Marjanovic { 0x4fa4fa4fa4fa4fa4ULL, 0x6c16c16c4fa4fa4fULL, }, 106*0fdd986aSMateja Marjanovic { 0x38e38e39e38e38e3ULL, 0x71c71c7138e38e39ULL, }, 107*0fdd986aSMateja Marjanovic { 0x38e38e38e38e38e2ULL, 0x71c71c7238e38e38ULL, }, 108*0fdd986aSMateja Marjanovic { 0xef2a326850c4aa80ULL, 0x96ce16bc03089fe8ULL, }, /* 64 */ 109*0fdd986aSMateja Marjanovic { 0x7bd718d175f61c48ULL, 0x5e5ec67816c3a2f0ULL, }, 110*0fdd986aSMateja Marjanovic { 0xcb3a6a8a6e92c9c0ULL, 0x733fd25d56592ae0ULL, }, 111*0fdd986aSMateja Marjanovic { 0xe7e42f818694378eULL, 0xbd75828658416d54ULL, }, 112*0fdd986aSMateja Marjanovic { 0x7bd718d175f61c48ULL, 0x5e5ec67816c3a2f0ULL, }, 113*0fdd986aSMateja Marjanovic { 0x0883ff3a9b278e10ULL, 0x25ef76342a7ea5f8ULL, }, 114*0fdd986aSMateja Marjanovic { 0x57e750f393c43b88ULL, 0x3ad082196a142de8ULL, }, 115*0fdd986aSMateja Marjanovic { 0x749115eaabc5a956ULL, 0x850632426bfc705cULL, }, 116*0fdd986aSMateja Marjanovic { 0xcb3a6a8a6e92c9c0ULL, 0x733fd25d56592ae0ULL, }, /* 72 */ 117*0fdd986aSMateja Marjanovic { 0x57e750f393c43b88ULL, 0x3ad082196a142de8ULL, }, 118*0fdd986aSMateja Marjanovic { 0xa74aa2ac8c60e900ULL, 0x4fb18dfea9a9b5d8ULL, }, 119*0fdd986aSMateja Marjanovic { 0xc3f467a3a46256ceULL, 0x99e73e27ab91f84cULL, }, 120*0fdd986aSMateja Marjanovic { 0xe7e42f818694378eULL, 0xbd75828658416d54ULL, }, 121*0fdd986aSMateja Marjanovic { 0x749115eaabc5a956ULL, 0x850632426bfc705cULL, }, 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_ADD_A_W(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_ADD_A_W(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