172f463bcSMateja Marjanovic /* 272f463bcSMateja Marjanovic * Test program for MSA instruction DIV_U.H 372f463bcSMateja Marjanovic * 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> 872f463bcSMateja Marjanovic * 972f463bcSMateja Marjanovic * This program is free software: you can redistribute it and/or modify 1072f463bcSMateja Marjanovic * it under the terms of the GNU General Public License as published by 1172f463bcSMateja Marjanovic * the Free Software Foundation, either version 2 of the License, or 1272f463bcSMateja Marjanovic * (at your option) any later version. 1372f463bcSMateja Marjanovic * 1472f463bcSMateja Marjanovic * This program is distributed in the hope that it will be useful, 1572f463bcSMateja Marjanovic * but WITHOUT ANY WARRANTY; without even the implied warranty of 1672f463bcSMateja Marjanovic * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1772f463bcSMateja Marjanovic * GNU General Public License for more details. 1872f463bcSMateja Marjanovic * 1972f463bcSMateja Marjanovic * You should have received a copy of the GNU General Public License 2072f463bcSMateja Marjanovic * along with this program. If not, see <https://www.gnu.org/licenses/>. 2172f463bcSMateja Marjanovic * 2272f463bcSMateja Marjanovic */ 2372f463bcSMateja Marjanovic 2472f463bcSMateja Marjanovic #include <sys/time.h> 2572f463bcSMateja Marjanovic #include <stdint.h> 2672f463bcSMateja Marjanovic 2772f463bcSMateja Marjanovic #include "../../../../include/wrappers_msa.h" 28750541c4SAleksandar Markovic #include "../../../../include/test_inputs_128.h" 29750541c4SAleksandar Markovic #include "../../../../include/test_utils_128.h" 3072f463bcSMateja Marjanovic 3172f463bcSMateja Marjanovic #define TEST_COUNT_TOTAL ( \ 3272f463bcSMateja Marjanovic (PATTERN_INPUTS_SHORT_COUNT) * (PATTERN_INPUTS_SHORT_COUNT) + \ 3372f463bcSMateja Marjanovic (RANDOM_INPUTS_SHORT_COUNT) * (RANDOM_INPUTS_SHORT_COUNT)) 3472f463bcSMateja Marjanovic 3572f463bcSMateja Marjanovic 3672f463bcSMateja Marjanovic int32_t main(void) 3772f463bcSMateja Marjanovic { 38*8e6fe6b8SAleksandar Markovic char *isa_ase_name = "MSA"; 39*8e6fe6b8SAleksandar Markovic char *group_name = "Int Divide"; 4072f463bcSMateja Marjanovic char *instruction_name = "DIV_U.H"; 4172f463bcSMateja Marjanovic int32_t ret; 4272f463bcSMateja Marjanovic uint32_t i, j; 4372f463bcSMateja Marjanovic struct timeval start, end; 4472f463bcSMateja Marjanovic double elapsed_time; 4572f463bcSMateja Marjanovic 4672f463bcSMateja Marjanovic uint64_t b128_result[TEST_COUNT_TOTAL][2]; 4772f463bcSMateja Marjanovic uint64_t b128_expect[TEST_COUNT_TOTAL][2] = { 4872f463bcSMateja Marjanovic { 0x0001000100010001ULL, 0x0001000100010001ULL, }, /* 0 */ 4972f463bcSMateja Marjanovic { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, 5072f463bcSMateja Marjanovic { 0x0001000100010001ULL, 0x0001000100010001ULL, }, 5172f463bcSMateja Marjanovic { 0x0003000300030003ULL, 0x0003000300030003ULL, }, 5272f463bcSMateja Marjanovic { 0x0001000100010001ULL, 0x0001000100010001ULL, }, 5372f463bcSMateja Marjanovic { 0x0005000500050005ULL, 0x0005000500050005ULL, }, 5472f463bcSMateja Marjanovic { 0x0001000400010001ULL, 0x0004000100010004ULL, }, 5572f463bcSMateja Marjanovic { 0x0009000100020009ULL, 0x0001000200090001ULL, }, 5672f463bcSMateja Marjanovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, /* 8 */ 5772f463bcSMateja Marjanovic { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, 5872f463bcSMateja Marjanovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, 5972f463bcSMateja Marjanovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, 6072f463bcSMateja Marjanovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, 6172f463bcSMateja Marjanovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, 6272f463bcSMateja Marjanovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, 6372f463bcSMateja Marjanovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, 6472f463bcSMateja Marjanovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, /* 16 */ 6572f463bcSMateja Marjanovic { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, 6672f463bcSMateja Marjanovic { 0x0001000100010001ULL, 0x0001000100010001ULL, }, 6772f463bcSMateja Marjanovic { 0x0002000200020002ULL, 0x0002000200020002ULL, }, 6872f463bcSMateja Marjanovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, 6972f463bcSMateja Marjanovic { 0x0003000300030003ULL, 0x0003000300030003ULL, }, 7072f463bcSMateja Marjanovic { 0x0000000300010000ULL, 0x0003000100000003ULL, }, 7172f463bcSMateja Marjanovic { 0x0006000000010006ULL, 0x0000000100060000ULL, }, 7272f463bcSMateja Marjanovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, /* 24 */ 7372f463bcSMateja Marjanovic { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, 7472f463bcSMateja Marjanovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, 7572f463bcSMateja Marjanovic { 0x0001000100010001ULL, 0x0001000100010001ULL, }, 7672f463bcSMateja Marjanovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, 7772f463bcSMateja Marjanovic { 0x0001000100010001ULL, 0x0001000100010001ULL, }, 7872f463bcSMateja Marjanovic { 0x0000000100000000ULL, 0x0001000000000001ULL, }, 7972f463bcSMateja Marjanovic { 0x0003000000000003ULL, 0x0000000000030000ULL, }, 8072f463bcSMateja Marjanovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, /* 32 */ 8172f463bcSMateja Marjanovic { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, 8272f463bcSMateja Marjanovic { 0x0001000100010001ULL, 0x0001000100010001ULL, }, 8372f463bcSMateja Marjanovic { 0x0002000200020002ULL, 0x0002000200020002ULL, }, 8472f463bcSMateja Marjanovic { 0x0001000100010001ULL, 0x0001000100010001ULL, }, 8572f463bcSMateja Marjanovic { 0x0004000400040004ULL, 0x0004000400040004ULL, }, 8672f463bcSMateja Marjanovic { 0x0000000300010000ULL, 0x0003000100000003ULL, }, 8772f463bcSMateja Marjanovic { 0x0007000100010007ULL, 0x0001000100070001ULL, }, 8872f463bcSMateja Marjanovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, /* 40 */ 8972f463bcSMateja Marjanovic { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, 9072f463bcSMateja Marjanovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, 9172f463bcSMateja Marjanovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, 9272f463bcSMateja Marjanovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, 9372f463bcSMateja Marjanovic { 0x0001000100010001ULL, 0x0001000100010001ULL, }, 9472f463bcSMateja Marjanovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, 9572f463bcSMateja Marjanovic { 0x0001000000000001ULL, 0x0000000000010000ULL, }, 9672f463bcSMateja Marjanovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, /* 48 */ 9772f463bcSMateja Marjanovic { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, 9872f463bcSMateja Marjanovic { 0x0001000000000001ULL, 0x0000000000010000ULL, }, 9972f463bcSMateja Marjanovic { 0x0002000000010002ULL, 0x0000000100020000ULL, }, 10072f463bcSMateja Marjanovic { 0x0001000000000001ULL, 0x0000000000010000ULL, }, 10172f463bcSMateja Marjanovic { 0x0004000100020004ULL, 0x0001000200040001ULL, }, 10272f463bcSMateja Marjanovic { 0x0001000100010001ULL, 0x0001000100010001ULL, }, 10372f463bcSMateja Marjanovic { 0x0008000000010008ULL, 0x0000000100080000ULL, }, 10472f463bcSMateja Marjanovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, /* 56 */ 10572f463bcSMateja Marjanovic { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, 10672f463bcSMateja Marjanovic { 0x0000000100000000ULL, 0x0001000000000001ULL, }, 10772f463bcSMateja Marjanovic { 0x0000000200010000ULL, 0x0002000100000002ULL, }, 10872f463bcSMateja Marjanovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, 10972f463bcSMateja Marjanovic { 0x0000000300020000ULL, 0x0003000200000003ULL, }, 11072f463bcSMateja Marjanovic { 0x0000000300000000ULL, 0x0003000000000003ULL, }, 11172f463bcSMateja Marjanovic { 0x0001000100010001ULL, 0x0001000100010001ULL, }, 11272f463bcSMateja Marjanovic { 0x0001000100010001ULL, 0x0001000100010001ULL, }, /* 64 */ 11372f463bcSMateja Marjanovic { 0x0000025400000000ULL, 0x00030000000b0002ULL, }, 11472f463bcSMateja Marjanovic { 0x0000000100000000ULL, 0x0001000000010004ULL, }, 11572f463bcSMateja Marjanovic { 0x0001000a00000000ULL, 0x0000000000010000ULL, }, 11672f463bcSMateja Marjanovic { 0x0001000000010002ULL, 0x0000001000000000ULL, }, 11772f463bcSMateja Marjanovic { 0x0001000100010001ULL, 0x0001000100010001ULL, }, 11872f463bcSMateja Marjanovic { 0x0001000000000001ULL, 0x0000000000000002ULL, }, 11972f463bcSMateja Marjanovic { 0x0002000000000000ULL, 0x0000000100000000ULL, }, 12072f463bcSMateja Marjanovic { 0x0001000000040001ULL, 0x0000001100000000ULL, }, /* 72 */ 12172f463bcSMateja Marjanovic { 0x000001c300020000ULL, 0x0002000100080000ULL, }, 12272f463bcSMateja Marjanovic { 0x0001000100010001ULL, 0x0001000100010001ULL, }, 12372f463bcSMateja Marjanovic { 0x0001000700010000ULL, 0x0000000100010000ULL, }, 12472f463bcSMateja Marjanovic { 0x0000000000020002ULL, 0x0001000c00000001ULL, }, 12572f463bcSMateja Marjanovic { 0x0000003900010001ULL, 0x0007000000070002ULL, }, 126750541c4SAleksandar Markovic { 0x0000000000000001ULL, 0x0003000000000006ULL, }, 127750541c4SAleksandar Markovic { 0x0001000100010001ULL, 0x0001000100010001ULL, }, 12872f463bcSMateja Marjanovic }; 12972f463bcSMateja Marjanovic 130ca693d1cSAleksandar Markovic reset_msa_registers(); 131ca693d1cSAleksandar Markovic 13272f463bcSMateja Marjanovic gettimeofday(&start, NULL); 13372f463bcSMateja Marjanovic 13472f463bcSMateja Marjanovic for (i = 0; i < PATTERN_INPUTS_SHORT_COUNT; i++) { 13572f463bcSMateja Marjanovic for (j = 0; j < PATTERN_INPUTS_SHORT_COUNT; j++) { 13672f463bcSMateja Marjanovic do_msa_DIV_U_H(b128_pattern[i], b128_pattern[j], 13772f463bcSMateja Marjanovic b128_result[PATTERN_INPUTS_SHORT_COUNT * i + j]); 13872f463bcSMateja Marjanovic } 13972f463bcSMateja Marjanovic } 14072f463bcSMateja Marjanovic 14172f463bcSMateja Marjanovic for (i = 0; i < RANDOM_INPUTS_SHORT_COUNT; i++) { 14272f463bcSMateja Marjanovic for (j = 0; j < RANDOM_INPUTS_SHORT_COUNT; j++) { 14372f463bcSMateja Marjanovic do_msa_DIV_U_H(b128_random[i], b128_random[j], 14472f463bcSMateja Marjanovic b128_result[((PATTERN_INPUTS_SHORT_COUNT) * 14572f463bcSMateja Marjanovic (PATTERN_INPUTS_SHORT_COUNT)) + 14672f463bcSMateja Marjanovic RANDOM_INPUTS_SHORT_COUNT * i + j]); 14772f463bcSMateja Marjanovic } 14872f463bcSMateja Marjanovic } 14972f463bcSMateja Marjanovic 15072f463bcSMateja Marjanovic gettimeofday(&end, NULL); 15172f463bcSMateja Marjanovic 15272f463bcSMateja Marjanovic elapsed_time = (end.tv_sec - start.tv_sec) * 1000.0; 15372f463bcSMateja Marjanovic elapsed_time += (end.tv_usec - start.tv_usec) / 1000.0; 15472f463bcSMateja Marjanovic 155*8e6fe6b8SAleksandar Markovic ret = check_results_128(isa_ase_name, group_name, instruction_name, 156*8e6fe6b8SAleksandar Markovic TEST_COUNT_TOTAL, elapsed_time, 15772f463bcSMateja Marjanovic &b128_result[0][0], &b128_expect[0][0]); 15872f463bcSMateja Marjanovic 15972f463bcSMateja Marjanovic return ret; 16072f463bcSMateja Marjanovic } 161