1 /* 2 * Test program for MSA instruction HADD_S.D 3 * 4 * Copyright (C) 2019 RT-RK Computer Based Systems LLC 5 * Copyright (C) 2019 Mateja Marjanovic <mateja.marjanovic@rt-rk.com> 6 * 7 * This program is free software: you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License as published by 9 * the Free Software Foundation, either version 2 of the License, or 10 * (at your option) any later version. 11 * 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with this program. If not, see <https://www.gnu.org/licenses/>. 19 * 20 */ 21 22 #include <sys/time.h> 23 #include <stdint.h> 24 25 #include "../../../../include/wrappers_msa.h" 26 #include "../../../../include/test_inputs_128.h" 27 #include "../../../../include/test_utils_128.h" 28 29 #define TEST_COUNT_TOTAL ( \ 30 (PATTERN_INPUTS_SHORT_COUNT) * (PATTERN_INPUTS_SHORT_COUNT) + \ 31 (RANDOM_INPUTS_SHORT_COUNT) * (RANDOM_INPUTS_SHORT_COUNT)) 32 33 34 int32_t main(void) 35 { 36 char *instruction_name = "HADD_S.D"; 37 int32_t ret; 38 uint32_t i, j; 39 struct timeval start, end; 40 double elapsed_time; 41 42 uint64_t b128_result[TEST_COUNT_TOTAL][2]; 43 uint64_t b128_expect[TEST_COUNT_TOTAL][2] = { 44 { 0xfffffffffffffffeULL, 0xfffffffffffffffeULL, }, /* 0 */ 45 { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, 46 { 0xffffffffaaaaaaa9ULL, 0xffffffffaaaaaaa9ULL, }, 47 { 0x0000000055555554ULL, 0x0000000055555554ULL, }, 48 { 0xffffffffcccccccbULL, 0xffffffffcccccccbULL, }, 49 { 0x0000000033333332ULL, 0x0000000033333332ULL, }, 50 { 0xffffffff8e38e38dULL, 0xffffffffe38e38e2ULL, }, 51 { 0x0000000071c71c70ULL, 0x000000001c71c71bULL, }, 52 { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, /* 8 */ 53 { 0x0000000000000000ULL, 0x0000000000000000ULL, }, 54 { 0xffffffffaaaaaaaaULL, 0xffffffffaaaaaaaaULL, }, 55 { 0x0000000055555555ULL, 0x0000000055555555ULL, }, 56 { 0xffffffffccccccccULL, 0xffffffffccccccccULL, }, 57 { 0x0000000033333333ULL, 0x0000000033333333ULL, }, 58 { 0xffffffff8e38e38eULL, 0xffffffffe38e38e3ULL, }, 59 { 0x0000000071c71c71ULL, 0x000000001c71c71cULL, }, 60 { 0xffffffffaaaaaaa9ULL, 0xffffffffaaaaaaa9ULL, }, /* 16 */ 61 { 0xffffffffaaaaaaaaULL, 0xffffffffaaaaaaaaULL, }, 62 { 0xffffffff55555554ULL, 0xffffffff55555554ULL, }, 63 { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, 64 { 0xffffffff77777776ULL, 0xffffffff77777776ULL, }, 65 { 0xffffffffddddddddULL, 0xffffffffddddddddULL, }, 66 { 0xffffffff38e38e38ULL, 0xffffffff8e38e38dULL, }, 67 { 0x000000001c71c71bULL, 0xffffffffc71c71c6ULL, }, 68 { 0x0000000055555554ULL, 0x0000000055555554ULL, }, /* 24 */ 69 { 0x0000000055555555ULL, 0x0000000055555555ULL, }, 70 { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, 71 { 0x00000000aaaaaaaaULL, 0x00000000aaaaaaaaULL, }, 72 { 0x0000000022222221ULL, 0x0000000022222221ULL, }, 73 { 0x0000000088888888ULL, 0x0000000088888888ULL, }, 74 { 0xffffffffe38e38e3ULL, 0x0000000038e38e38ULL, }, 75 { 0x00000000c71c71c6ULL, 0x0000000071c71c71ULL, }, 76 { 0xffffffffcccccccbULL, 0xffffffffcccccccbULL, }, /* 32 */ 77 { 0xffffffffccccccccULL, 0xffffffffccccccccULL, }, 78 { 0xffffffff77777776ULL, 0xffffffff77777776ULL, }, 79 { 0x0000000022222221ULL, 0x0000000022222221ULL, }, 80 { 0xffffffff99999998ULL, 0xffffffff99999998ULL, }, 81 { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, 82 { 0xffffffff5b05b05aULL, 0xffffffffb05b05afULL, }, 83 { 0x000000003e93e93dULL, 0xffffffffe93e93e8ULL, }, 84 { 0x0000000033333332ULL, 0x0000000033333332ULL, }, /* 40 */ 85 { 0x0000000033333333ULL, 0x0000000033333333ULL, }, 86 { 0xffffffffddddddddULL, 0xffffffffddddddddULL, }, 87 { 0x0000000088888888ULL, 0x0000000088888888ULL, }, 88 { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, 89 { 0x0000000066666666ULL, 0x0000000066666666ULL, }, 90 { 0xffffffffc16c16c1ULL, 0x0000000016c16c16ULL, }, 91 { 0x00000000a4fa4fa4ULL, 0x000000004fa4fa4fULL, }, 92 { 0xffffffffe38e38e2ULL, 0x0000000038e38e37ULL, }, /* 48 */ 93 { 0xffffffffe38e38e3ULL, 0x0000000038e38e38ULL, }, 94 { 0xffffffff8e38e38dULL, 0xffffffffe38e38e2ULL, }, 95 { 0x0000000038e38e38ULL, 0x000000008e38e38dULL, }, 96 { 0xffffffffb05b05afULL, 0x0000000005b05b04ULL, }, 97 { 0x0000000016c16c16ULL, 0x000000006c16c16bULL, }, 98 { 0xffffffff71c71c71ULL, 0x000000001c71c71bULL, }, 99 { 0x0000000055555554ULL, 0x0000000055555554ULL, }, 100 { 0x000000001c71c71bULL, 0xffffffffc71c71c6ULL, }, /* 56 */ 101 { 0x000000001c71c71cULL, 0xffffffffc71c71c7ULL, }, 102 { 0xffffffffc71c71c6ULL, 0xffffffff71c71c71ULL, }, 103 { 0x0000000071c71c71ULL, 0x000000001c71c71cULL, }, 104 { 0xffffffffe93e93e8ULL, 0xffffffff93e93e93ULL, }, 105 { 0x000000004fa4fa4fULL, 0xfffffffffa4fa4faULL, }, 106 { 0xffffffffaaaaaaaaULL, 0xffffffffaaaaaaaaULL, }, 107 { 0x000000008e38e38dULL, 0xffffffffe38e38e3ULL, }, 108 { 0xffffffffb0cd3c0cULL, 0x0000000049e2bb6aULL, }, /* 64 */ 109 { 0xffffffffd5feadd4ULL, 0x0000000060a65e5aULL, }, 110 { 0xffffffff423a724cULL, 0xfffffffff6923072ULL, }, 111 { 0xffffffffe69cc91aULL, 0xfffffffff4a9edfeULL, }, 112 { 0x00000000242055a3ULL, 0x0000000011736b26ULL, }, 113 { 0x000000004951c76bULL, 0x0000000028370e16ULL, }, 114 { 0xffffffffb58d8be3ULL, 0xffffffffbe22e02eULL, }, 115 { 0x0000000059efe2b1ULL, 0xffffffffbc3a9dbaULL, }, 116 { 0xffffffffd4bd03eaULL, 0x000000002654770bULL, }, /* 72 */ 117 { 0xfffffffff9ee75b2ULL, 0x000000003d1819fbULL, }, 118 { 0xffffffff662a3a2aULL, 0xffffffffd303ec13ULL, }, 119 { 0x000000000a8c90f8ULL, 0xffffffffd11ba99fULL, }, 120 { 0x0000000098b16b8dULL, 0xffffffff8c6d38e4ULL, }, 121 { 0x00000000bde2dd55ULL, 0xffffffffa330dbd4ULL, }, 122 }; 123 124 gettimeofday(&start, NULL); 125 126 for (i = 0; i < PATTERN_INPUTS_SHORT_COUNT; i++) { 127 for (j = 0; j < PATTERN_INPUTS_SHORT_COUNT; j++) { 128 do_msa_HADD_S_D(b128_pattern[i], b128_pattern[j], 129 b128_result[PATTERN_INPUTS_SHORT_COUNT * i + j]); 130 } 131 } 132 133 for (i = 0; i < RANDOM_INPUTS_SHORT_COUNT; i++) { 134 for (j = 0; j < RANDOM_INPUTS_SHORT_COUNT; j++) { 135 do_msa_HADD_S_D(b128_random[i], b128_random[j], 136 b128_result[((PATTERN_INPUTS_SHORT_COUNT) * 137 (PATTERN_INPUTS_SHORT_COUNT)) + 138 RANDOM_INPUTS_SHORT_COUNT * i + j]); 139 } 140 } 141 142 gettimeofday(&end, NULL); 143 144 elapsed_time = (end.tv_sec - start.tv_sec) * 1000.0; 145 elapsed_time += (end.tv_usec - start.tv_usec) / 1000.0; 146 147 ret = check_results(instruction_name, TEST_COUNT_TOTAL, elapsed_time, 148 &b128_result[0][0], &b128_expect[0][0]); 149 150 return ret; 151 } 152