1*750541c4SAleksandar Markovic /* 2*750541c4SAleksandar Markovic * Test program for MSA instruction MOD_S.W 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_S.W"; 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 { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, 49*750541c4SAleksandar Markovic { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, 50*750541c4SAleksandar Markovic { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, 51*750541c4SAleksandar Markovic { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, 52*750541c4SAleksandar Markovic { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, 53*750541c4SAleksandar Markovic { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, 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 { 0x0000000000000000ULL, 0x0000000000000000ULL, }, /* 16 */ 63*750541c4SAleksandar Markovic { 0xaaaaaaaaaaaaaaaaULL, 0xaaaaaaaaaaaaaaaaULL, }, 64*750541c4SAleksandar Markovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, 65*750541c4SAleksandar Markovic { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, 66*750541c4SAleksandar Markovic { 0xdddddddedddddddeULL, 0xdddddddedddddddeULL, }, 67*750541c4SAleksandar Markovic { 0xddddddddddddddddULL, 0xddddddddddddddddULL, }, 68*750541c4SAleksandar Markovic { 0xe38e38e4aaaaaaaaULL, 0xe38e38e2e38e38e4ULL, }, 69*750541c4SAleksandar Markovic { 0xfffffffeaaaaaaaaULL, 0xe38e38e3fffffffeULL, }, 70*750541c4SAleksandar Markovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, /* 24 */ 71*750541c4SAleksandar Markovic { 0x5555555555555555ULL, 0x5555555555555555ULL, }, 72*750541c4SAleksandar Markovic { 0x5555555555555555ULL, 0x5555555555555555ULL, }, 73*750541c4SAleksandar Markovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, 74*750541c4SAleksandar Markovic { 0x2222222122222221ULL, 0x2222222122222221ULL, }, 75*750541c4SAleksandar Markovic { 0x2222222222222222ULL, 0x2222222222222222ULL, }, 76*750541c4SAleksandar Markovic { 0x1c71c71b55555555ULL, 0x1c71c71d1c71c71bULL, }, 77*750541c4SAleksandar Markovic { 0x0000000155555555ULL, 0x1c71c71c00000001ULL, }, 78*750541c4SAleksandar Markovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, /* 32 */ 79*750541c4SAleksandar Markovic { 0xccccccccccccccccULL, 0xccccccccccccccccULL, }, 80*750541c4SAleksandar Markovic { 0xccccccccccccccccULL, 0xccccccccccccccccULL, }, 81*750541c4SAleksandar Markovic { 0xccccccccccccccccULL, 0xccccccccccccccccULL, }, 82*750541c4SAleksandar Markovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, 83*750541c4SAleksandar Markovic { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, 84*750541c4SAleksandar Markovic { 0xe93e93e9ccccccccULL, 0xcccccccce93e93e9ULL, }, 85*750541c4SAleksandar Markovic { 0xe93e93e8ccccccccULL, 0xcccccccce93e93e8ULL, }, 86*750541c4SAleksandar Markovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, /* 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 { 0x16c16c1633333333ULL, 0x3333333316c16c16ULL, }, 93*750541c4SAleksandar Markovic { 0x16c16c1733333333ULL, 0x3333333316c16c17ULL, }, 94*750541c4SAleksandar Markovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, /* 48 */ 95*750541c4SAleksandar Markovic { 0xe38e38e38e38e38eULL, 0x38e38e38e38e38e3ULL, }, 96*750541c4SAleksandar Markovic { 0xe38e38e3e38e38e4ULL, 0x38e38e38e38e38e3ULL, }, 97*750541c4SAleksandar Markovic { 0xe38e38e3e38e38e3ULL, 0x38e38e38e38e38e3ULL, }, 98*750541c4SAleksandar Markovic { 0xe38e38e3f49f49f6ULL, 0x05b05b04e38e38e3ULL, }, 99*750541c4SAleksandar Markovic { 0xe38e38e3f49f49f4ULL, 0x05b05b05e38e38e3ULL, }, 100*750541c4SAleksandar Markovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, 101*750541c4SAleksandar Markovic { 0xffffffffffffffffULL, 0x38e38e38ffffffffULL, }, 102*750541c4SAleksandar Markovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, /* 56 */ 103*750541c4SAleksandar Markovic { 0x1c71c71c71c71c71ULL, 0xc71c71c71c71c71cULL, }, 104*750541c4SAleksandar Markovic { 0x1c71c71c1c71c71bULL, 0xc71c71c71c71c71cULL, }, 105*750541c4SAleksandar Markovic { 0x1c71c71c1c71c71cULL, 0xc71c71c71c71c71cULL, }, 106*750541c4SAleksandar Markovic { 0x1c71c71c0b60b609ULL, 0xfa4fa4fb1c71c71cULL, }, 107*750541c4SAleksandar Markovic { 0x1c71c71c0b60b60bULL, 0xfa4fa4fa1c71c71cULL, }, 108*750541c4SAleksandar Markovic { 0x1c71c71c71c71c71ULL, 0xffffffff1c71c71cULL, }, 109*750541c4SAleksandar Markovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, 110*750541c4SAleksandar Markovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, /* 64 */ 111*750541c4SAleksandar Markovic { 0xffa2dbf828625540ULL, 0x127fda10fe7bb00cULL, }, 112*750541c4SAleksandar Markovic { 0xdc10382228625540ULL, 0x238e445ffe7bb00cULL, }, 113*750541c4SAleksandar Markovic { 0xf8b9fd1928625540ULL, 0x4b670b5efe7bb00cULL, }, 114*750541c4SAleksandar Markovic { 0xfbbe0063253171c8ULL, 0x12f7bb1a0002f3a4ULL, }, 115*750541c4SAleksandar Markovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, 116*750541c4SAleksandar Markovic { 0xfbbe006307635288ULL, 0x12f7bb1a153f52fcULL, }, 117*750541c4SAleksandar Markovic { 0xfbbe00634d93c708ULL, 0x12f7bb1a153f52fcULL, }, 118*750541c4SAleksandar Markovic { 0xac5aaeaae231e0c0ULL, 0x27d8c6fffe985280ULL, }, /* 72 */ 119*750541c4SAleksandar Markovic { 0xfd40a751b9cf8b80ULL, 0x01e950cbeae91e08ULL, }, 120*750541c4SAleksandar Markovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, 121*750541c4SAleksandar Markovic { 0xac5aaeaab9cf8b80ULL, 0x27d8c6ffab2b2514ULL, }, 122*750541c4SAleksandar Markovic { 0x704f164d0d6d37ceULL, 0xd9589436ffb8aff4ULL, }, 123*750541c4SAleksandar Markovic { 0x019b205b109e1b46ULL, 0xffbfeb74fe402e90ULL, }, 124*750541c4SAleksandar Markovic { 0x1ca9c4f718016dceULL, 0xdda316d6fe17bd8cULL, }, 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_S_W(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_S_W(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