1*fc76f486SAleksandar Markovic /* 2*fc76f486SAleksandar Markovic * Test program for MSA instruction ILVL.W 3*fc76f486SAleksandar Markovic * 4*fc76f486SAleksandar Markovic * Copyright (C) 2018 Wave Computing, Inc. 5*fc76f486SAleksandar Markovic * Copyright (C) 2018 Aleksandar Markovic <amarkovic@wavecomp.com> 6*fc76f486SAleksandar Markovic * 7*fc76f486SAleksandar Markovic * This program is free software: you can redistribute it and/or modify 8*fc76f486SAleksandar Markovic * it under the terms of the GNU General Public License as published by 9*fc76f486SAleksandar Markovic * the Free Software Foundation, either version 2 of the License, or 10*fc76f486SAleksandar Markovic * (at your option) any later version. 11*fc76f486SAleksandar Markovic * 12*fc76f486SAleksandar Markovic * This program is distributed in the hope that it will be useful, 13*fc76f486SAleksandar Markovic * but WITHOUT ANY WARRANTY; without even the implied warranty of 14*fc76f486SAleksandar Markovic * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15*fc76f486SAleksandar Markovic * GNU General Public License for more details. 16*fc76f486SAleksandar Markovic * 17*fc76f486SAleksandar Markovic * You should have received a copy of the GNU General Public License 18*fc76f486SAleksandar Markovic * along with this program. If not, see <https://www.gnu.org/licenses/>. 19*fc76f486SAleksandar Markovic * 20*fc76f486SAleksandar Markovic */ 21*fc76f486SAleksandar Markovic 22*fc76f486SAleksandar Markovic #include <sys/time.h> 23*fc76f486SAleksandar Markovic #include <stdint.h> 24*fc76f486SAleksandar Markovic 25*fc76f486SAleksandar Markovic #include "../../../../include/wrappers_msa.h" 26*fc76f486SAleksandar Markovic #include "../../../../include/test_inputs.h" 27*fc76f486SAleksandar Markovic #include "../../../../include/test_utils.h" 28*fc76f486SAleksandar Markovic 29*fc76f486SAleksandar Markovic #define TEST_COUNT_TOTAL ( \ 30*fc76f486SAleksandar Markovic (PATTERN_INPUTS_SHORT_COUNT) * (PATTERN_INPUTS_SHORT_COUNT) + \ 31*fc76f486SAleksandar Markovic (RANDOM_INPUTS_SHORT_COUNT) * (RANDOM_INPUTS_SHORT_COUNT)) 32*fc76f486SAleksandar Markovic 33*fc76f486SAleksandar Markovic 34*fc76f486SAleksandar Markovic int32_t main(void) 35*fc76f486SAleksandar Markovic { 36*fc76f486SAleksandar Markovic char *instruction_name = "ILVL.W"; 37*fc76f486SAleksandar Markovic int32_t ret; 38*fc76f486SAleksandar Markovic uint32_t i, j; 39*fc76f486SAleksandar Markovic struct timeval start, end; 40*fc76f486SAleksandar Markovic double elapsed_time; 41*fc76f486SAleksandar Markovic 42*fc76f486SAleksandar Markovic uint64_t b128_result[TEST_COUNT_TOTAL][2]; 43*fc76f486SAleksandar Markovic uint64_t b128_expect[TEST_COUNT_TOTAL][2] = { 44*fc76f486SAleksandar Markovic { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, /* 0 */ 45*fc76f486SAleksandar Markovic { 0xffffffff00000000ULL, 0xffffffff00000000ULL, }, 46*fc76f486SAleksandar Markovic { 0xffffffffaaaaaaaaULL, 0xffffffffaaaaaaaaULL, }, 47*fc76f486SAleksandar Markovic { 0xffffffff55555555ULL, 0xffffffff55555555ULL, }, 48*fc76f486SAleksandar Markovic { 0xffffffffccccccccULL, 0xffffffffccccccccULL, }, 49*fc76f486SAleksandar Markovic { 0xffffffff33333333ULL, 0xffffffff33333333ULL, }, 50*fc76f486SAleksandar Markovic { 0xffffffffe38e38e3ULL, 0xffffffff38e38e38ULL, }, 51*fc76f486SAleksandar Markovic { 0xffffffff1c71c71cULL, 0xffffffffc71c71c7ULL, }, 52*fc76f486SAleksandar Markovic { 0x00000000ffffffffULL, 0x00000000ffffffffULL, }, /* 8 */ 53*fc76f486SAleksandar Markovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, 54*fc76f486SAleksandar Markovic { 0x00000000aaaaaaaaULL, 0x00000000aaaaaaaaULL, }, 55*fc76f486SAleksandar Markovic { 0x0000000055555555ULL, 0x0000000055555555ULL, }, 56*fc76f486SAleksandar Markovic { 0x00000000ccccccccULL, 0x00000000ccccccccULL, }, 57*fc76f486SAleksandar Markovic { 0x0000000033333333ULL, 0x0000000033333333ULL, }, 58*fc76f486SAleksandar Markovic { 0x00000000e38e38e3ULL, 0x0000000038e38e38ULL, }, 59*fc76f486SAleksandar Markovic { 0x000000001c71c71cULL, 0x00000000c71c71c7ULL, }, 60*fc76f486SAleksandar Markovic { 0xaaaaaaaaffffffffULL, 0xaaaaaaaaffffffffULL, }, /* 16 */ 61*fc76f486SAleksandar Markovic { 0xaaaaaaaa00000000ULL, 0xaaaaaaaa00000000ULL, }, 62*fc76f486SAleksandar Markovic { 0xaaaaaaaaaaaaaaaaULL, 0xaaaaaaaaaaaaaaaaULL, }, 63*fc76f486SAleksandar Markovic { 0xaaaaaaaa55555555ULL, 0xaaaaaaaa55555555ULL, }, 64*fc76f486SAleksandar Markovic { 0xaaaaaaaaccccccccULL, 0xaaaaaaaaccccccccULL, }, 65*fc76f486SAleksandar Markovic { 0xaaaaaaaa33333333ULL, 0xaaaaaaaa33333333ULL, }, 66*fc76f486SAleksandar Markovic { 0xaaaaaaaae38e38e3ULL, 0xaaaaaaaa38e38e38ULL, }, 67*fc76f486SAleksandar Markovic { 0xaaaaaaaa1c71c71cULL, 0xaaaaaaaac71c71c7ULL, }, 68*fc76f486SAleksandar Markovic { 0x55555555ffffffffULL, 0x55555555ffffffffULL, }, /* 24 */ 69*fc76f486SAleksandar Markovic { 0x5555555500000000ULL, 0x5555555500000000ULL, }, 70*fc76f486SAleksandar Markovic { 0x55555555aaaaaaaaULL, 0x55555555aaaaaaaaULL, }, 71*fc76f486SAleksandar Markovic { 0x5555555555555555ULL, 0x5555555555555555ULL, }, 72*fc76f486SAleksandar Markovic { 0x55555555ccccccccULL, 0x55555555ccccccccULL, }, 73*fc76f486SAleksandar Markovic { 0x5555555533333333ULL, 0x5555555533333333ULL, }, 74*fc76f486SAleksandar Markovic { 0x55555555e38e38e3ULL, 0x5555555538e38e38ULL, }, 75*fc76f486SAleksandar Markovic { 0x555555551c71c71cULL, 0x55555555c71c71c7ULL, }, 76*fc76f486SAleksandar Markovic { 0xccccccccffffffffULL, 0xccccccccffffffffULL, }, /* 32 */ 77*fc76f486SAleksandar Markovic { 0xcccccccc00000000ULL, 0xcccccccc00000000ULL, }, 78*fc76f486SAleksandar Markovic { 0xccccccccaaaaaaaaULL, 0xccccccccaaaaaaaaULL, }, 79*fc76f486SAleksandar Markovic { 0xcccccccc55555555ULL, 0xcccccccc55555555ULL, }, 80*fc76f486SAleksandar Markovic { 0xccccccccccccccccULL, 0xccccccccccccccccULL, }, 81*fc76f486SAleksandar Markovic { 0xcccccccc33333333ULL, 0xcccccccc33333333ULL, }, 82*fc76f486SAleksandar Markovic { 0xcccccccce38e38e3ULL, 0xcccccccc38e38e38ULL, }, 83*fc76f486SAleksandar Markovic { 0xcccccccc1c71c71cULL, 0xccccccccc71c71c7ULL, }, 84*fc76f486SAleksandar Markovic { 0x33333333ffffffffULL, 0x33333333ffffffffULL, }, /* 40 */ 85*fc76f486SAleksandar Markovic { 0x3333333300000000ULL, 0x3333333300000000ULL, }, 86*fc76f486SAleksandar Markovic { 0x33333333aaaaaaaaULL, 0x33333333aaaaaaaaULL, }, 87*fc76f486SAleksandar Markovic { 0x3333333355555555ULL, 0x3333333355555555ULL, }, 88*fc76f486SAleksandar Markovic { 0x33333333ccccccccULL, 0x33333333ccccccccULL, }, 89*fc76f486SAleksandar Markovic { 0x3333333333333333ULL, 0x3333333333333333ULL, }, 90*fc76f486SAleksandar Markovic { 0x33333333e38e38e3ULL, 0x3333333338e38e38ULL, }, 91*fc76f486SAleksandar Markovic { 0x333333331c71c71cULL, 0x33333333c71c71c7ULL, }, 92*fc76f486SAleksandar Markovic { 0xe38e38e3ffffffffULL, 0x38e38e38ffffffffULL, }, /* 48 */ 93*fc76f486SAleksandar Markovic { 0xe38e38e300000000ULL, 0x38e38e3800000000ULL, }, 94*fc76f486SAleksandar Markovic { 0xe38e38e3aaaaaaaaULL, 0x38e38e38aaaaaaaaULL, }, 95*fc76f486SAleksandar Markovic { 0xe38e38e355555555ULL, 0x38e38e3855555555ULL, }, 96*fc76f486SAleksandar Markovic { 0xe38e38e3ccccccccULL, 0x38e38e38ccccccccULL, }, 97*fc76f486SAleksandar Markovic { 0xe38e38e333333333ULL, 0x38e38e3833333333ULL, }, 98*fc76f486SAleksandar Markovic { 0xe38e38e3e38e38e3ULL, 0x38e38e3838e38e38ULL, }, 99*fc76f486SAleksandar Markovic { 0xe38e38e31c71c71cULL, 0x38e38e38c71c71c7ULL, }, 100*fc76f486SAleksandar Markovic { 0x1c71c71cffffffffULL, 0xc71c71c7ffffffffULL, }, /* 56 */ 101*fc76f486SAleksandar Markovic { 0x1c71c71c00000000ULL, 0xc71c71c700000000ULL, }, 102*fc76f486SAleksandar Markovic { 0x1c71c71caaaaaaaaULL, 0xc71c71c7aaaaaaaaULL, }, 103*fc76f486SAleksandar Markovic { 0x1c71c71c55555555ULL, 0xc71c71c755555555ULL, }, 104*fc76f486SAleksandar Markovic { 0x1c71c71cccccccccULL, 0xc71c71c7ccccccccULL, }, 105*fc76f486SAleksandar Markovic { 0x1c71c71c33333333ULL, 0xc71c71c733333333ULL, }, 106*fc76f486SAleksandar Markovic { 0x1c71c71ce38e38e3ULL, 0xc71c71c738e38e38ULL, }, 107*fc76f486SAleksandar Markovic { 0x1c71c71c1c71c71cULL, 0xc71c71c7c71c71c7ULL, }, 108*fc76f486SAleksandar Markovic { 0xfe7bb00cfe7bb00cULL, 0x4b670b5e4b670b5eULL, }, /* 64 */ 109*fc76f486SAleksandar Markovic { 0xfe7bb00c153f52fcULL, 0x4b670b5e12f7bb1aULL, }, 110*fc76f486SAleksandar Markovic { 0xfe7bb00cab2b2514ULL, 0x4b670b5e27d8c6ffULL, }, 111*fc76f486SAleksandar Markovic { 0xfe7bb00ca942e2a0ULL, 0x4b670b5e8df188d8ULL, }, 112*fc76f486SAleksandar Markovic { 0x153f52fcfe7bb00cULL, 0x12f7bb1a4b670b5eULL, }, 113*fc76f486SAleksandar Markovic { 0x153f52fc153f52fcULL, 0x12f7bb1a12f7bb1aULL, }, 114*fc76f486SAleksandar Markovic { 0x153f52fcab2b2514ULL, 0x12f7bb1a27d8c6ffULL, }, 115*fc76f486SAleksandar Markovic { 0x153f52fca942e2a0ULL, 0x12f7bb1a8df188d8ULL, }, 116*fc76f486SAleksandar Markovic { 0xab2b2514fe7bb00cULL, 0x27d8c6ff4b670b5eULL, }, /* 72 */ 117*fc76f486SAleksandar Markovic { 0xab2b2514153f52fcULL, 0x27d8c6ff12f7bb1aULL, }, 118*fc76f486SAleksandar Markovic { 0xab2b2514ab2b2514ULL, 0x27d8c6ff27d8c6ffULL, }, 119*fc76f486SAleksandar Markovic { 0xab2b2514a942e2a0ULL, 0x27d8c6ff8df188d8ULL, }, 120*fc76f486SAleksandar Markovic { 0xa942e2a0fe7bb00cULL, 0x8df188d84b670b5eULL, }, 121*fc76f486SAleksandar Markovic { 0xa942e2a0153f52fcULL, 0x8df188d812f7bb1aULL, }, 122*fc76f486SAleksandar Markovic { 0xa942e2a0ab2b2514ULL, 0x8df188d827d8c6ffULL, }, 123*fc76f486SAleksandar Markovic { 0xa942e2a0a942e2a0ULL, 0x8df188d88df188d8ULL, }, 124*fc76f486SAleksandar Markovic }; 125*fc76f486SAleksandar Markovic 126*fc76f486SAleksandar Markovic gettimeofday(&start, NULL); 127*fc76f486SAleksandar Markovic 128*fc76f486SAleksandar Markovic for (i = 0; i < PATTERN_INPUTS_SHORT_COUNT; i++) { 129*fc76f486SAleksandar Markovic for (j = 0; j < PATTERN_INPUTS_SHORT_COUNT; j++) { 130*fc76f486SAleksandar Markovic do_msa_ILVL_W(b128_pattern[i], b128_pattern[j], 131*fc76f486SAleksandar Markovic b128_result[PATTERN_INPUTS_SHORT_COUNT * i + j]); 132*fc76f486SAleksandar Markovic } 133*fc76f486SAleksandar Markovic } 134*fc76f486SAleksandar Markovic 135*fc76f486SAleksandar Markovic for (i = 0; i < RANDOM_INPUTS_SHORT_COUNT; i++) { 136*fc76f486SAleksandar Markovic for (j = 0; j < RANDOM_INPUTS_SHORT_COUNT; j++) { 137*fc76f486SAleksandar Markovic do_msa_ILVL_W(b128_random[i], b128_random[j], 138*fc76f486SAleksandar Markovic b128_result[((PATTERN_INPUTS_SHORT_COUNT) * 139*fc76f486SAleksandar Markovic (PATTERN_INPUTS_SHORT_COUNT)) + 140*fc76f486SAleksandar Markovic RANDOM_INPUTS_SHORT_COUNT * i + j]); 141*fc76f486SAleksandar Markovic } 142*fc76f486SAleksandar Markovic } 143*fc76f486SAleksandar Markovic 144*fc76f486SAleksandar Markovic gettimeofday(&end, NULL); 145*fc76f486SAleksandar Markovic 146*fc76f486SAleksandar Markovic elapsed_time = (end.tv_sec - start.tv_sec) * 1000.0; 147*fc76f486SAleksandar Markovic elapsed_time += (end.tv_usec - start.tv_usec) / 1000.0; 148*fc76f486SAleksandar Markovic 149*fc76f486SAleksandar Markovic ret = check_results(instruction_name, TEST_COUNT_TOTAL, elapsed_time, 150*fc76f486SAleksandar Markovic &b128_result[0][0], &b128_expect[0][0]); 151*fc76f486SAleksandar Markovic 152*fc76f486SAleksandar Markovic return ret; 153*fc76f486SAleksandar Markovic } 154