1fc76f486SAleksandar Markovic /* 2fc76f486SAleksandar Markovic * Test program for MSA instruction ILVL.W 3fc76f486SAleksandar Markovic * 4dd8d6a2dSAleksandar Markovic * Copyright (C) 2019 Wave Computing, Inc. 5dd8d6a2dSAleksandar 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" 26*81526dffSAleksandar Markovic #include "../../../../include/test_inputs_128.h" 27*81526dffSAleksandar Markovic #include "../../../../include/test_utils_128.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 = "ILVL.W"; 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 { 0xffffffff00000000ULL, 0xffffffff00000000ULL, }, 46fc76f486SAleksandar Markovic { 0xffffffffaaaaaaaaULL, 0xffffffffaaaaaaaaULL, }, 47fc76f486SAleksandar Markovic { 0xffffffff55555555ULL, 0xffffffff55555555ULL, }, 48fc76f486SAleksandar Markovic { 0xffffffffccccccccULL, 0xffffffffccccccccULL, }, 49fc76f486SAleksandar Markovic { 0xffffffff33333333ULL, 0xffffffff33333333ULL, }, 50fc76f486SAleksandar Markovic { 0xffffffffe38e38e3ULL, 0xffffffff38e38e38ULL, }, 51fc76f486SAleksandar Markovic { 0xffffffff1c71c71cULL, 0xffffffffc71c71c7ULL, }, 52fc76f486SAleksandar Markovic { 0x00000000ffffffffULL, 0x00000000ffffffffULL, }, /* 8 */ 53fc76f486SAleksandar Markovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, 54fc76f486SAleksandar Markovic { 0x00000000aaaaaaaaULL, 0x00000000aaaaaaaaULL, }, 55fc76f486SAleksandar Markovic { 0x0000000055555555ULL, 0x0000000055555555ULL, }, 56fc76f486SAleksandar Markovic { 0x00000000ccccccccULL, 0x00000000ccccccccULL, }, 57fc76f486SAleksandar Markovic { 0x0000000033333333ULL, 0x0000000033333333ULL, }, 58fc76f486SAleksandar Markovic { 0x00000000e38e38e3ULL, 0x0000000038e38e38ULL, }, 59fc76f486SAleksandar Markovic { 0x000000001c71c71cULL, 0x00000000c71c71c7ULL, }, 60fc76f486SAleksandar Markovic { 0xaaaaaaaaffffffffULL, 0xaaaaaaaaffffffffULL, }, /* 16 */ 61fc76f486SAleksandar Markovic { 0xaaaaaaaa00000000ULL, 0xaaaaaaaa00000000ULL, }, 62fc76f486SAleksandar Markovic { 0xaaaaaaaaaaaaaaaaULL, 0xaaaaaaaaaaaaaaaaULL, }, 63fc76f486SAleksandar Markovic { 0xaaaaaaaa55555555ULL, 0xaaaaaaaa55555555ULL, }, 64fc76f486SAleksandar Markovic { 0xaaaaaaaaccccccccULL, 0xaaaaaaaaccccccccULL, }, 65fc76f486SAleksandar Markovic { 0xaaaaaaaa33333333ULL, 0xaaaaaaaa33333333ULL, }, 66fc76f486SAleksandar Markovic { 0xaaaaaaaae38e38e3ULL, 0xaaaaaaaa38e38e38ULL, }, 67fc76f486SAleksandar Markovic { 0xaaaaaaaa1c71c71cULL, 0xaaaaaaaac71c71c7ULL, }, 68fc76f486SAleksandar Markovic { 0x55555555ffffffffULL, 0x55555555ffffffffULL, }, /* 24 */ 69fc76f486SAleksandar Markovic { 0x5555555500000000ULL, 0x5555555500000000ULL, }, 70fc76f486SAleksandar Markovic { 0x55555555aaaaaaaaULL, 0x55555555aaaaaaaaULL, }, 71fc76f486SAleksandar Markovic { 0x5555555555555555ULL, 0x5555555555555555ULL, }, 72fc76f486SAleksandar Markovic { 0x55555555ccccccccULL, 0x55555555ccccccccULL, }, 73fc76f486SAleksandar Markovic { 0x5555555533333333ULL, 0x5555555533333333ULL, }, 74fc76f486SAleksandar Markovic { 0x55555555e38e38e3ULL, 0x5555555538e38e38ULL, }, 75fc76f486SAleksandar Markovic { 0x555555551c71c71cULL, 0x55555555c71c71c7ULL, }, 76fc76f486SAleksandar Markovic { 0xccccccccffffffffULL, 0xccccccccffffffffULL, }, /* 32 */ 77fc76f486SAleksandar Markovic { 0xcccccccc00000000ULL, 0xcccccccc00000000ULL, }, 78fc76f486SAleksandar Markovic { 0xccccccccaaaaaaaaULL, 0xccccccccaaaaaaaaULL, }, 79fc76f486SAleksandar Markovic { 0xcccccccc55555555ULL, 0xcccccccc55555555ULL, }, 80fc76f486SAleksandar Markovic { 0xccccccccccccccccULL, 0xccccccccccccccccULL, }, 81fc76f486SAleksandar Markovic { 0xcccccccc33333333ULL, 0xcccccccc33333333ULL, }, 82fc76f486SAleksandar Markovic { 0xcccccccce38e38e3ULL, 0xcccccccc38e38e38ULL, }, 83fc76f486SAleksandar Markovic { 0xcccccccc1c71c71cULL, 0xccccccccc71c71c7ULL, }, 84fc76f486SAleksandar Markovic { 0x33333333ffffffffULL, 0x33333333ffffffffULL, }, /* 40 */ 85fc76f486SAleksandar Markovic { 0x3333333300000000ULL, 0x3333333300000000ULL, }, 86fc76f486SAleksandar Markovic { 0x33333333aaaaaaaaULL, 0x33333333aaaaaaaaULL, }, 87fc76f486SAleksandar Markovic { 0x3333333355555555ULL, 0x3333333355555555ULL, }, 88fc76f486SAleksandar Markovic { 0x33333333ccccccccULL, 0x33333333ccccccccULL, }, 89fc76f486SAleksandar Markovic { 0x3333333333333333ULL, 0x3333333333333333ULL, }, 90fc76f486SAleksandar Markovic { 0x33333333e38e38e3ULL, 0x3333333338e38e38ULL, }, 91fc76f486SAleksandar Markovic { 0x333333331c71c71cULL, 0x33333333c71c71c7ULL, }, 92fc76f486SAleksandar Markovic { 0xe38e38e3ffffffffULL, 0x38e38e38ffffffffULL, }, /* 48 */ 93fc76f486SAleksandar Markovic { 0xe38e38e300000000ULL, 0x38e38e3800000000ULL, }, 94fc76f486SAleksandar Markovic { 0xe38e38e3aaaaaaaaULL, 0x38e38e38aaaaaaaaULL, }, 95fc76f486SAleksandar Markovic { 0xe38e38e355555555ULL, 0x38e38e3855555555ULL, }, 96fc76f486SAleksandar Markovic { 0xe38e38e3ccccccccULL, 0x38e38e38ccccccccULL, }, 97fc76f486SAleksandar Markovic { 0xe38e38e333333333ULL, 0x38e38e3833333333ULL, }, 98fc76f486SAleksandar Markovic { 0xe38e38e3e38e38e3ULL, 0x38e38e3838e38e38ULL, }, 99fc76f486SAleksandar Markovic { 0xe38e38e31c71c71cULL, 0x38e38e38c71c71c7ULL, }, 100fc76f486SAleksandar Markovic { 0x1c71c71cffffffffULL, 0xc71c71c7ffffffffULL, }, /* 56 */ 101fc76f486SAleksandar Markovic { 0x1c71c71c00000000ULL, 0xc71c71c700000000ULL, }, 102fc76f486SAleksandar Markovic { 0x1c71c71caaaaaaaaULL, 0xc71c71c7aaaaaaaaULL, }, 103fc76f486SAleksandar Markovic { 0x1c71c71c55555555ULL, 0xc71c71c755555555ULL, }, 104fc76f486SAleksandar Markovic { 0x1c71c71cccccccccULL, 0xc71c71c7ccccccccULL, }, 105fc76f486SAleksandar Markovic { 0x1c71c71c33333333ULL, 0xc71c71c733333333ULL, }, 106fc76f486SAleksandar Markovic { 0x1c71c71ce38e38e3ULL, 0xc71c71c738e38e38ULL, }, 107fc76f486SAleksandar Markovic { 0x1c71c71c1c71c71cULL, 0xc71c71c7c71c71c7ULL, }, 108fc76f486SAleksandar Markovic { 0xfe7bb00cfe7bb00cULL, 0x4b670b5e4b670b5eULL, }, /* 64 */ 109fc76f486SAleksandar Markovic { 0xfe7bb00c153f52fcULL, 0x4b670b5e12f7bb1aULL, }, 110fc76f486SAleksandar Markovic { 0xfe7bb00cab2b2514ULL, 0x4b670b5e27d8c6ffULL, }, 111fc76f486SAleksandar Markovic { 0xfe7bb00ca942e2a0ULL, 0x4b670b5e8df188d8ULL, }, 112fc76f486SAleksandar Markovic { 0x153f52fcfe7bb00cULL, 0x12f7bb1a4b670b5eULL, }, 113fc76f486SAleksandar Markovic { 0x153f52fc153f52fcULL, 0x12f7bb1a12f7bb1aULL, }, 114fc76f486SAleksandar Markovic { 0x153f52fcab2b2514ULL, 0x12f7bb1a27d8c6ffULL, }, 115fc76f486SAleksandar Markovic { 0x153f52fca942e2a0ULL, 0x12f7bb1a8df188d8ULL, }, 116fc76f486SAleksandar Markovic { 0xab2b2514fe7bb00cULL, 0x27d8c6ff4b670b5eULL, }, /* 72 */ 117fc76f486SAleksandar Markovic { 0xab2b2514153f52fcULL, 0x27d8c6ff12f7bb1aULL, }, 118fc76f486SAleksandar Markovic { 0xab2b2514ab2b2514ULL, 0x27d8c6ff27d8c6ffULL, }, 119fc76f486SAleksandar Markovic { 0xab2b2514a942e2a0ULL, 0x27d8c6ff8df188d8ULL, }, 120fc76f486SAleksandar Markovic { 0xa942e2a0fe7bb00cULL, 0x8df188d84b670b5eULL, }, 121fc76f486SAleksandar Markovic { 0xa942e2a0153f52fcULL, 0x8df188d812f7bb1aULL, }, 122fc76f486SAleksandar Markovic { 0xa942e2a0ab2b2514ULL, 0x8df188d827d8c6ffULL, }, 123fc76f486SAleksandar Markovic { 0xa942e2a0a942e2a0ULL, 0x8df188d88df188d8ULL, }, 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_ILVL_W(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_ILVL_W(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