1 /* 2 * Test program for MSA instruction HADD_S.W 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.W"; 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 { 0xfffffffefffffffeULL, 0xfffffffefffffffeULL, }, /* 0 */ 45 { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, 46 { 0xffffaaa9ffffaaa9ULL, 0xffffaaa9ffffaaa9ULL, }, 47 { 0x0000555400005554ULL, 0x0000555400005554ULL, }, 48 { 0xffffcccbffffcccbULL, 0xffffcccbffffcccbULL, }, 49 { 0x0000333200003332ULL, 0x0000333200003332ULL, }, 50 { 0x000038e2ffffe38dULL, 0xffff8e37000038e2ULL, }, 51 { 0xffffc71b00001c70ULL, 0x000071c6ffffc71bULL, }, 52 { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, /* 8 */ 53 { 0x0000000000000000ULL, 0x0000000000000000ULL, }, 54 { 0xffffaaaaffffaaaaULL, 0xffffaaaaffffaaaaULL, }, 55 { 0x0000555500005555ULL, 0x0000555500005555ULL, }, 56 { 0xffffccccffffccccULL, 0xffffccccffffccccULL, }, 57 { 0x0000333300003333ULL, 0x0000333300003333ULL, }, 58 { 0x000038e3ffffe38eULL, 0xffff8e38000038e3ULL, }, 59 { 0xffffc71c00001c71ULL, 0x000071c7ffffc71cULL, }, 60 { 0xffffaaa9ffffaaa9ULL, 0xffffaaa9ffffaaa9ULL, }, /* 16 */ 61 { 0xffffaaaaffffaaaaULL, 0xffffaaaaffffaaaaULL, }, 62 { 0xffff5554ffff5554ULL, 0xffff5554ffff5554ULL, }, 63 { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, 64 { 0xffff7776ffff7776ULL, 0xffff7776ffff7776ULL, }, 65 { 0xffffddddffffddddULL, 0xffffddddffffddddULL, }, 66 { 0xffffe38dffff8e38ULL, 0xffff38e2ffffe38dULL, }, 67 { 0xffff71c6ffffc71bULL, 0x00001c71ffff71c6ULL, }, 68 { 0x0000555400005554ULL, 0x0000555400005554ULL, }, /* 24 */ 69 { 0x0000555500005555ULL, 0x0000555500005555ULL, }, 70 { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, 71 { 0x0000aaaa0000aaaaULL, 0x0000aaaa0000aaaaULL, }, 72 { 0x0000222100002221ULL, 0x0000222100002221ULL, }, 73 { 0x0000888800008888ULL, 0x0000888800008888ULL, }, 74 { 0x00008e38000038e3ULL, 0xffffe38d00008e38ULL, }, 75 { 0x00001c71000071c6ULL, 0x0000c71c00001c71ULL, }, 76 { 0xffffcccbffffcccbULL, 0xffffcccbffffcccbULL, }, /* 32 */ 77 { 0xffffccccffffccccULL, 0xffffccccffffccccULL, }, 78 { 0xffff7776ffff7776ULL, 0xffff7776ffff7776ULL, }, 79 { 0x0000222100002221ULL, 0x0000222100002221ULL, }, 80 { 0xffff9998ffff9998ULL, 0xffff9998ffff9998ULL, }, 81 { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, 82 { 0x000005afffffb05aULL, 0xffff5b04000005afULL, }, 83 { 0xffff93e8ffffe93dULL, 0x00003e93ffff93e8ULL, }, 84 { 0x0000333200003332ULL, 0x0000333200003332ULL, }, /* 40 */ 85 { 0x0000333300003333ULL, 0x0000333300003333ULL, }, 86 { 0xffffddddffffddddULL, 0xffffddddffffddddULL, }, 87 { 0x0000888800008888ULL, 0x0000888800008888ULL, }, 88 { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, 89 { 0x0000666600006666ULL, 0x0000666600006666ULL, }, 90 { 0x00006c16000016c1ULL, 0xffffc16b00006c16ULL, }, 91 { 0xfffffa4f00004fa4ULL, 0x0000a4fafffffa4fULL, }, 92 { 0xffffe38dffff8e37ULL, 0x000038e2ffffe38dULL, }, /* 48 */ 93 { 0xffffe38effff8e38ULL, 0x000038e3ffffe38eULL, }, 94 { 0xffff8e38ffff38e2ULL, 0xffffe38dffff8e38ULL, }, 95 { 0x000038e3ffffe38dULL, 0x00008e38000038e3ULL, }, 96 { 0xffffb05affff5b04ULL, 0x000005afffffb05aULL, }, 97 { 0x000016c1ffffc16bULL, 0x00006c16000016c1ULL, }, 98 { 0x00001c71ffff71c6ULL, 0xffffc71b00001c71ULL, }, 99 { 0xffffaaaaffffaaa9ULL, 0x0000aaaaffffaaaaULL, }, 100 { 0x00001c70000071c6ULL, 0xffffc71b00001c70ULL, }, /* 56 */ 101 { 0x00001c71000071c7ULL, 0xffffc71c00001c71ULL, }, 102 { 0xffffc71b00001c71ULL, 0xffff71c6ffffc71bULL, }, 103 { 0x000071c60000c71cULL, 0x00001c71000071c6ULL, }, 104 { 0xffffe93d00003e93ULL, 0xffff93e8ffffe93dULL, }, 105 { 0x00004fa40000a4faULL, 0xfffffa4f00004fa4ULL, }, 106 { 0x0000555400005555ULL, 0xffff555400005554ULL, }, 107 { 0xffffe38d00008e38ULL, 0x000038e3ffffe38dULL, }, 108 { 0xffff6f3600007da2ULL, 0x000056c5ffffae87ULL, }, /* 64 */ 109 { 0xffff88cdffffef6aULL, 0x0000068100005177ULL, }, 110 { 0xffff3714ffffb3e2ULL, 0x000012660000238fULL, }, 111 { 0xffff9eb700000ab0ULL, 0xffffd43fffffe11bULL, }, 112 { 0xffffe28a0000a2d3ULL, 0x00001e55ffffc54bULL, }, 113 { 0xfffffc210000149bULL, 0xffffce110000683bULL, }, 114 { 0xffffaa68ffffd913ULL, 0xffffd9f600003a53ULL, }, 115 { 0x0000120b00002fe1ULL, 0xffff9bcffffff7dfULL, }, 116 { 0xffff932600000f0fULL, 0x00003336ffff5b37ULL, }, /* 72 */ 117 { 0xffffacbdffff80d7ULL, 0xffffe2f2fffffe27ULL, }, 118 { 0xffff5b04ffff454fULL, 0xffffeed7ffffd03fULL, }, 119 { 0xffffc2a7ffff9c1dULL, 0xffffb0b0ffff8dcbULL, }, 120 { 0x0000571b0000b371ULL, 0xffff994fffff594eULL, }, 121 { 0x000070b200002539ULL, 0xffff490bfffffc3eULL, }, 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_W(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_W(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