1*750541c4SAleksandar Markovic /* 2*750541c4SAleksandar Markovic * Test program for MSA instruction MOD_U.H 3*750541c4SAleksandar Markovic * 4*750541c4SAleksandar Markovic * Copyright (C) 2019 Wave Computing, Inc. 5*750541c4SAleksandar Markovic * Copyright (C) 2019 Aleksandar Markovic <amarkovic@wavecomp.com> 6*750541c4SAleksandar Markovic * Copyright (C) 2019 RT-RK Computer Based Systems LLC 7*750541c4SAleksandar Markovic * Copyright (C) 2019 Mateja Marjanovic <mateja.marjanovic@rt-rk.com> 8*750541c4SAleksandar Markovic * 9*750541c4SAleksandar Markovic * This program is free software: you can redistribute it and/or modify 10*750541c4SAleksandar Markovic * it under the terms of the GNU General Public License as published by 11*750541c4SAleksandar Markovic * the Free Software Foundation, either version 2 of the License, or 12*750541c4SAleksandar Markovic * (at your option) any later version. 13*750541c4SAleksandar Markovic * 14*750541c4SAleksandar Markovic * This program is distributed in the hope that it will be useful, 15*750541c4SAleksandar Markovic * but WITHOUT ANY WARRANTY; without even the implied warranty of 16*750541c4SAleksandar Markovic * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17*750541c4SAleksandar Markovic * GNU General Public License for more details. 18*750541c4SAleksandar Markovic * 19*750541c4SAleksandar Markovic * You should have received a copy of the GNU General Public License 20*750541c4SAleksandar Markovic * along with this program. If not, see <https://www.gnu.org/licenses/>. 21*750541c4SAleksandar Markovic * 22*750541c4SAleksandar Markovic */ 23*750541c4SAleksandar Markovic 24*750541c4SAleksandar Markovic #include <sys/time.h> 25*750541c4SAleksandar Markovic #include <stdint.h> 26*750541c4SAleksandar Markovic 27*750541c4SAleksandar Markovic #include "../../../../include/wrappers_msa.h" 28*750541c4SAleksandar Markovic #include "../../../../include/test_inputs_128.h" 29*750541c4SAleksandar Markovic #include "../../../../include/test_utils_128.h" 30*750541c4SAleksandar Markovic 31*750541c4SAleksandar Markovic #define TEST_COUNT_TOTAL ( \ 32*750541c4SAleksandar Markovic (PATTERN_INPUTS_SHORT_COUNT) * (PATTERN_INPUTS_SHORT_COUNT) + \ 33*750541c4SAleksandar Markovic (RANDOM_INPUTS_SHORT_COUNT) * (RANDOM_INPUTS_SHORT_COUNT)) 34*750541c4SAleksandar Markovic 35*750541c4SAleksandar Markovic 36*750541c4SAleksandar Markovic int32_t main(void) 37*750541c4SAleksandar Markovic { 38*750541c4SAleksandar Markovic char *instruction_name = "MOD_U.H"; 39*750541c4SAleksandar Markovic int32_t ret; 40*750541c4SAleksandar Markovic uint32_t i, j; 41*750541c4SAleksandar Markovic struct timeval start, end; 42*750541c4SAleksandar Markovic double elapsed_time; 43*750541c4SAleksandar Markovic 44*750541c4SAleksandar Markovic uint64_t b128_result[TEST_COUNT_TOTAL][2]; 45*750541c4SAleksandar Markovic uint64_t b128_expect[TEST_COUNT_TOTAL][2] = { 46*750541c4SAleksandar Markovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, /* 0 */ 47*750541c4SAleksandar Markovic { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, 48*750541c4SAleksandar Markovic { 0x5555555555555555ULL, 0x5555555555555555ULL, }, 49*750541c4SAleksandar Markovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, 50*750541c4SAleksandar Markovic { 0x3333333333333333ULL, 0x3333333333333333ULL, }, 51*750541c4SAleksandar Markovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, 52*750541c4SAleksandar Markovic { 0x1c711c7371c71c71ULL, 0x1c7371c71c711c73ULL, }, 53*750541c4SAleksandar Markovic { 0x000638e31c710006ULL, 0x38e31c71000638e3ULL, }, 54*750541c4SAleksandar Markovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, /* 8 */ 55*750541c4SAleksandar Markovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, 56*750541c4SAleksandar Markovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, 57*750541c4SAleksandar Markovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, 58*750541c4SAleksandar Markovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, 59*750541c4SAleksandar Markovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, 60*750541c4SAleksandar Markovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, 61*750541c4SAleksandar Markovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, 62*750541c4SAleksandar Markovic { 0xaaaaaaaaaaaaaaaaULL, 0xaaaaaaaaaaaaaaaaULL, }, /* 16 */ 63*750541c4SAleksandar Markovic { 0xaaaaaaaaaaaaaaaaULL, 0xaaaaaaaaaaaaaaaaULL, }, 64*750541c4SAleksandar Markovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, 65*750541c4SAleksandar Markovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, 66*750541c4SAleksandar Markovic { 0xaaaaaaaaaaaaaaaaULL, 0xaaaaaaaaaaaaaaaaULL, }, 67*750541c4SAleksandar Markovic { 0x1111111111111111ULL, 0x1111111111111111ULL, }, 68*750541c4SAleksandar Markovic { 0xaaaa00011c72aaaaULL, 0x00011c72aaaa0001ULL, }, 69*750541c4SAleksandar Markovic { 0x0004aaaa38e30004ULL, 0xaaaa38e30004aaaaULL, }, 70*750541c4SAleksandar Markovic { 0x5555555555555555ULL, 0x5555555555555555ULL, }, /* 24 */ 71*750541c4SAleksandar Markovic { 0x5555555555555555ULL, 0x5555555555555555ULL, }, 72*750541c4SAleksandar Markovic { 0x5555555555555555ULL, 0x5555555555555555ULL, }, 73*750541c4SAleksandar Markovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, 74*750541c4SAleksandar Markovic { 0x5555555555555555ULL, 0x5555555555555555ULL, }, 75*750541c4SAleksandar Markovic { 0x2222222222222222ULL, 0x2222222222222222ULL, }, 76*750541c4SAleksandar Markovic { 0x55551c7255555555ULL, 0x1c72555555551c72ULL, }, 77*750541c4SAleksandar Markovic { 0x0002555555550002ULL, 0x5555555500025555ULL, }, 78*750541c4SAleksandar Markovic { 0xccccccccccccccccULL, 0xccccccccccccccccULL, }, /* 32 */ 79*750541c4SAleksandar Markovic { 0xccccccccccccccccULL, 0xccccccccccccccccULL, }, 80*750541c4SAleksandar Markovic { 0x2222222222222222ULL, 0x2222222222222222ULL, }, 81*750541c4SAleksandar Markovic { 0x2222222222222222ULL, 0x2222222222222222ULL, }, 82*750541c4SAleksandar Markovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, 83*750541c4SAleksandar Markovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, 84*750541c4SAleksandar Markovic { 0xcccc22233e94ccccULL, 0x22233e94cccc2223ULL, }, 85*750541c4SAleksandar Markovic { 0x05b505b05b0505b5ULL, 0x05b05b0505b505b0ULL, }, 86*750541c4SAleksandar Markovic { 0x3333333333333333ULL, 0x3333333333333333ULL, }, /* 40 */ 87*750541c4SAleksandar Markovic { 0x3333333333333333ULL, 0x3333333333333333ULL, }, 88*750541c4SAleksandar Markovic { 0x3333333333333333ULL, 0x3333333333333333ULL, }, 89*750541c4SAleksandar Markovic { 0x3333333333333333ULL, 0x3333333333333333ULL, }, 90*750541c4SAleksandar Markovic { 0x3333333333333333ULL, 0x3333333333333333ULL, }, 91*750541c4SAleksandar Markovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, 92*750541c4SAleksandar Markovic { 0x3333333333333333ULL, 0x3333333333333333ULL, }, 93*750541c4SAleksandar Markovic { 0x16c23333333316c2ULL, 0x3333333316c23333ULL, }, 94*750541c4SAleksandar Markovic { 0xe38e38e38e38e38eULL, 0x38e38e38e38e38e3ULL, }, /* 48 */ 95*750541c4SAleksandar Markovic { 0xe38e38e38e38e38eULL, 0x38e38e38e38e38e3ULL, }, 96*750541c4SAleksandar Markovic { 0x38e438e38e3838e4ULL, 0x38e38e3838e438e3ULL, }, 97*750541c4SAleksandar Markovic { 0x38e438e338e338e4ULL, 0x38e338e338e438e3ULL, }, 98*750541c4SAleksandar Markovic { 0x16c238e38e3816c2ULL, 0x38e38e3816c238e3ULL, }, 99*750541c4SAleksandar Markovic { 0x16c205b027d216c2ULL, 0x05b027d216c205b0ULL, }, 100*750541c4SAleksandar Markovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, 101*750541c4SAleksandar Markovic { 0x000638e31c710006ULL, 0x38e31c71000638e3ULL, }, 102*750541c4SAleksandar Markovic { 0x1c71c71c71c71c71ULL, 0xc71c71c71c71c71cULL, }, /* 56 */ 103*750541c4SAleksandar Markovic { 0x1c71c71c71c71c71ULL, 0xc71c71c71c71c71cULL, }, 104*750541c4SAleksandar Markovic { 0x1c711c7271c71c71ULL, 0x1c7271c71c711c72ULL, }, 105*750541c4SAleksandar Markovic { 0x1c711c721c721c71ULL, 0x1c721c721c711c72ULL, }, 106*750541c4SAleksandar Markovic { 0x1c71c71c71c71c71ULL, 0xc71c71c71c71c71cULL, }, 107*750541c4SAleksandar Markovic { 0x1c712d830b611c71ULL, 0x2d830b611c712d83ULL, }, 108*750541c4SAleksandar Markovic { 0x1c711c7371c71c71ULL, 0x1c7371c71c711c73ULL, }, 109*750541c4SAleksandar Markovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, 110*750541c4SAleksandar Markovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, /* 64 */ 111*750541c4SAleksandar Markovic { 0x886a005028625540ULL, 0x12820b5e14c60a14ULL, }, 112*750541c4SAleksandar Markovic { 0x886a382228625540ULL, 0x238f0b5e53501bbcULL, }, 113*750541c4SAleksandar Markovic { 0x181b07ca28625540ULL, 0x4b670b5e5539b00cULL, }, 114*750541c4SAleksandar Markovic { 0x7354006325311c88ULL, 0x12f7053a153f52fcULL, }, 115*750541c4SAleksandar Markovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, 116*750541c4SAleksandar Markovic { 0x4f6400634d933b88ULL, 0x12f7bb1a153f08d4ULL, }, 117*750541c4SAleksandar Markovic { 0x1b2000634d93c708ULL, 0x12f73242153f52fcULL, }, 118*750541c4SAleksandar Markovic { 0x23f0aeaa18473640ULL, 0x27d805c1ab2b2514ULL, }, /* 72 */ 119*750541c4SAleksandar Markovic { 0xac5a00411ea98b80ULL, 0x01ea0be501332514ULL, }, 120*750541c4SAleksandar Markovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, 121*750541c4SAleksandar Markovic { 0x3c0b128f5b9e8b80ULL, 0x27d83e2701e92514ULL, }, 122*750541c4SAleksandar Markovic { 0x704f164d0d6d37ceULL, 0x428a0070a9423294ULL, }, 123*750541c4SAleksandar Markovic { 0x704f0042109e1b46ULL, 0x093088d814893ca8ULL, }, 124*750541c4SAleksandar Markovic { 0x704f164d5e3156ceULL, 0x166988d8a9420428ULL, }, 125*750541c4SAleksandar Markovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, 126*750541c4SAleksandar Markovic }; 127*750541c4SAleksandar Markovic 128*750541c4SAleksandar Markovic gettimeofday(&start, NULL); 129*750541c4SAleksandar Markovic 130*750541c4SAleksandar Markovic for (i = 0; i < PATTERN_INPUTS_SHORT_COUNT; i++) { 131*750541c4SAleksandar Markovic for (j = 0; j < PATTERN_INPUTS_SHORT_COUNT; j++) { 132*750541c4SAleksandar Markovic do_msa_MOD_U_H(b128_pattern[i], b128_pattern[j], 133*750541c4SAleksandar Markovic b128_result[PATTERN_INPUTS_SHORT_COUNT * i + j]); 134*750541c4SAleksandar Markovic } 135*750541c4SAleksandar Markovic } 136*750541c4SAleksandar Markovic 137*750541c4SAleksandar Markovic for (i = 0; i < RANDOM_INPUTS_SHORT_COUNT; i++) { 138*750541c4SAleksandar Markovic for (j = 0; j < RANDOM_INPUTS_SHORT_COUNT; j++) { 139*750541c4SAleksandar Markovic do_msa_MOD_U_H(b128_random[i], b128_random[j], 140*750541c4SAleksandar Markovic b128_result[((PATTERN_INPUTS_SHORT_COUNT) * 141*750541c4SAleksandar Markovic (PATTERN_INPUTS_SHORT_COUNT)) + 142*750541c4SAleksandar Markovic RANDOM_INPUTS_SHORT_COUNT * i + j]); 143*750541c4SAleksandar Markovic } 144*750541c4SAleksandar Markovic } 145*750541c4SAleksandar Markovic 146*750541c4SAleksandar Markovic gettimeofday(&end, NULL); 147*750541c4SAleksandar Markovic 148*750541c4SAleksandar Markovic elapsed_time = (end.tv_sec - start.tv_sec) * 1000.0; 149*750541c4SAleksandar Markovic elapsed_time += (end.tv_usec - start.tv_usec) / 1000.0; 150*750541c4SAleksandar Markovic 151*750541c4SAleksandar Markovic ret = check_results(instruction_name, TEST_COUNT_TOTAL, elapsed_time, 152*750541c4SAleksandar Markovic &b128_result[0][0], &b128_expect[0][0]); 153*750541c4SAleksandar Markovic 154*750541c4SAleksandar Markovic return ret; 155*750541c4SAleksandar Markovic } 156