1*fc76f486SAleksandar Markovic /* 2*fc76f486SAleksandar Markovic * Test program for MSA instruction ILVEV.B 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 = "*ILVEV.B"; 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 { 0xff00ff00ff00ff00ULL, 0xff00ff00ff00ff00ULL, }, 46*fc76f486SAleksandar Markovic { 0xffaaffaaffaaffaaULL, 0xffaaffaaffaaffaaULL, }, 47*fc76f486SAleksandar Markovic { 0xff55ff55ff55ff55ULL, 0xff55ff55ff55ff55ULL, }, 48*fc76f486SAleksandar Markovic { 0xffccffccffccffccULL, 0xffccffccffccffccULL, }, 49*fc76f486SAleksandar Markovic { 0xff33ff33ff33ff33ULL, 0xff33ff33ff33ff33ULL, }, 50*fc76f486SAleksandar Markovic { 0xff8effe3ff38ff8eULL, 0xffe3ff38ff8effe3ULL, }, 51*fc76f486SAleksandar Markovic { 0xff71ff1cffc7ff71ULL, 0xff1cffc7ff71ff1cULL, }, 52*fc76f486SAleksandar Markovic { 0x00ff00ff00ff00ffULL, 0x00ff00ff00ff00ffULL, }, /* 8 */ 53*fc76f486SAleksandar Markovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, 54*fc76f486SAleksandar Markovic { 0x00aa00aa00aa00aaULL, 0x00aa00aa00aa00aaULL, }, 55*fc76f486SAleksandar Markovic { 0x0055005500550055ULL, 0x0055005500550055ULL, }, 56*fc76f486SAleksandar Markovic { 0x00cc00cc00cc00ccULL, 0x00cc00cc00cc00ccULL, }, 57*fc76f486SAleksandar Markovic { 0x0033003300330033ULL, 0x0033003300330033ULL, }, 58*fc76f486SAleksandar Markovic { 0x008e00e30038008eULL, 0x00e30038008e00e3ULL, }, 59*fc76f486SAleksandar Markovic { 0x0071001c00c70071ULL, 0x001c00c70071001cULL, }, 60*fc76f486SAleksandar Markovic { 0xaaffaaffaaffaaffULL, 0xaaffaaffaaffaaffULL, }, /* 16 */ 61*fc76f486SAleksandar Markovic { 0xaa00aa00aa00aa00ULL, 0xaa00aa00aa00aa00ULL, }, 62*fc76f486SAleksandar Markovic { 0xaaaaaaaaaaaaaaaaULL, 0xaaaaaaaaaaaaaaaaULL, }, 63*fc76f486SAleksandar Markovic { 0xaa55aa55aa55aa55ULL, 0xaa55aa55aa55aa55ULL, }, 64*fc76f486SAleksandar Markovic { 0xaaccaaccaaccaaccULL, 0xaaccaaccaaccaaccULL, }, 65*fc76f486SAleksandar Markovic { 0xaa33aa33aa33aa33ULL, 0xaa33aa33aa33aa33ULL, }, 66*fc76f486SAleksandar Markovic { 0xaa8eaae3aa38aa8eULL, 0xaae3aa38aa8eaae3ULL, }, 67*fc76f486SAleksandar Markovic { 0xaa71aa1caac7aa71ULL, 0xaa1caac7aa71aa1cULL, }, 68*fc76f486SAleksandar Markovic { 0x55ff55ff55ff55ffULL, 0x55ff55ff55ff55ffULL, }, /* 24 */ 69*fc76f486SAleksandar Markovic { 0x5500550055005500ULL, 0x5500550055005500ULL, }, 70*fc76f486SAleksandar Markovic { 0x55aa55aa55aa55aaULL, 0x55aa55aa55aa55aaULL, }, 71*fc76f486SAleksandar Markovic { 0x5555555555555555ULL, 0x5555555555555555ULL, }, 72*fc76f486SAleksandar Markovic { 0x55cc55cc55cc55ccULL, 0x55cc55cc55cc55ccULL, }, 73*fc76f486SAleksandar Markovic { 0x5533553355335533ULL, 0x5533553355335533ULL, }, 74*fc76f486SAleksandar Markovic { 0x558e55e35538558eULL, 0x55e35538558e55e3ULL, }, 75*fc76f486SAleksandar Markovic { 0x5571551c55c75571ULL, 0x551c55c75571551cULL, }, 76*fc76f486SAleksandar Markovic { 0xccffccffccffccffULL, 0xccffccffccffccffULL, }, /* 32 */ 77*fc76f486SAleksandar Markovic { 0xcc00cc00cc00cc00ULL, 0xcc00cc00cc00cc00ULL, }, 78*fc76f486SAleksandar Markovic { 0xccaaccaaccaaccaaULL, 0xccaaccaaccaaccaaULL, }, 79*fc76f486SAleksandar Markovic { 0xcc55cc55cc55cc55ULL, 0xcc55cc55cc55cc55ULL, }, 80*fc76f486SAleksandar Markovic { 0xccccccccccccccccULL, 0xccccccccccccccccULL, }, 81*fc76f486SAleksandar Markovic { 0xcc33cc33cc33cc33ULL, 0xcc33cc33cc33cc33ULL, }, 82*fc76f486SAleksandar Markovic { 0xcc8ecce3cc38cc8eULL, 0xcce3cc38cc8ecce3ULL, }, 83*fc76f486SAleksandar Markovic { 0xcc71cc1cccc7cc71ULL, 0xcc1cccc7cc71cc1cULL, }, 84*fc76f486SAleksandar Markovic { 0x33ff33ff33ff33ffULL, 0x33ff33ff33ff33ffULL, }, /* 40 */ 85*fc76f486SAleksandar Markovic { 0x3300330033003300ULL, 0x3300330033003300ULL, }, 86*fc76f486SAleksandar Markovic { 0x33aa33aa33aa33aaULL, 0x33aa33aa33aa33aaULL, }, 87*fc76f486SAleksandar Markovic { 0x3355335533553355ULL, 0x3355335533553355ULL, }, 88*fc76f486SAleksandar Markovic { 0x33cc33cc33cc33ccULL, 0x33cc33cc33cc33ccULL, }, 89*fc76f486SAleksandar Markovic { 0x3333333333333333ULL, 0x3333333333333333ULL, }, 90*fc76f486SAleksandar Markovic { 0x338e33e33338338eULL, 0x33e33338338e33e3ULL, }, 91*fc76f486SAleksandar Markovic { 0x3371331c33c73371ULL, 0x331c33c73371331cULL, }, 92*fc76f486SAleksandar Markovic { 0x8effe3ff38ff8effULL, 0xe3ff38ff8effe3ffULL, }, /* 48 */ 93*fc76f486SAleksandar Markovic { 0x8e00e30038008e00ULL, 0xe30038008e00e300ULL, }, 94*fc76f486SAleksandar Markovic { 0x8eaae3aa38aa8eaaULL, 0xe3aa38aa8eaae3aaULL, }, 95*fc76f486SAleksandar Markovic { 0x8e55e35538558e55ULL, 0xe35538558e55e355ULL, }, 96*fc76f486SAleksandar Markovic { 0x8ecce3cc38cc8eccULL, 0xe3cc38cc8ecce3ccULL, }, 97*fc76f486SAleksandar Markovic { 0x8e33e33338338e33ULL, 0xe33338338e33e333ULL, }, 98*fc76f486SAleksandar Markovic { 0x8e8ee3e338388e8eULL, 0xe3e338388e8ee3e3ULL, }, 99*fc76f486SAleksandar Markovic { 0x8e71e31c38c78e71ULL, 0xe31c38c78e71e31cULL, }, 100*fc76f486SAleksandar Markovic { 0x71ff1cffc7ff71ffULL, 0x1cffc7ff71ff1cffULL, }, /* 56 */ 101*fc76f486SAleksandar Markovic { 0x71001c00c7007100ULL, 0x1c00c70071001c00ULL, }, 102*fc76f486SAleksandar Markovic { 0x71aa1caac7aa71aaULL, 0x1caac7aa71aa1caaULL, }, 103*fc76f486SAleksandar Markovic { 0x71551c55c7557155ULL, 0x1c55c75571551c55ULL, }, 104*fc76f486SAleksandar Markovic { 0x71cc1cccc7cc71ccULL, 0x1cccc7cc71cc1cccULL, }, 105*fc76f486SAleksandar Markovic { 0x71331c33c7337133ULL, 0x1c33c73371331c33ULL, }, 106*fc76f486SAleksandar Markovic { 0x718e1ce3c738718eULL, 0x1ce3c738718e1ce3ULL, }, 107*fc76f486SAleksandar Markovic { 0x71711c1cc7c77171ULL, 0x1c1cc7c771711c1cULL, }, 108*fc76f486SAleksandar Markovic { 0x6a6acccc62624040ULL, 0x67675e5e7b7b0c0cULL, }, /* 64 */ 109*fc76f486SAleksandar Markovic { 0x6abecc6362934008ULL, 0x67f75e1a7b3f0cfcULL, }, 110*fc76f486SAleksandar Markovic { 0x6a5accaa62cf4080ULL, 0x67d85eff7b2b0c14ULL, }, 111*fc76f486SAleksandar Markovic { 0x6a4fcc4d6231404eULL, 0x67f15ed87b420ca0ULL, }, 112*fc76f486SAleksandar Markovic { 0xbe6a63cc93620840ULL, 0xf7671a5e3f7bfc0cULL, }, 113*fc76f486SAleksandar Markovic { 0xbebe636393930808ULL, 0xf7f71a1a3f3ffcfcULL, }, 114*fc76f486SAleksandar Markovic { 0xbe5a63aa93cf0880ULL, 0xf7d81aff3f2bfc14ULL, }, 115*fc76f486SAleksandar Markovic { 0xbe4f634d9331084eULL, 0xf7f11ad83f42fca0ULL, }, 116*fc76f486SAleksandar Markovic { 0x5a6aaacccf628040ULL, 0xd867ff5e2b7b140cULL, }, /* 72 */ 117*fc76f486SAleksandar Markovic { 0x5abeaa63cf938008ULL, 0xd8f7ff1a2b3f14fcULL, }, 118*fc76f486SAleksandar Markovic { 0x5a5aaaaacfcf8080ULL, 0xd8d8ffff2b2b1414ULL, }, 119*fc76f486SAleksandar Markovic { 0x5a4faa4dcf31804eULL, 0xd8f1ffd82b4214a0ULL, }, 120*fc76f486SAleksandar Markovic { 0x4f6a4dcc31624e40ULL, 0xf167d85e427ba00cULL, }, 121*fc76f486SAleksandar Markovic { 0x4fbe4d6331934e08ULL, 0xf1f7d81a423fa0fcULL, }, 122*fc76f486SAleksandar Markovic { 0x4f5a4daa31cf4e80ULL, 0xf1d8d8ff422ba014ULL, }, 123*fc76f486SAleksandar Markovic { 0x4f4f4d4d31314e4eULL, 0xf1f1d8d84242a0a0ULL, }, 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_ILVEV_B(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_ILVEV_B(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