1750541c4SAleksandar Markovic /* 2750541c4SAleksandar Markovic * Test program for MSA instruction MOD_S.W 3750541c4SAleksandar Markovic * 4750541c4SAleksandar Markovic * Copyright (C) 2019 Wave Computing, Inc. 5750541c4SAleksandar Markovic * Copyright (C) 2019 Aleksandar Markovic <amarkovic@wavecomp.com> 6750541c4SAleksandar Markovic * Copyright (C) 2019 RT-RK Computer Based Systems LLC 7750541c4SAleksandar Markovic * Copyright (C) 2019 Mateja Marjanovic <mateja.marjanovic@rt-rk.com> 8750541c4SAleksandar Markovic * 9750541c4SAleksandar Markovic * This program is free software: you can redistribute it and/or modify 10750541c4SAleksandar Markovic * it under the terms of the GNU General Public License as published by 11750541c4SAleksandar Markovic * the Free Software Foundation, either version 2 of the License, or 12750541c4SAleksandar Markovic * (at your option) any later version. 13750541c4SAleksandar Markovic * 14750541c4SAleksandar Markovic * This program is distributed in the hope that it will be useful, 15750541c4SAleksandar Markovic * but WITHOUT ANY WARRANTY; without even the implied warranty of 16750541c4SAleksandar Markovic * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17750541c4SAleksandar Markovic * GNU General Public License for more details. 18750541c4SAleksandar Markovic * 19750541c4SAleksandar Markovic * You should have received a copy of the GNU General Public License 20750541c4SAleksandar Markovic * along with this program. If not, see <https://www.gnu.org/licenses/>. 21750541c4SAleksandar Markovic * 22750541c4SAleksandar Markovic */ 23750541c4SAleksandar Markovic 24750541c4SAleksandar Markovic #include <sys/time.h> 25750541c4SAleksandar Markovic #include <stdint.h> 26750541c4SAleksandar Markovic 27750541c4SAleksandar Markovic #include "../../../../include/wrappers_msa.h" 28750541c4SAleksandar Markovic #include "../../../../include/test_inputs_128.h" 29750541c4SAleksandar Markovic #include "../../../../include/test_utils_128.h" 30750541c4SAleksandar Markovic 31750541c4SAleksandar Markovic #define TEST_COUNT_TOTAL ( \ 32750541c4SAleksandar Markovic (PATTERN_INPUTS_SHORT_COUNT) * (PATTERN_INPUTS_SHORT_COUNT) + \ 33750541c4SAleksandar Markovic (RANDOM_INPUTS_SHORT_COUNT) * (RANDOM_INPUTS_SHORT_COUNT)) 34750541c4SAleksandar Markovic 35750541c4SAleksandar Markovic 36750541c4SAleksandar Markovic int32_t main(void) 37750541c4SAleksandar Markovic { 38*8e6fe6b8SAleksandar Markovic char *isa_ase_name = "MSA"; 39*8e6fe6b8SAleksandar Markovic char *group_name = "Int Modulo"; 40750541c4SAleksandar Markovic char *instruction_name = "MOD_S.W"; 41750541c4SAleksandar Markovic int32_t ret; 42750541c4SAleksandar Markovic uint32_t i, j; 43750541c4SAleksandar Markovic struct timeval start, end; 44750541c4SAleksandar Markovic double elapsed_time; 45750541c4SAleksandar Markovic 46750541c4SAleksandar Markovic uint64_t b128_result[TEST_COUNT_TOTAL][2]; 47750541c4SAleksandar Markovic uint64_t b128_expect[TEST_COUNT_TOTAL][2] = { 48750541c4SAleksandar Markovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, /* 0 */ 49750541c4SAleksandar Markovic { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, 50750541c4SAleksandar Markovic { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, 51750541c4SAleksandar Markovic { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, 52750541c4SAleksandar Markovic { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, 53750541c4SAleksandar Markovic { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, 54750541c4SAleksandar Markovic { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, 55750541c4SAleksandar Markovic { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, 56750541c4SAleksandar Markovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, /* 8 */ 57750541c4SAleksandar Markovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, 58750541c4SAleksandar Markovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, 59750541c4SAleksandar Markovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, 60750541c4SAleksandar Markovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, 61750541c4SAleksandar Markovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, 62750541c4SAleksandar Markovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, 63750541c4SAleksandar Markovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, 64750541c4SAleksandar Markovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, /* 16 */ 65750541c4SAleksandar Markovic { 0xaaaaaaaaaaaaaaaaULL, 0xaaaaaaaaaaaaaaaaULL, }, 66750541c4SAleksandar Markovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, 67750541c4SAleksandar Markovic { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, 68750541c4SAleksandar Markovic { 0xdddddddedddddddeULL, 0xdddddddedddddddeULL, }, 69750541c4SAleksandar Markovic { 0xddddddddddddddddULL, 0xddddddddddddddddULL, }, 70750541c4SAleksandar Markovic { 0xe38e38e4aaaaaaaaULL, 0xe38e38e2e38e38e4ULL, }, 71750541c4SAleksandar Markovic { 0xfffffffeaaaaaaaaULL, 0xe38e38e3fffffffeULL, }, 72750541c4SAleksandar Markovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, /* 24 */ 73750541c4SAleksandar Markovic { 0x5555555555555555ULL, 0x5555555555555555ULL, }, 74750541c4SAleksandar Markovic { 0x5555555555555555ULL, 0x5555555555555555ULL, }, 75750541c4SAleksandar Markovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, 76750541c4SAleksandar Markovic { 0x2222222122222221ULL, 0x2222222122222221ULL, }, 77750541c4SAleksandar Markovic { 0x2222222222222222ULL, 0x2222222222222222ULL, }, 78750541c4SAleksandar Markovic { 0x1c71c71b55555555ULL, 0x1c71c71d1c71c71bULL, }, 79750541c4SAleksandar Markovic { 0x0000000155555555ULL, 0x1c71c71c00000001ULL, }, 80750541c4SAleksandar Markovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, /* 32 */ 81750541c4SAleksandar Markovic { 0xccccccccccccccccULL, 0xccccccccccccccccULL, }, 82750541c4SAleksandar Markovic { 0xccccccccccccccccULL, 0xccccccccccccccccULL, }, 83750541c4SAleksandar Markovic { 0xccccccccccccccccULL, 0xccccccccccccccccULL, }, 84750541c4SAleksandar Markovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, 85750541c4SAleksandar Markovic { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, 86750541c4SAleksandar Markovic { 0xe93e93e9ccccccccULL, 0xcccccccce93e93e9ULL, }, 87750541c4SAleksandar Markovic { 0xe93e93e8ccccccccULL, 0xcccccccce93e93e8ULL, }, 88750541c4SAleksandar Markovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, /* 40 */ 89750541c4SAleksandar Markovic { 0x3333333333333333ULL, 0x3333333333333333ULL, }, 90750541c4SAleksandar Markovic { 0x3333333333333333ULL, 0x3333333333333333ULL, }, 91750541c4SAleksandar Markovic { 0x3333333333333333ULL, 0x3333333333333333ULL, }, 92750541c4SAleksandar Markovic { 0x3333333333333333ULL, 0x3333333333333333ULL, }, 93750541c4SAleksandar Markovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, 94750541c4SAleksandar Markovic { 0x16c16c1633333333ULL, 0x3333333316c16c16ULL, }, 95750541c4SAleksandar Markovic { 0x16c16c1733333333ULL, 0x3333333316c16c17ULL, }, 96750541c4SAleksandar Markovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, /* 48 */ 97750541c4SAleksandar Markovic { 0xe38e38e38e38e38eULL, 0x38e38e38e38e38e3ULL, }, 98750541c4SAleksandar Markovic { 0xe38e38e3e38e38e4ULL, 0x38e38e38e38e38e3ULL, }, 99750541c4SAleksandar Markovic { 0xe38e38e3e38e38e3ULL, 0x38e38e38e38e38e3ULL, }, 100750541c4SAleksandar Markovic { 0xe38e38e3f49f49f6ULL, 0x05b05b04e38e38e3ULL, }, 101750541c4SAleksandar Markovic { 0xe38e38e3f49f49f4ULL, 0x05b05b05e38e38e3ULL, }, 102750541c4SAleksandar Markovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, 103750541c4SAleksandar Markovic { 0xffffffffffffffffULL, 0x38e38e38ffffffffULL, }, 104750541c4SAleksandar Markovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, /* 56 */ 105750541c4SAleksandar Markovic { 0x1c71c71c71c71c71ULL, 0xc71c71c71c71c71cULL, }, 106750541c4SAleksandar Markovic { 0x1c71c71c1c71c71bULL, 0xc71c71c71c71c71cULL, }, 107750541c4SAleksandar Markovic { 0x1c71c71c1c71c71cULL, 0xc71c71c71c71c71cULL, }, 108750541c4SAleksandar Markovic { 0x1c71c71c0b60b609ULL, 0xfa4fa4fb1c71c71cULL, }, 109750541c4SAleksandar Markovic { 0x1c71c71c0b60b60bULL, 0xfa4fa4fa1c71c71cULL, }, 110750541c4SAleksandar Markovic { 0x1c71c71c71c71c71ULL, 0xffffffff1c71c71cULL, }, 111750541c4SAleksandar Markovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, 112750541c4SAleksandar Markovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, /* 64 */ 113750541c4SAleksandar Markovic { 0xffa2dbf828625540ULL, 0x127fda10fe7bb00cULL, }, 114750541c4SAleksandar Markovic { 0xdc10382228625540ULL, 0x238e445ffe7bb00cULL, }, 115750541c4SAleksandar Markovic { 0xf8b9fd1928625540ULL, 0x4b670b5efe7bb00cULL, }, 116750541c4SAleksandar Markovic { 0xfbbe0063253171c8ULL, 0x12f7bb1a0002f3a4ULL, }, 117750541c4SAleksandar Markovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, 118750541c4SAleksandar Markovic { 0xfbbe006307635288ULL, 0x12f7bb1a153f52fcULL, }, 119750541c4SAleksandar Markovic { 0xfbbe00634d93c708ULL, 0x12f7bb1a153f52fcULL, }, 120750541c4SAleksandar Markovic { 0xac5aaeaae231e0c0ULL, 0x27d8c6fffe985280ULL, }, /* 72 */ 121750541c4SAleksandar Markovic { 0xfd40a751b9cf8b80ULL, 0x01e950cbeae91e08ULL, }, 122750541c4SAleksandar Markovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, 123750541c4SAleksandar Markovic { 0xac5aaeaab9cf8b80ULL, 0x27d8c6ffab2b2514ULL, }, 124750541c4SAleksandar Markovic { 0x704f164d0d6d37ceULL, 0xd9589436ffb8aff4ULL, }, 125750541c4SAleksandar Markovic { 0x019b205b109e1b46ULL, 0xffbfeb74fe402e90ULL, }, 126750541c4SAleksandar Markovic { 0x1ca9c4f718016dceULL, 0xdda316d6fe17bd8cULL, }, 127750541c4SAleksandar Markovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, 128750541c4SAleksandar Markovic }; 129750541c4SAleksandar Markovic 130ca693d1cSAleksandar Markovic reset_msa_registers(); 131ca693d1cSAleksandar Markovic 132750541c4SAleksandar Markovic gettimeofday(&start, NULL); 133750541c4SAleksandar Markovic 134750541c4SAleksandar Markovic for (i = 0; i < PATTERN_INPUTS_SHORT_COUNT; i++) { 135750541c4SAleksandar Markovic for (j = 0; j < PATTERN_INPUTS_SHORT_COUNT; j++) { 136750541c4SAleksandar Markovic do_msa_MOD_S_W(b128_pattern[i], b128_pattern[j], 137750541c4SAleksandar Markovic b128_result[PATTERN_INPUTS_SHORT_COUNT * i + j]); 138750541c4SAleksandar Markovic } 139750541c4SAleksandar Markovic } 140750541c4SAleksandar Markovic 141750541c4SAleksandar Markovic for (i = 0; i < RANDOM_INPUTS_SHORT_COUNT; i++) { 142750541c4SAleksandar Markovic for (j = 0; j < RANDOM_INPUTS_SHORT_COUNT; j++) { 143750541c4SAleksandar Markovic do_msa_MOD_S_W(b128_random[i], b128_random[j], 144750541c4SAleksandar Markovic b128_result[((PATTERN_INPUTS_SHORT_COUNT) * 145750541c4SAleksandar Markovic (PATTERN_INPUTS_SHORT_COUNT)) + 146750541c4SAleksandar Markovic RANDOM_INPUTS_SHORT_COUNT * i + j]); 147750541c4SAleksandar Markovic } 148750541c4SAleksandar Markovic } 149750541c4SAleksandar Markovic 150750541c4SAleksandar Markovic gettimeofday(&end, NULL); 151750541c4SAleksandar Markovic 152750541c4SAleksandar Markovic elapsed_time = (end.tv_sec - start.tv_sec) * 1000.0; 153750541c4SAleksandar Markovic elapsed_time += (end.tv_usec - start.tv_usec) / 1000.0; 154750541c4SAleksandar Markovic 155*8e6fe6b8SAleksandar Markovic ret = check_results_128(isa_ase_name, group_name, instruction_name, 156*8e6fe6b8SAleksandar Markovic TEST_COUNT_TOTAL, elapsed_time, 157750541c4SAleksandar Markovic &b128_result[0][0], &b128_expect[0][0]); 158750541c4SAleksandar Markovic 159750541c4SAleksandar Markovic return ret; 160750541c4SAleksandar Markovic } 161