1750541c4SAleksandar Markovic /* 2750541c4SAleksandar Markovic * Test program for MSA instruction MOD_U.H 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 { 38750541c4SAleksandar Markovic char *instruction_name = "MOD_U.H"; 39750541c4SAleksandar Markovic int32_t ret; 40750541c4SAleksandar Markovic uint32_t i, j; 41750541c4SAleksandar Markovic struct timeval start, end; 42750541c4SAleksandar Markovic double elapsed_time; 43750541c4SAleksandar Markovic 44750541c4SAleksandar Markovic uint64_t b128_result[TEST_COUNT_TOTAL][2]; 45750541c4SAleksandar Markovic uint64_t b128_expect[TEST_COUNT_TOTAL][2] = { 46750541c4SAleksandar Markovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, /* 0 */ 47750541c4SAleksandar Markovic { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, 48750541c4SAleksandar Markovic { 0x5555555555555555ULL, 0x5555555555555555ULL, }, 49750541c4SAleksandar Markovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, 50750541c4SAleksandar Markovic { 0x3333333333333333ULL, 0x3333333333333333ULL, }, 51750541c4SAleksandar Markovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, 52750541c4SAleksandar Markovic { 0x1c711c7371c71c71ULL, 0x1c7371c71c711c73ULL, }, 53750541c4SAleksandar Markovic { 0x000638e31c710006ULL, 0x38e31c71000638e3ULL, }, 54750541c4SAleksandar Markovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, /* 8 */ 55750541c4SAleksandar Markovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, 56750541c4SAleksandar Markovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, 57750541c4SAleksandar Markovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, 58750541c4SAleksandar Markovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, 59750541c4SAleksandar Markovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, 60750541c4SAleksandar Markovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, 61750541c4SAleksandar Markovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, 62750541c4SAleksandar Markovic { 0xaaaaaaaaaaaaaaaaULL, 0xaaaaaaaaaaaaaaaaULL, }, /* 16 */ 63750541c4SAleksandar Markovic { 0xaaaaaaaaaaaaaaaaULL, 0xaaaaaaaaaaaaaaaaULL, }, 64750541c4SAleksandar Markovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, 65750541c4SAleksandar Markovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, 66750541c4SAleksandar Markovic { 0xaaaaaaaaaaaaaaaaULL, 0xaaaaaaaaaaaaaaaaULL, }, 67750541c4SAleksandar Markovic { 0x1111111111111111ULL, 0x1111111111111111ULL, }, 68750541c4SAleksandar Markovic { 0xaaaa00011c72aaaaULL, 0x00011c72aaaa0001ULL, }, 69750541c4SAleksandar Markovic { 0x0004aaaa38e30004ULL, 0xaaaa38e30004aaaaULL, }, 70750541c4SAleksandar Markovic { 0x5555555555555555ULL, 0x5555555555555555ULL, }, /* 24 */ 71750541c4SAleksandar Markovic { 0x5555555555555555ULL, 0x5555555555555555ULL, }, 72750541c4SAleksandar Markovic { 0x5555555555555555ULL, 0x5555555555555555ULL, }, 73750541c4SAleksandar Markovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, 74750541c4SAleksandar Markovic { 0x5555555555555555ULL, 0x5555555555555555ULL, }, 75750541c4SAleksandar Markovic { 0x2222222222222222ULL, 0x2222222222222222ULL, }, 76750541c4SAleksandar Markovic { 0x55551c7255555555ULL, 0x1c72555555551c72ULL, }, 77750541c4SAleksandar Markovic { 0x0002555555550002ULL, 0x5555555500025555ULL, }, 78750541c4SAleksandar Markovic { 0xccccccccccccccccULL, 0xccccccccccccccccULL, }, /* 32 */ 79750541c4SAleksandar Markovic { 0xccccccccccccccccULL, 0xccccccccccccccccULL, }, 80750541c4SAleksandar Markovic { 0x2222222222222222ULL, 0x2222222222222222ULL, }, 81750541c4SAleksandar Markovic { 0x2222222222222222ULL, 0x2222222222222222ULL, }, 82750541c4SAleksandar Markovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, 83750541c4SAleksandar Markovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, 84750541c4SAleksandar Markovic { 0xcccc22233e94ccccULL, 0x22233e94cccc2223ULL, }, 85750541c4SAleksandar Markovic { 0x05b505b05b0505b5ULL, 0x05b05b0505b505b0ULL, }, 86750541c4SAleksandar Markovic { 0x3333333333333333ULL, 0x3333333333333333ULL, }, /* 40 */ 87750541c4SAleksandar Markovic { 0x3333333333333333ULL, 0x3333333333333333ULL, }, 88750541c4SAleksandar Markovic { 0x3333333333333333ULL, 0x3333333333333333ULL, }, 89750541c4SAleksandar Markovic { 0x3333333333333333ULL, 0x3333333333333333ULL, }, 90750541c4SAleksandar Markovic { 0x3333333333333333ULL, 0x3333333333333333ULL, }, 91750541c4SAleksandar Markovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, 92750541c4SAleksandar Markovic { 0x3333333333333333ULL, 0x3333333333333333ULL, }, 93750541c4SAleksandar Markovic { 0x16c23333333316c2ULL, 0x3333333316c23333ULL, }, 94750541c4SAleksandar Markovic { 0xe38e38e38e38e38eULL, 0x38e38e38e38e38e3ULL, }, /* 48 */ 95750541c4SAleksandar Markovic { 0xe38e38e38e38e38eULL, 0x38e38e38e38e38e3ULL, }, 96750541c4SAleksandar Markovic { 0x38e438e38e3838e4ULL, 0x38e38e3838e438e3ULL, }, 97750541c4SAleksandar Markovic { 0x38e438e338e338e4ULL, 0x38e338e338e438e3ULL, }, 98750541c4SAleksandar Markovic { 0x16c238e38e3816c2ULL, 0x38e38e3816c238e3ULL, }, 99750541c4SAleksandar Markovic { 0x16c205b027d216c2ULL, 0x05b027d216c205b0ULL, }, 100750541c4SAleksandar Markovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, 101750541c4SAleksandar Markovic { 0x000638e31c710006ULL, 0x38e31c71000638e3ULL, }, 102750541c4SAleksandar Markovic { 0x1c71c71c71c71c71ULL, 0xc71c71c71c71c71cULL, }, /* 56 */ 103750541c4SAleksandar Markovic { 0x1c71c71c71c71c71ULL, 0xc71c71c71c71c71cULL, }, 104750541c4SAleksandar Markovic { 0x1c711c7271c71c71ULL, 0x1c7271c71c711c72ULL, }, 105750541c4SAleksandar Markovic { 0x1c711c721c721c71ULL, 0x1c721c721c711c72ULL, }, 106750541c4SAleksandar Markovic { 0x1c71c71c71c71c71ULL, 0xc71c71c71c71c71cULL, }, 107750541c4SAleksandar Markovic { 0x1c712d830b611c71ULL, 0x2d830b611c712d83ULL, }, 108750541c4SAleksandar Markovic { 0x1c711c7371c71c71ULL, 0x1c7371c71c711c73ULL, }, 109750541c4SAleksandar Markovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, 110750541c4SAleksandar Markovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, /* 64 */ 111750541c4SAleksandar Markovic { 0x886a005028625540ULL, 0x12820b5e14c60a14ULL, }, 112750541c4SAleksandar Markovic { 0x886a382228625540ULL, 0x238f0b5e53501bbcULL, }, 113750541c4SAleksandar Markovic { 0x181b07ca28625540ULL, 0x4b670b5e5539b00cULL, }, 114750541c4SAleksandar Markovic { 0x7354006325311c88ULL, 0x12f7053a153f52fcULL, }, 115750541c4SAleksandar Markovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, 116750541c4SAleksandar Markovic { 0x4f6400634d933b88ULL, 0x12f7bb1a153f08d4ULL, }, 117750541c4SAleksandar Markovic { 0x1b2000634d93c708ULL, 0x12f73242153f52fcULL, }, 118750541c4SAleksandar Markovic { 0x23f0aeaa18473640ULL, 0x27d805c1ab2b2514ULL, }, /* 72 */ 119750541c4SAleksandar Markovic { 0xac5a00411ea98b80ULL, 0x01ea0be501332514ULL, }, 120750541c4SAleksandar Markovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, 121750541c4SAleksandar Markovic { 0x3c0b128f5b9e8b80ULL, 0x27d83e2701e92514ULL, }, 122750541c4SAleksandar Markovic { 0x704f164d0d6d37ceULL, 0x428a0070a9423294ULL, }, 123750541c4SAleksandar Markovic { 0x704f0042109e1b46ULL, 0x093088d814893ca8ULL, }, 124750541c4SAleksandar Markovic { 0x704f164d5e3156ceULL, 0x166988d8a9420428ULL, }, 125750541c4SAleksandar Markovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, 126750541c4SAleksandar Markovic }; 127750541c4SAleksandar Markovic 128*ca693d1cSAleksandar Markovic reset_msa_registers(); 129*ca693d1cSAleksandar Markovic 130750541c4SAleksandar Markovic gettimeofday(&start, NULL); 131750541c4SAleksandar Markovic 132750541c4SAleksandar Markovic for (i = 0; i < PATTERN_INPUTS_SHORT_COUNT; i++) { 133750541c4SAleksandar Markovic for (j = 0; j < PATTERN_INPUTS_SHORT_COUNT; j++) { 134750541c4SAleksandar Markovic do_msa_MOD_U_H(b128_pattern[i], b128_pattern[j], 135750541c4SAleksandar Markovic b128_result[PATTERN_INPUTS_SHORT_COUNT * i + j]); 136750541c4SAleksandar Markovic } 137750541c4SAleksandar Markovic } 138750541c4SAleksandar Markovic 139750541c4SAleksandar Markovic for (i = 0; i < RANDOM_INPUTS_SHORT_COUNT; i++) { 140750541c4SAleksandar Markovic for (j = 0; j < RANDOM_INPUTS_SHORT_COUNT; j++) { 141750541c4SAleksandar Markovic do_msa_MOD_U_H(b128_random[i], b128_random[j], 142750541c4SAleksandar Markovic b128_result[((PATTERN_INPUTS_SHORT_COUNT) * 143750541c4SAleksandar Markovic (PATTERN_INPUTS_SHORT_COUNT)) + 144750541c4SAleksandar Markovic RANDOM_INPUTS_SHORT_COUNT * i + j]); 145750541c4SAleksandar Markovic } 146750541c4SAleksandar Markovic } 147750541c4SAleksandar Markovic 148750541c4SAleksandar Markovic gettimeofday(&end, NULL); 149750541c4SAleksandar Markovic 150750541c4SAleksandar Markovic elapsed_time = (end.tv_sec - start.tv_sec) * 1000.0; 151750541c4SAleksandar Markovic elapsed_time += (end.tv_usec - start.tv_usec) / 1000.0; 152750541c4SAleksandar Markovic 153750541c4SAleksandar Markovic ret = check_results(instruction_name, TEST_COUNT_TOTAL, elapsed_time, 154750541c4SAleksandar Markovic &b128_result[0][0], &b128_expect[0][0]); 155750541c4SAleksandar Markovic 156750541c4SAleksandar Markovic return ret; 157750541c4SAleksandar Markovic } 158