1*72f463bcSMateja Marjanovic /* 2*72f463bcSMateja Marjanovic * Test program for MSA instruction DIV_U.H 3*72f463bcSMateja Marjanovic * 4*72f463bcSMateja Marjanovic * Copyright (C) 2018 Wave Computing, Inc. 5*72f463bcSMateja Marjanovic * Copyright (C) 2018 Mateja Marjanovic <mateja.marjanovic@rt-rk.com> 6*72f463bcSMateja Marjanovic * 7*72f463bcSMateja Marjanovic * This program is free software: you can redistribute it and/or modify 8*72f463bcSMateja Marjanovic * it under the terms of the GNU General Public License as published by 9*72f463bcSMateja Marjanovic * the Free Software Foundation, either version 2 of the License, or 10*72f463bcSMateja Marjanovic * (at your option) any later version. 11*72f463bcSMateja Marjanovic * 12*72f463bcSMateja Marjanovic * This program is distributed in the hope that it will be useful, 13*72f463bcSMateja Marjanovic * but WITHOUT ANY WARRANTY; without even the implied warranty of 14*72f463bcSMateja Marjanovic * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15*72f463bcSMateja Marjanovic * GNU General Public License for more details. 16*72f463bcSMateja Marjanovic * 17*72f463bcSMateja Marjanovic * You should have received a copy of the GNU General Public License 18*72f463bcSMateja Marjanovic * along with this program. If not, see <https://www.gnu.org/licenses/>. 19*72f463bcSMateja Marjanovic * 20*72f463bcSMateja Marjanovic */ 21*72f463bcSMateja Marjanovic 22*72f463bcSMateja Marjanovic #include <sys/time.h> 23*72f463bcSMateja Marjanovic #include <stdint.h> 24*72f463bcSMateja Marjanovic 25*72f463bcSMateja Marjanovic #include "../../../../include/wrappers_msa.h" 26*72f463bcSMateja Marjanovic #include "../../../../include/test_inputs.h" 27*72f463bcSMateja Marjanovic #include "../../../../include/test_utils.h" 28*72f463bcSMateja Marjanovic 29*72f463bcSMateja Marjanovic #define TEST_COUNT_TOTAL ( \ 30*72f463bcSMateja Marjanovic (PATTERN_INPUTS_SHORT_COUNT) * (PATTERN_INPUTS_SHORT_COUNT) + \ 31*72f463bcSMateja Marjanovic (RANDOM_INPUTS_SHORT_COUNT) * (RANDOM_INPUTS_SHORT_COUNT)) 32*72f463bcSMateja Marjanovic 33*72f463bcSMateja Marjanovic 34*72f463bcSMateja Marjanovic int32_t main(void) 35*72f463bcSMateja Marjanovic { 36*72f463bcSMateja Marjanovic char *instruction_name = "DIV_U.H"; 37*72f463bcSMateja Marjanovic int32_t ret; 38*72f463bcSMateja Marjanovic uint32_t i, j; 39*72f463bcSMateja Marjanovic struct timeval start, end; 40*72f463bcSMateja Marjanovic double elapsed_time; 41*72f463bcSMateja Marjanovic 42*72f463bcSMateja Marjanovic uint64_t b128_result[TEST_COUNT_TOTAL][2]; 43*72f463bcSMateja Marjanovic uint64_t b128_expect[TEST_COUNT_TOTAL][2] = { 44*72f463bcSMateja Marjanovic { 0x0001000100010001ULL, 0x0001000100010001ULL, }, /* 0 */ 45*72f463bcSMateja Marjanovic { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, 46*72f463bcSMateja Marjanovic { 0x0001000100010001ULL, 0x0001000100010001ULL, }, 47*72f463bcSMateja Marjanovic { 0x0003000300030003ULL, 0x0003000300030003ULL, }, 48*72f463bcSMateja Marjanovic { 0x0001000100010001ULL, 0x0001000100010001ULL, }, 49*72f463bcSMateja Marjanovic { 0x0005000500050005ULL, 0x0005000500050005ULL, }, 50*72f463bcSMateja Marjanovic { 0x0001000400010001ULL, 0x0004000100010004ULL, }, 51*72f463bcSMateja Marjanovic { 0x0009000100020009ULL, 0x0001000200090001ULL, }, 52*72f463bcSMateja Marjanovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, /* 8 */ 53*72f463bcSMateja Marjanovic { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, 54*72f463bcSMateja Marjanovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, 55*72f463bcSMateja Marjanovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, 56*72f463bcSMateja Marjanovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, 57*72f463bcSMateja Marjanovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, 58*72f463bcSMateja Marjanovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, 59*72f463bcSMateja Marjanovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, 60*72f463bcSMateja Marjanovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, /* 16 */ 61*72f463bcSMateja Marjanovic { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, 62*72f463bcSMateja Marjanovic { 0x0001000100010001ULL, 0x0001000100010001ULL, }, 63*72f463bcSMateja Marjanovic { 0x0002000200020002ULL, 0x0002000200020002ULL, }, 64*72f463bcSMateja Marjanovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, 65*72f463bcSMateja Marjanovic { 0x0003000300030003ULL, 0x0003000300030003ULL, }, 66*72f463bcSMateja Marjanovic { 0x0000000300010000ULL, 0x0003000100000003ULL, }, 67*72f463bcSMateja Marjanovic { 0x0006000000010006ULL, 0x0000000100060000ULL, }, 68*72f463bcSMateja Marjanovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, /* 24 */ 69*72f463bcSMateja Marjanovic { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, 70*72f463bcSMateja Marjanovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, 71*72f463bcSMateja Marjanovic { 0x0001000100010001ULL, 0x0001000100010001ULL, }, 72*72f463bcSMateja Marjanovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, 73*72f463bcSMateja Marjanovic { 0x0001000100010001ULL, 0x0001000100010001ULL, }, 74*72f463bcSMateja Marjanovic { 0x0000000100000000ULL, 0x0001000000000001ULL, }, 75*72f463bcSMateja Marjanovic { 0x0003000000000003ULL, 0x0000000000030000ULL, }, 76*72f463bcSMateja Marjanovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, /* 32 */ 77*72f463bcSMateja Marjanovic { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, 78*72f463bcSMateja Marjanovic { 0x0001000100010001ULL, 0x0001000100010001ULL, }, 79*72f463bcSMateja Marjanovic { 0x0002000200020002ULL, 0x0002000200020002ULL, }, 80*72f463bcSMateja Marjanovic { 0x0001000100010001ULL, 0x0001000100010001ULL, }, 81*72f463bcSMateja Marjanovic { 0x0004000400040004ULL, 0x0004000400040004ULL, }, 82*72f463bcSMateja Marjanovic { 0x0000000300010000ULL, 0x0003000100000003ULL, }, 83*72f463bcSMateja Marjanovic { 0x0007000100010007ULL, 0x0001000100070001ULL, }, 84*72f463bcSMateja Marjanovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, /* 40 */ 85*72f463bcSMateja Marjanovic { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, 86*72f463bcSMateja Marjanovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, 87*72f463bcSMateja Marjanovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, 88*72f463bcSMateja Marjanovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, 89*72f463bcSMateja Marjanovic { 0x0001000100010001ULL, 0x0001000100010001ULL, }, 90*72f463bcSMateja Marjanovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, 91*72f463bcSMateja Marjanovic { 0x0001000000000001ULL, 0x0000000000010000ULL, }, 92*72f463bcSMateja Marjanovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, /* 48 */ 93*72f463bcSMateja Marjanovic { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, 94*72f463bcSMateja Marjanovic { 0x0001000000000001ULL, 0x0000000000010000ULL, }, 95*72f463bcSMateja Marjanovic { 0x0002000000010002ULL, 0x0000000100020000ULL, }, 96*72f463bcSMateja Marjanovic { 0x0001000000000001ULL, 0x0000000000010000ULL, }, 97*72f463bcSMateja Marjanovic { 0x0004000100020004ULL, 0x0001000200040001ULL, }, 98*72f463bcSMateja Marjanovic { 0x0001000100010001ULL, 0x0001000100010001ULL, }, 99*72f463bcSMateja Marjanovic { 0x0008000000010008ULL, 0x0000000100080000ULL, }, 100*72f463bcSMateja Marjanovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, /* 56 */ 101*72f463bcSMateja Marjanovic { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, 102*72f463bcSMateja Marjanovic { 0x0000000100000000ULL, 0x0001000000000001ULL, }, 103*72f463bcSMateja Marjanovic { 0x0000000200010000ULL, 0x0002000100000002ULL, }, 104*72f463bcSMateja Marjanovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, 105*72f463bcSMateja Marjanovic { 0x0000000300020000ULL, 0x0003000200000003ULL, }, 106*72f463bcSMateja Marjanovic { 0x0000000300000000ULL, 0x0003000000000003ULL, }, 107*72f463bcSMateja Marjanovic { 0x0001000100010001ULL, 0x0001000100010001ULL, }, 108*72f463bcSMateja Marjanovic { 0x0001000100010001ULL, 0x0001000100010001ULL, }, /* 64 */ 109*72f463bcSMateja Marjanovic { 0x0000025400000000ULL, 0x00030000000b0002ULL, }, 110*72f463bcSMateja Marjanovic { 0x0000000100000000ULL, 0x0001000000010004ULL, }, 111*72f463bcSMateja Marjanovic { 0x0001000a00000000ULL, 0x0000000000010000ULL, }, 112*72f463bcSMateja Marjanovic { 0x0001000000010002ULL, 0x0000001000000000ULL, }, 113*72f463bcSMateja Marjanovic { 0x0001000100010001ULL, 0x0001000100010001ULL, }, 114*72f463bcSMateja Marjanovic { 0x0001000000000001ULL, 0x0000000000000002ULL, }, 115*72f463bcSMateja Marjanovic { 0x0002000000000000ULL, 0x0000000100000000ULL, }, 116*72f463bcSMateja Marjanovic { 0x0001000000040001ULL, 0x0000001100000000ULL, }, /* 72 */ 117*72f463bcSMateja Marjanovic { 0x000001c300020000ULL, 0x0002000100080000ULL, }, 118*72f463bcSMateja Marjanovic { 0x0001000100010001ULL, 0x0001000100010001ULL, }, 119*72f463bcSMateja Marjanovic { 0x0001000700010000ULL, 0x0000000100010000ULL, }, 120*72f463bcSMateja Marjanovic { 0x0000000000020002ULL, 0x0001000c00000001ULL, }, 121*72f463bcSMateja Marjanovic { 0x0000003900010001ULL, 0x0007000000070002ULL, }, 122*72f463bcSMateja Marjanovic }; 123*72f463bcSMateja Marjanovic 124*72f463bcSMateja Marjanovic gettimeofday(&start, NULL); 125*72f463bcSMateja Marjanovic 126*72f463bcSMateja Marjanovic for (i = 0; i < PATTERN_INPUTS_SHORT_COUNT; i++) { 127*72f463bcSMateja Marjanovic for (j = 0; j < PATTERN_INPUTS_SHORT_COUNT; j++) { 128*72f463bcSMateja Marjanovic do_msa_DIV_U_H(b128_pattern[i], b128_pattern[j], 129*72f463bcSMateja Marjanovic b128_result[PATTERN_INPUTS_SHORT_COUNT * i + j]); 130*72f463bcSMateja Marjanovic } 131*72f463bcSMateja Marjanovic } 132*72f463bcSMateja Marjanovic 133*72f463bcSMateja Marjanovic for (i = 0; i < RANDOM_INPUTS_SHORT_COUNT; i++) { 134*72f463bcSMateja Marjanovic for (j = 0; j < RANDOM_INPUTS_SHORT_COUNT; j++) { 135*72f463bcSMateja Marjanovic do_msa_DIV_U_H(b128_random[i], b128_random[j], 136*72f463bcSMateja Marjanovic b128_result[((PATTERN_INPUTS_SHORT_COUNT) * 137*72f463bcSMateja Marjanovic (PATTERN_INPUTS_SHORT_COUNT)) + 138*72f463bcSMateja Marjanovic RANDOM_INPUTS_SHORT_COUNT * i + j]); 139*72f463bcSMateja Marjanovic } 140*72f463bcSMateja Marjanovic } 141*72f463bcSMateja Marjanovic 142*72f463bcSMateja Marjanovic gettimeofday(&end, NULL); 143*72f463bcSMateja Marjanovic 144*72f463bcSMateja Marjanovic elapsed_time = (end.tv_sec - start.tv_sec) * 1000.0; 145*72f463bcSMateja Marjanovic elapsed_time += (end.tv_usec - start.tv_usec) / 1000.0; 146*72f463bcSMateja Marjanovic 147*72f463bcSMateja Marjanovic ret = check_results(instruction_name, TEST_COUNT_TOTAL, elapsed_time, 148*72f463bcSMateja Marjanovic &b128_result[0][0], &b128_expect[0][0]); 149*72f463bcSMateja Marjanovic 150*72f463bcSMateja Marjanovic return ret; 151*72f463bcSMateja Marjanovic } 152