1fc76f486SAleksandar Markovic /* 2fc76f486SAleksandar Markovic * Test program for MSA instruction ILVR.H 3fc76f486SAleksandar Markovic * 4*dd8d6a2dSAleksandar Markovic * Copyright (C) 2019 Wave Computing, Inc. 5*dd8d6a2dSAleksandar Markovic * Copyright (C) 2019 Aleksandar Markovic <amarkovic@wavecomp.com> 6fc76f486SAleksandar Markovic * 7fc76f486SAleksandar Markovic * This program is free software: you can redistribute it and/or modify 8fc76f486SAleksandar Markovic * it under the terms of the GNU General Public License as published by 9fc76f486SAleksandar Markovic * the Free Software Foundation, either version 2 of the License, or 10fc76f486SAleksandar Markovic * (at your option) any later version. 11fc76f486SAleksandar Markovic * 12fc76f486SAleksandar Markovic * This program is distributed in the hope that it will be useful, 13fc76f486SAleksandar Markovic * but WITHOUT ANY WARRANTY; without even the implied warranty of 14fc76f486SAleksandar Markovic * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15fc76f486SAleksandar Markovic * GNU General Public License for more details. 16fc76f486SAleksandar Markovic * 17fc76f486SAleksandar Markovic * You should have received a copy of the GNU General Public License 18fc76f486SAleksandar Markovic * along with this program. If not, see <https://www.gnu.org/licenses/>. 19fc76f486SAleksandar Markovic * 20fc76f486SAleksandar Markovic */ 21fc76f486SAleksandar Markovic 22fc76f486SAleksandar Markovic #include <sys/time.h> 23fc76f486SAleksandar Markovic #include <stdint.h> 24fc76f486SAleksandar Markovic 25fc76f486SAleksandar Markovic #include "../../../../include/wrappers_msa.h" 26fc76f486SAleksandar Markovic #include "../../../../include/test_inputs.h" 27fc76f486SAleksandar Markovic #include "../../../../include/test_utils.h" 28fc76f486SAleksandar Markovic 29fc76f486SAleksandar Markovic #define TEST_COUNT_TOTAL ( \ 30fc76f486SAleksandar Markovic (PATTERN_INPUTS_SHORT_COUNT) * (PATTERN_INPUTS_SHORT_COUNT) + \ 31fc76f486SAleksandar Markovic (RANDOM_INPUTS_SHORT_COUNT) * (RANDOM_INPUTS_SHORT_COUNT)) 32fc76f486SAleksandar Markovic 33fc76f486SAleksandar Markovic 34fc76f486SAleksandar Markovic int32_t main(void) 35fc76f486SAleksandar Markovic { 36fc76f486SAleksandar Markovic char *instruction_name = "ILVR.H"; 37fc76f486SAleksandar Markovic int32_t ret; 38fc76f486SAleksandar Markovic uint32_t i, j; 39fc76f486SAleksandar Markovic struct timeval start, end; 40fc76f486SAleksandar Markovic double elapsed_time; 41fc76f486SAleksandar Markovic 42fc76f486SAleksandar Markovic uint64_t b128_result[TEST_COUNT_TOTAL][2]; 43fc76f486SAleksandar Markovic uint64_t b128_expect[TEST_COUNT_TOTAL][2] = { 44fc76f486SAleksandar Markovic { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, /* 0 */ 45fc76f486SAleksandar Markovic { 0xffff0000ffff0000ULL, 0xffff0000ffff0000ULL, }, 46fc76f486SAleksandar Markovic { 0xffffaaaaffffaaaaULL, 0xffffaaaaffffaaaaULL, }, 47fc76f486SAleksandar Markovic { 0xffff5555ffff5555ULL, 0xffff5555ffff5555ULL, }, 48fc76f486SAleksandar Markovic { 0xffffccccffffccccULL, 0xffffccccffffccccULL, }, 49fc76f486SAleksandar Markovic { 0xffff3333ffff3333ULL, 0xffff3333ffff3333ULL, }, 50fc76f486SAleksandar Markovic { 0xffff8e38ffffe38eULL, 0xffffe38effff38e3ULL, }, 51fc76f486SAleksandar Markovic { 0xffff71c7ffff1c71ULL, 0xffff1c71ffffc71cULL, }, 52fc76f486SAleksandar Markovic { 0x0000ffff0000ffffULL, 0x0000ffff0000ffffULL, }, /* 8 */ 53fc76f486SAleksandar Markovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, 54fc76f486SAleksandar Markovic { 0x0000aaaa0000aaaaULL, 0x0000aaaa0000aaaaULL, }, 55fc76f486SAleksandar Markovic { 0x0000555500005555ULL, 0x0000555500005555ULL, }, 56fc76f486SAleksandar Markovic { 0x0000cccc0000ccccULL, 0x0000cccc0000ccccULL, }, 57fc76f486SAleksandar Markovic { 0x0000333300003333ULL, 0x0000333300003333ULL, }, 58fc76f486SAleksandar Markovic { 0x00008e380000e38eULL, 0x0000e38e000038e3ULL, }, 59fc76f486SAleksandar Markovic { 0x000071c700001c71ULL, 0x00001c710000c71cULL, }, 60fc76f486SAleksandar Markovic { 0xaaaaffffaaaaffffULL, 0xaaaaffffaaaaffffULL, }, /* 16 */ 61fc76f486SAleksandar Markovic { 0xaaaa0000aaaa0000ULL, 0xaaaa0000aaaa0000ULL, }, 62fc76f486SAleksandar Markovic { 0xaaaaaaaaaaaaaaaaULL, 0xaaaaaaaaaaaaaaaaULL, }, 63fc76f486SAleksandar Markovic { 0xaaaa5555aaaa5555ULL, 0xaaaa5555aaaa5555ULL, }, 64fc76f486SAleksandar Markovic { 0xaaaaccccaaaaccccULL, 0xaaaaccccaaaaccccULL, }, 65fc76f486SAleksandar Markovic { 0xaaaa3333aaaa3333ULL, 0xaaaa3333aaaa3333ULL, }, 66fc76f486SAleksandar Markovic { 0xaaaa8e38aaaae38eULL, 0xaaaae38eaaaa38e3ULL, }, 67fc76f486SAleksandar Markovic { 0xaaaa71c7aaaa1c71ULL, 0xaaaa1c71aaaac71cULL, }, 68fc76f486SAleksandar Markovic { 0x5555ffff5555ffffULL, 0x5555ffff5555ffffULL, }, /* 24 */ 69fc76f486SAleksandar Markovic { 0x5555000055550000ULL, 0x5555000055550000ULL, }, 70fc76f486SAleksandar Markovic { 0x5555aaaa5555aaaaULL, 0x5555aaaa5555aaaaULL, }, 71fc76f486SAleksandar Markovic { 0x5555555555555555ULL, 0x5555555555555555ULL, }, 72fc76f486SAleksandar Markovic { 0x5555cccc5555ccccULL, 0x5555cccc5555ccccULL, }, 73fc76f486SAleksandar Markovic { 0x5555333355553333ULL, 0x5555333355553333ULL, }, 74fc76f486SAleksandar Markovic { 0x55558e385555e38eULL, 0x5555e38e555538e3ULL, }, 75fc76f486SAleksandar Markovic { 0x555571c755551c71ULL, 0x55551c715555c71cULL, }, 76fc76f486SAleksandar Markovic { 0xccccffffccccffffULL, 0xccccffffccccffffULL, }, /* 32 */ 77fc76f486SAleksandar Markovic { 0xcccc0000cccc0000ULL, 0xcccc0000cccc0000ULL, }, 78fc76f486SAleksandar Markovic { 0xccccaaaaccccaaaaULL, 0xccccaaaaccccaaaaULL, }, 79fc76f486SAleksandar Markovic { 0xcccc5555cccc5555ULL, 0xcccc5555cccc5555ULL, }, 80fc76f486SAleksandar Markovic { 0xccccccccccccccccULL, 0xccccccccccccccccULL, }, 81fc76f486SAleksandar Markovic { 0xcccc3333cccc3333ULL, 0xcccc3333cccc3333ULL, }, 82fc76f486SAleksandar Markovic { 0xcccc8e38cccce38eULL, 0xcccce38ecccc38e3ULL, }, 83fc76f486SAleksandar Markovic { 0xcccc71c7cccc1c71ULL, 0xcccc1c71ccccc71cULL, }, 84fc76f486SAleksandar Markovic { 0x3333ffff3333ffffULL, 0x3333ffff3333ffffULL, }, /* 40 */ 85fc76f486SAleksandar Markovic { 0x3333000033330000ULL, 0x3333000033330000ULL, }, 86fc76f486SAleksandar Markovic { 0x3333aaaa3333aaaaULL, 0x3333aaaa3333aaaaULL, }, 87fc76f486SAleksandar Markovic { 0x3333555533335555ULL, 0x3333555533335555ULL, }, 88fc76f486SAleksandar Markovic { 0x3333cccc3333ccccULL, 0x3333cccc3333ccccULL, }, 89fc76f486SAleksandar Markovic { 0x3333333333333333ULL, 0x3333333333333333ULL, }, 90fc76f486SAleksandar Markovic { 0x33338e383333e38eULL, 0x3333e38e333338e3ULL, }, 91fc76f486SAleksandar Markovic { 0x333371c733331c71ULL, 0x33331c713333c71cULL, }, 92fc76f486SAleksandar Markovic { 0x8e38ffffe38effffULL, 0xe38effff38e3ffffULL, }, /* 48 */ 93fc76f486SAleksandar Markovic { 0x8e380000e38e0000ULL, 0xe38e000038e30000ULL, }, 94fc76f486SAleksandar Markovic { 0x8e38aaaae38eaaaaULL, 0xe38eaaaa38e3aaaaULL, }, 95fc76f486SAleksandar Markovic { 0x8e385555e38e5555ULL, 0xe38e555538e35555ULL, }, 96fc76f486SAleksandar Markovic { 0x8e38cccce38eccccULL, 0xe38ecccc38e3ccccULL, }, 97fc76f486SAleksandar Markovic { 0x8e383333e38e3333ULL, 0xe38e333338e33333ULL, }, 98fc76f486SAleksandar Markovic { 0x8e388e38e38ee38eULL, 0xe38ee38e38e338e3ULL, }, 99fc76f486SAleksandar Markovic { 0x8e3871c7e38e1c71ULL, 0xe38e1c7138e3c71cULL, }, 100fc76f486SAleksandar Markovic { 0x71c7ffff1c71ffffULL, 0x1c71ffffc71cffffULL, }, /* 56 */ 101fc76f486SAleksandar Markovic { 0x71c700001c710000ULL, 0x1c710000c71c0000ULL, }, 102fc76f486SAleksandar Markovic { 0x71c7aaaa1c71aaaaULL, 0x1c71aaaac71caaaaULL, }, 103fc76f486SAleksandar Markovic { 0x71c755551c715555ULL, 0x1c715555c71c5555ULL, }, 104fc76f486SAleksandar Markovic { 0x71c7cccc1c71ccccULL, 0x1c71ccccc71cccccULL, }, 105fc76f486SAleksandar Markovic { 0x71c733331c713333ULL, 0x1c713333c71c3333ULL, }, 106fc76f486SAleksandar Markovic { 0x71c78e381c71e38eULL, 0x1c71e38ec71c38e3ULL, }, 107fc76f486SAleksandar Markovic { 0x71c771c71c711c71ULL, 0x1c711c71c71cc71cULL, }, 108fc76f486SAleksandar Markovic { 0x2862286255405540ULL, 0x886a886ae6cce6ccULL, }, /* 64 */ 109fc76f486SAleksandar Markovic { 0x28624d935540c708ULL, 0x886afbbee6cc0063ULL, }, 110fc76f486SAleksandar Markovic { 0x2862b9cf55408b80ULL, 0x886aac5ae6ccaeaaULL, }, 111fc76f486SAleksandar Markovic { 0x28625e315540e24eULL, 0x886a704fe6cc164dULL, }, 112fc76f486SAleksandar Markovic { 0x4d932862c7085540ULL, 0xfbbe886a0063e6ccULL, }, 113fc76f486SAleksandar Markovic { 0x4d934d93c708c708ULL, 0xfbbefbbe00630063ULL, }, 114fc76f486SAleksandar Markovic { 0x4d93b9cfc7088b80ULL, 0xfbbeac5a0063aeaaULL, }, 115fc76f486SAleksandar Markovic { 0x4d935e31c708e24eULL, 0xfbbe704f0063164dULL, }, 116fc76f486SAleksandar Markovic { 0xb9cf28628b805540ULL, 0xac5a886aaeaae6ccULL, }, /* 72 */ 117fc76f486SAleksandar Markovic { 0xb9cf4d938b80c708ULL, 0xac5afbbeaeaa0063ULL, }, 118fc76f486SAleksandar Markovic { 0xb9cfb9cf8b808b80ULL, 0xac5aac5aaeaaaeaaULL, }, 119fc76f486SAleksandar Markovic { 0xb9cf5e318b80e24eULL, 0xac5a704faeaa164dULL, }, 120fc76f486SAleksandar Markovic { 0x5e312862e24e5540ULL, 0x704f886a164de6ccULL, }, 121fc76f486SAleksandar Markovic { 0x5e314d93e24ec708ULL, 0x704ffbbe164d0063ULL, }, 122fc76f486SAleksandar Markovic { 0x5e31b9cfe24e8b80ULL, 0x704fac5a164daeaaULL, }, 123fc76f486SAleksandar Markovic { 0x5e315e31e24ee24eULL, 0x704f704f164d164dULL, }, 124fc76f486SAleksandar Markovic }; 125fc76f486SAleksandar Markovic 126fc76f486SAleksandar Markovic gettimeofday(&start, NULL); 127fc76f486SAleksandar Markovic 128fc76f486SAleksandar Markovic for (i = 0; i < PATTERN_INPUTS_SHORT_COUNT; i++) { 129fc76f486SAleksandar Markovic for (j = 0; j < PATTERN_INPUTS_SHORT_COUNT; j++) { 130fc76f486SAleksandar Markovic do_msa_ILVR_H(b128_pattern[i], b128_pattern[j], 131fc76f486SAleksandar Markovic b128_result[PATTERN_INPUTS_SHORT_COUNT * i + j]); 132fc76f486SAleksandar Markovic } 133fc76f486SAleksandar Markovic } 134fc76f486SAleksandar Markovic 135fc76f486SAleksandar Markovic for (i = 0; i < RANDOM_INPUTS_SHORT_COUNT; i++) { 136fc76f486SAleksandar Markovic for (j = 0; j < RANDOM_INPUTS_SHORT_COUNT; j++) { 137fc76f486SAleksandar Markovic do_msa_ILVR_H(b128_random[i], b128_random[j], 138fc76f486SAleksandar Markovic b128_result[((PATTERN_INPUTS_SHORT_COUNT) * 139fc76f486SAleksandar Markovic (PATTERN_INPUTS_SHORT_COUNT)) + 140fc76f486SAleksandar Markovic RANDOM_INPUTS_SHORT_COUNT * i + j]); 141fc76f486SAleksandar Markovic } 142fc76f486SAleksandar Markovic } 143fc76f486SAleksandar Markovic 144fc76f486SAleksandar Markovic gettimeofday(&end, NULL); 145fc76f486SAleksandar Markovic 146fc76f486SAleksandar Markovic elapsed_time = (end.tv_sec - start.tv_sec) * 1000.0; 147fc76f486SAleksandar Markovic elapsed_time += (end.tv_usec - start.tv_usec) / 1000.0; 148fc76f486SAleksandar Markovic 149fc76f486SAleksandar Markovic ret = check_results(instruction_name, TEST_COUNT_TOTAL, elapsed_time, 150fc76f486SAleksandar Markovic &b128_result[0][0], &b128_expect[0][0]); 151fc76f486SAleksandar Markovic 152fc76f486SAleksandar Markovic return ret; 153fc76f486SAleksandar Markovic } 154