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