172f463bcSMateja Marjanovic /* 272f463bcSMateja Marjanovic * Test program for MSA instruction DIV_S.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_S.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 { 0x0001000100010001ULL, 0x0001000100010001ULL, }, 5072f463bcSMateja Marjanovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, 5172f463bcSMateja Marjanovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, 5272f463bcSMateja Marjanovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, 5372f463bcSMateja Marjanovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, 5472f463bcSMateja Marjanovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, 5572f463bcSMateja Marjanovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, 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 { 0x5556555655565556ULL, 0x5556555655565556ULL, }, /* 16 */ 6572f463bcSMateja Marjanovic { 0x0001000100010001ULL, 0x0001000100010001ULL, }, 6672f463bcSMateja Marjanovic { 0x0001000100010001ULL, 0x0001000100010001ULL, }, 6772f463bcSMateja Marjanovic { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, 6872f463bcSMateja Marjanovic { 0x0001000100010001ULL, 0x0001000100010001ULL, }, 6972f463bcSMateja Marjanovic { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, 7072f463bcSMateja Marjanovic { 0x0003ffff00000003ULL, 0xffff00000003ffffULL, }, 7172f463bcSMateja Marjanovic { 0xfffd00010000fffdULL, 0x00010000fffd0001ULL, }, 7272f463bcSMateja Marjanovic { 0xaaabaaabaaabaaabULL, 0xaaabaaabaaabaaabULL, }, /* 24 */ 7372f463bcSMateja Marjanovic { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, 7472f463bcSMateja Marjanovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, 7572f463bcSMateja Marjanovic { 0x0001000100010001ULL, 0x0001000100010001ULL, }, 7672f463bcSMateja Marjanovic { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, 7772f463bcSMateja Marjanovic { 0x0001000100010001ULL, 0x0001000100010001ULL, }, 7872f463bcSMateja Marjanovic { 0xfffe00010000fffeULL, 0x00010000fffe0001ULL, }, 7972f463bcSMateja Marjanovic { 0x0003ffff00000003ULL, 0xffff00000003ffffULL, }, 8072f463bcSMateja Marjanovic { 0x3334333433343334ULL, 0x3334333433343334ULL, }, /* 32 */ 8172f463bcSMateja Marjanovic { 0x0001000100010001ULL, 0x0001000100010001ULL, }, 8272f463bcSMateja Marjanovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, 8372f463bcSMateja Marjanovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, 8472f463bcSMateja Marjanovic { 0x0001000100010001ULL, 0x0001000100010001ULL, }, 8572f463bcSMateja Marjanovic { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, 8672f463bcSMateja Marjanovic { 0x0001000000000001ULL, 0x0000000000010000ULL, }, 8772f463bcSMateja Marjanovic { 0xffff00000000ffffULL, 0x00000000ffff0000ULL, }, 8872f463bcSMateja Marjanovic { 0xcccdcccdcccdcccdULL, 0xcccdcccdcccdcccdULL, }, /* 40 */ 8972f463bcSMateja Marjanovic { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, 9072f463bcSMateja Marjanovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, 9172f463bcSMateja Marjanovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, 9272f463bcSMateja Marjanovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, 9372f463bcSMateja Marjanovic { 0x0001000100010001ULL, 0x0001000100010001ULL, }, 9472f463bcSMateja Marjanovic { 0xffff00000000ffffULL, 0x00000000ffff0000ULL, }, 9572f463bcSMateja Marjanovic { 0x0001000000000001ULL, 0x0000000000010000ULL, }, 9672f463bcSMateja Marjanovic { 0x1c72c71d71c81c72ULL, 0xc71d71c81c72c71dULL, }, /* 48 */ 9772f463bcSMateja Marjanovic { 0x0001ffff00010001ULL, 0xffff00010001ffffULL, }, 9872f463bcSMateja Marjanovic { 0x0000000000010000ULL, 0x0000000100000000ULL, }, 9972f463bcSMateja Marjanovic { 0x00000000ffff0000ULL, 0x0000ffff00000000ULL, }, 10072f463bcSMateja Marjanovic { 0x0000ffff00020000ULL, 0xffff00020000ffffULL, }, 10172f463bcSMateja Marjanovic { 0x00000001fffe0000ULL, 0x0001fffe00000001ULL, }, 10272f463bcSMateja Marjanovic { 0x0001000100010001ULL, 0x0001000100010001ULL, }, 10372f463bcSMateja Marjanovic { 0xffff0000ffffffffULL, 0x0000ffffffff0000ULL, }, 10472f463bcSMateja Marjanovic { 0xe38f38e48e39e38fULL, 0x38e48e39e38f38e4ULL, }, /* 56 */ 10572f463bcSMateja Marjanovic { 0xffff0001ffffffffULL, 0x0001ffffffff0001ULL, }, 10672f463bcSMateja Marjanovic { 0x00000000ffff0000ULL, 0x0000ffff00000000ULL, }, 10772f463bcSMateja Marjanovic { 0x0000000000010000ULL, 0x0000000100000000ULL, }, 10872f463bcSMateja Marjanovic { 0x00000001fffe0000ULL, 0x0001fffe00000001ULL, }, 10972f463bcSMateja Marjanovic { 0x0000ffff00020000ULL, 0xffff00020000ffffULL, }, 11072f463bcSMateja Marjanovic { 0x0000ffff00000000ULL, 0xffff00000000ffffULL, }, 11172f463bcSMateja Marjanovic { 0x0001000100010001ULL, 0x0001000100010001ULL, }, 11272f463bcSMateja Marjanovic { 0x0001000100010001ULL, 0x0001000100010001ULL, }, /* 64 */ 11372f463bcSMateja Marjanovic { 0x001cffbf0000ffffULL, 0x0003000000000000ULL, }, 11472f463bcSMateja Marjanovic { 0x0001000000000000ULL, 0x000100000000fffeULL, }, 11572f463bcSMateja Marjanovic { 0xffffffff0000fffeULL, 0x0000000000000002ULL, }, 11672f463bcSMateja Marjanovic { 0x0000000000010000ULL, 0x0000fffafff3ffffULL, }, 11772f463bcSMateja Marjanovic { 0x0001000100010001ULL, 0x0001000100010001ULL, }, 11872f463bcSMateja Marjanovic { 0x00000000ffff0000ULL, 0x0000000100000002ULL, }, 11972f463bcSMateja Marjanovic { 0x0000000000000001ULL, 0x000000000000fffeULL, }, 12072f463bcSMateja Marjanovic { 0x00000003ffffffffULL, 0x0000fffb00370000ULL, }, /* 72 */ 12172f463bcSMateja Marjanovic { 0x0013ff2e00000002ULL, 0x00020000fffd0000ULL, }, 12272f463bcSMateja Marjanovic { 0x0001000100010001ULL, 0x0001000100010001ULL, }, 12372f463bcSMateja Marjanovic { 0x0000fffd00000003ULL, 0x000000000000ffffULL, }, 12472f463bcSMateja Marjanovic { 0x0000000000020000ULL, 0xfffffff600390000ULL, }, 12572f463bcSMateja Marjanovic { 0xffe6003900010000ULL, 0xfffa0001fffc0000ULL, }, 126750541c4SAleksandar Markovic { 0xffff0000ffff0000ULL, 0xfffe000200010000ULL, }, 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_S_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_S_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