1b7c67982SAleksandar Markovic /* 2b7c67982SAleksandar Markovic * Test program for MSA instruction MULR_Q.H 3b7c67982SAleksandar Markovic * 4b7c67982SAleksandar Markovic * Copyright (C) 2019 Wave Computing, Inc. 5b7c67982SAleksandar Markovic * Copyright (C) 2019 Aleksandar Markovic <amarkovic@wavecomp.com> 6b7c67982SAleksandar Markovic * Copyright (C) 2019 RT-RK Computer Based Systems LLC 7b7c67982SAleksandar Markovic * Copyright (C) 2019 Mateja Marjanovic <mateja.marjanovic@rt-rk.com> 8b7c67982SAleksandar Markovic * 9b7c67982SAleksandar Markovic * This program is free software: you can redistribute it and/or modify 10b7c67982SAleksandar Markovic * it under the terms of the GNU General Public License as published by 11b7c67982SAleksandar Markovic * the Free Software Foundation, either version 2 of the License, or 12b7c67982SAleksandar Markovic * (at your option) any later version. 13b7c67982SAleksandar Markovic * 14b7c67982SAleksandar Markovic * This program is distributed in the hope that it will be useful, 15b7c67982SAleksandar Markovic * but WITHOUT ANY WARRANTY; without even the implied warranty of 16b7c67982SAleksandar Markovic * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17b7c67982SAleksandar Markovic * GNU General Public License for more details. 18b7c67982SAleksandar Markovic * 19b7c67982SAleksandar Markovic * You should have received a copy of the GNU General Public License 20b7c67982SAleksandar Markovic * along with this program. If not, see <https://www.gnu.org/licenses/>. 21b7c67982SAleksandar Markovic * 22b7c67982SAleksandar Markovic */ 23b7c67982SAleksandar Markovic 24b7c67982SAleksandar Markovic #include <sys/time.h> 25b7c67982SAleksandar Markovic #include <stdint.h> 26b7c67982SAleksandar Markovic 27b7c67982SAleksandar Markovic #include "../../../../include/wrappers_msa.h" 28b7c67982SAleksandar Markovic #include "../../../../include/test_inputs_128.h" 29b7c67982SAleksandar Markovic #include "../../../../include/test_utils_128.h" 30b7c67982SAleksandar Markovic 31b7c67982SAleksandar Markovic #define TEST_COUNT_TOTAL ( \ 32b7c67982SAleksandar Markovic (PATTERN_INPUTS_SHORT_COUNT) * (PATTERN_INPUTS_SHORT_COUNT) + \ 33b7c67982SAleksandar Markovic (RANDOM_INPUTS_SHORT_COUNT) * (RANDOM_INPUTS_SHORT_COUNT)) 34b7c67982SAleksandar Markovic 35b7c67982SAleksandar Markovic 36b7c67982SAleksandar Markovic int32_t main(void) 37b7c67982SAleksandar Markovic { 38*8e6fe6b8SAleksandar Markovic char *isa_ase_name = "MSA"; 39*8e6fe6b8SAleksandar Markovic char *group_name = "Fixed Multiply"; 40b7c67982SAleksandar Markovic char *instruction_name = "MULR_Q.H"; 41b7c67982SAleksandar Markovic int32_t ret; 42b7c67982SAleksandar Markovic uint32_t i, j; 43b7c67982SAleksandar Markovic struct timeval start, end; 44b7c67982SAleksandar Markovic double elapsed_time; 45b7c67982SAleksandar Markovic 46b7c67982SAleksandar Markovic uint64_t b128_result[TEST_COUNT_TOTAL][2]; 47b7c67982SAleksandar Markovic uint64_t b128_expect[TEST_COUNT_TOTAL][2] = { 48b7c67982SAleksandar Markovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, /* 0 */ 49b7c67982SAleksandar Markovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, 50b7c67982SAleksandar Markovic { 0x0001000100010001ULL, 0x0001000100010001ULL, }, 51b7c67982SAleksandar Markovic { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, 52b7c67982SAleksandar Markovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, 53b7c67982SAleksandar Markovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, 54b7c67982SAleksandar Markovic { 0x0000000000010000ULL, 0x0000000100000000ULL, }, 55b7c67982SAleksandar Markovic { 0x00000000ffff0000ULL, 0x0000ffff00000000ULL, }, 56b7c67982SAleksandar Markovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, /* 8 */ 57b7c67982SAleksandar Markovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, 58b7c67982SAleksandar Markovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, 59b7c67982SAleksandar Markovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, 60b7c67982SAleksandar Markovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, 61b7c67982SAleksandar Markovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, 62b7c67982SAleksandar Markovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, 63b7c67982SAleksandar Markovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, 64b7c67982SAleksandar Markovic { 0x0001000100010001ULL, 0x0001000100010001ULL, }, /* 16 */ 65b7c67982SAleksandar Markovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, 66b7c67982SAleksandar Markovic { 0x38e438e438e438e4ULL, 0x38e438e438e438e4ULL, }, 67b7c67982SAleksandar Markovic { 0xc71cc71cc71cc71cULL, 0xc71cc71cc71cc71cULL, }, 68b7c67982SAleksandar Markovic { 0x2223222322232223ULL, 0x2223222322232223ULL, }, 69b7c67982SAleksandar Markovic { 0xdddedddedddedddeULL, 0xdddedddedddedddeULL, }, 70b7c67982SAleksandar Markovic { 0x12f7da134bdb12f7ULL, 0xda134bdb12f7da13ULL, }, 71b7c67982SAleksandar Markovic { 0xed0a25eeb425ed0aULL, 0x25eeb425ed0a25eeULL, }, 72b7c67982SAleksandar Markovic { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, /* 24 */ 73b7c67982SAleksandar Markovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, 74b7c67982SAleksandar Markovic { 0xc71cc71cc71cc71cULL, 0xc71cc71cc71cc71cULL, }, 75b7c67982SAleksandar Markovic { 0x38e338e338e338e3ULL, 0x38e338e338e338e3ULL, }, 76b7c67982SAleksandar Markovic { 0xddddddddddddddddULL, 0xddddddddddddddddULL, }, 77b7c67982SAleksandar Markovic { 0x2222222222222222ULL, 0x2222222222222222ULL, }, 78b7c67982SAleksandar Markovic { 0xed0925edb426ed09ULL, 0x25edb426ed0925edULL, }, 79b7c67982SAleksandar Markovic { 0x12f6da134bda12f6ULL, 0xda134bda12f6da13ULL, }, 80b7c67982SAleksandar Markovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, /* 32 */ 81b7c67982SAleksandar Markovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, 82b7c67982SAleksandar Markovic { 0x2223222322232223ULL, 0x2223222322232223ULL, }, 83b7c67982SAleksandar Markovic { 0xddddddddddddddddULL, 0xddddddddddddddddULL, }, 84b7c67982SAleksandar Markovic { 0x147c147c147c147cULL, 0x147c147c147c147cULL, }, 85b7c67982SAleksandar Markovic { 0xeb85eb85eb85eb85ULL, 0xeb85eb85eb85eb85ULL, }, 86b7c67982SAleksandar Markovic { 0x0b61e93e2d840b61ULL, 0xe93e2d840b61e93eULL, }, 87b7c67982SAleksandar Markovic { 0xf49f16c2d27cf49fULL, 0x16c2d27cf49f16c2ULL, }, 88b7c67982SAleksandar Markovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, /* 40 */ 89b7c67982SAleksandar Markovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, 90b7c67982SAleksandar Markovic { 0xdddedddedddedddeULL, 0xdddedddedddedddeULL, }, 91b7c67982SAleksandar Markovic { 0x2222222222222222ULL, 0x2222222222222222ULL, }, 92b7c67982SAleksandar Markovic { 0xeb85eb85eb85eb85ULL, 0xeb85eb85eb85eb85ULL, }, 93b7c67982SAleksandar Markovic { 0x147b147b147b147bULL, 0x147b147b147b147bULL, }, 94b7c67982SAleksandar Markovic { 0xf49f16c1d27df49fULL, 0x16c1d27df49f16c1ULL, }, 95b7c67982SAleksandar Markovic { 0x0b60e93e2d830b60ULL, 0xe93e2d830b60e93eULL, }, 96b7c67982SAleksandar Markovic { 0x0000000000010000ULL, 0x0000000100000000ULL, }, /* 48 */ 97b7c67982SAleksandar Markovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, 98b7c67982SAleksandar Markovic { 0x12f7da134bdb12f7ULL, 0xda134bdb12f7da13ULL, }, 99b7c67982SAleksandar Markovic { 0xed0925edb426ed09ULL, 0x25edb426ed0925edULL, }, 100b7c67982SAleksandar Markovic { 0x0b61e93e2d840b61ULL, 0xe93e2d840b61e93eULL, }, 101b7c67982SAleksandar Markovic { 0xf49f16c1d27df49fULL, 0x16c1d27df49f16c1ULL, }, 102b7c67982SAleksandar Markovic { 0x0652194865240652ULL, 0x1948652406521948ULL, }, 103b7c67982SAleksandar Markovic { 0xf9aee6b79addf9aeULL, 0xe6b79addf9aee6b7ULL, }, 104b7c67982SAleksandar Markovic { 0x00000000ffff0000ULL, 0x0000ffff00000000ULL, }, /* 56 */ 105b7c67982SAleksandar Markovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, 106b7c67982SAleksandar Markovic { 0xed0a25eeb425ed0aULL, 0x25eeb425ed0a25eeULL, }, 107b7c67982SAleksandar Markovic { 0x12f6da134bda12f6ULL, 0xda134bda12f6da13ULL, }, 108b7c67982SAleksandar Markovic { 0xf49f16c2d27cf49fULL, 0x16c2d27cf49f16c2ULL, }, 109b7c67982SAleksandar Markovic { 0x0b60e93e2d830b60ULL, 0xe93e2d830b60e93eULL, }, 110b7c67982SAleksandar Markovic { 0xf9aee6b79addf9aeULL, 0xe6b79addf9aee6b7ULL, }, 111b7c67982SAleksandar Markovic { 0x0652194965230652ULL, 0x1949652306521949ULL, }, 112b7c67982SAleksandar Markovic { 0x6fba04f60cbe38c7ULL, 0x2c6b0102000531f1ULL, }, /* 64 */ 113b7c67982SAleksandar Markovic { 0x03faffed1879da0fULL, 0x0b2cf9e2ffbfcc2aULL, }, 114b7c67982SAleksandar Markovic { 0x4e261004e9dbb269ULL, 0x1779faf00102e8d7ULL, }, 115b7c67982SAleksandar Markovic { 0x9713fb9c1db7ec39ULL, 0xbccff56b01081259ULL, }, 116b7c67982SAleksandar Markovic { 0x03faffed1879da0fULL, 0x0b2cf9e2ffbfcc2aULL, }, 117b7c67982SAleksandar Markovic { 0x002400002f04195bULL, 0x02cf2516038735cdULL, }, 118b7c67982SAleksandar Markovic { 0x02c8ffc1d57633daULL, 0x05e71eaff1eb180aULL, }, 119b7c67982SAleksandar Markovic { 0xfc44001139160d37ULL, 0xef1a4023f19aecf5ULL, }, 120b7c67982SAleksandar Markovic { 0x4e261004e9dbb269ULL, 0x1779faf00102e8d7ULL, }, /* 72 */ 121b7c67982SAleksandar Markovic { 0x02c8ffc1d57633daULL, 0x05e71eaff1eb180aULL, }, 122b7c67982SAleksandar Markovic { 0x36aa33af267e6a09ULL, 0x0c67196338390abeULL, }, 123b7c67982SAleksandar Markovic { 0xb69bf1d4cc591b07ULL, 0xdc7f3511397df77eULL, }, 124b7c67982SAleksandar Markovic { 0x9713fb9c1db7ec39ULL, 0xbccff56b01081259ULL, }, 125b7c67982SAleksandar Markovic { 0xfc44001139160d37ULL, 0xef1a4023f19aecf5ULL, }, 126b7c67982SAleksandar Markovic { 0xb69bf1d4cc591b07ULL, 0xdc7f3511397df77eULL, }, 127b7c67982SAleksandar Markovic { 0x628a03e3455006e4ULL, 0x65a36eec3ac806beULL, }, 128b7c67982SAleksandar Markovic }; 129b7c67982SAleksandar Markovic 130ca693d1cSAleksandar Markovic reset_msa_registers(); 131ca693d1cSAleksandar Markovic 132b7c67982SAleksandar Markovic gettimeofday(&start, NULL); 133b7c67982SAleksandar Markovic 134b7c67982SAleksandar Markovic for (i = 0; i < PATTERN_INPUTS_SHORT_COUNT; i++) { 135b7c67982SAleksandar Markovic for (j = 0; j < PATTERN_INPUTS_SHORT_COUNT; j++) { 136b7c67982SAleksandar Markovic do_msa_MULR_Q_H(b128_pattern[i], b128_pattern[j], 137b7c67982SAleksandar Markovic b128_result[PATTERN_INPUTS_SHORT_COUNT * i + j]); 138b7c67982SAleksandar Markovic } 139b7c67982SAleksandar Markovic } 140b7c67982SAleksandar Markovic 141b7c67982SAleksandar Markovic for (i = 0; i < RANDOM_INPUTS_SHORT_COUNT; i++) { 142b7c67982SAleksandar Markovic for (j = 0; j < RANDOM_INPUTS_SHORT_COUNT; j++) { 143b7c67982SAleksandar Markovic do_msa_MULR_Q_H(b128_random[i], b128_random[j], 144b7c67982SAleksandar Markovic b128_result[((PATTERN_INPUTS_SHORT_COUNT) * 145b7c67982SAleksandar Markovic (PATTERN_INPUTS_SHORT_COUNT)) + 146b7c67982SAleksandar Markovic RANDOM_INPUTS_SHORT_COUNT * i + j]); 147b7c67982SAleksandar Markovic } 148b7c67982SAleksandar Markovic } 149b7c67982SAleksandar Markovic 150b7c67982SAleksandar Markovic gettimeofday(&end, NULL); 151b7c67982SAleksandar Markovic 152b7c67982SAleksandar Markovic elapsed_time = (end.tv_sec - start.tv_sec) * 1000.0; 153b7c67982SAleksandar Markovic elapsed_time += (end.tv_usec - start.tv_usec) / 1000.0; 154b7c67982SAleksandar Markovic 155*8e6fe6b8SAleksandar Markovic ret = check_results_128(isa_ase_name, group_name, instruction_name, 156*8e6fe6b8SAleksandar Markovic TEST_COUNT_TOTAL, elapsed_time, 157b7c67982SAleksandar Markovic &b128_result[0][0], &b128_expect[0][0]); 158b7c67982SAleksandar Markovic 159b7c67982SAleksandar Markovic return ret; 160b7c67982SAleksandar Markovic } 161