1 /* 2 * Test program for MSA instruction HADD_S.H 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.H"; 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 { 0xfffefffefffefffeULL, 0xfffefffefffefffeULL, }, /* 0 */ 45 { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, 46 { 0xffa9ffa9ffa9ffa9ULL, 0xffa9ffa9ffa9ffa9ULL, }, 47 { 0x0054005400540054ULL, 0x0054005400540054ULL, }, 48 { 0xffcbffcbffcbffcbULL, 0xffcbffcbffcbffcbULL, }, 49 { 0x0032003200320032ULL, 0x0032003200320032ULL, }, 50 { 0xff8dffe20037ff8dULL, 0xffe20037ff8dffe2ULL, }, 51 { 0x0070001bffc60070ULL, 0x001bffc60070001bULL, }, 52 { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, /* 8 */ 53 { 0x0000000000000000ULL, 0x0000000000000000ULL, }, 54 { 0xffaaffaaffaaffaaULL, 0xffaaffaaffaaffaaULL, }, 55 { 0x0055005500550055ULL, 0x0055005500550055ULL, }, 56 { 0xffccffccffccffccULL, 0xffccffccffccffccULL, }, 57 { 0x0033003300330033ULL, 0x0033003300330033ULL, }, 58 { 0xff8effe30038ff8eULL, 0xffe30038ff8effe3ULL, }, 59 { 0x0071001cffc70071ULL, 0x001cffc70071001cULL, }, 60 { 0xffa9ffa9ffa9ffa9ULL, 0xffa9ffa9ffa9ffa9ULL, }, /* 16 */ 61 { 0xffaaffaaffaaffaaULL, 0xffaaffaaffaaffaaULL, }, 62 { 0xff54ff54ff54ff54ULL, 0xff54ff54ff54ff54ULL, }, 63 { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, 64 { 0xff76ff76ff76ff76ULL, 0xff76ff76ff76ff76ULL, }, 65 { 0xffddffddffddffddULL, 0xffddffddffddffddULL, }, 66 { 0xff38ff8dffe2ff38ULL, 0xff8dffe2ff38ff8dULL, }, 67 { 0x001bffc6ff71001bULL, 0xffc6ff71001bffc6ULL, }, 68 { 0x0054005400540054ULL, 0x0054005400540054ULL, }, /* 24 */ 69 { 0x0055005500550055ULL, 0x0055005500550055ULL, }, 70 { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, 71 { 0x00aa00aa00aa00aaULL, 0x00aa00aa00aa00aaULL, }, 72 { 0x0021002100210021ULL, 0x0021002100210021ULL, }, 73 { 0x0088008800880088ULL, 0x0088008800880088ULL, }, 74 { 0xffe30038008dffe3ULL, 0x0038008dffe30038ULL, }, 75 { 0x00c60071001c00c6ULL, 0x0071001c00c60071ULL, }, 76 { 0xffcbffcbffcbffcbULL, 0xffcbffcbffcbffcbULL, }, /* 32 */ 77 { 0xffccffccffccffccULL, 0xffccffccffccffccULL, }, 78 { 0xff76ff76ff76ff76ULL, 0xff76ff76ff76ff76ULL, }, 79 { 0x0021002100210021ULL, 0x0021002100210021ULL, }, 80 { 0xff98ff98ff98ff98ULL, 0xff98ff98ff98ff98ULL, }, 81 { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, 82 { 0xff5affaf0004ff5aULL, 0xffaf0004ff5affafULL, }, 83 { 0x003dffe8ff93003dULL, 0xffe8ff93003dffe8ULL, }, 84 { 0x0032003200320032ULL, 0x0032003200320032ULL, }, /* 40 */ 85 { 0x0033003300330033ULL, 0x0033003300330033ULL, }, 86 { 0xffddffddffddffddULL, 0xffddffddffddffddULL, }, 87 { 0x0088008800880088ULL, 0x0088008800880088ULL, }, 88 { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, 89 { 0x0066006600660066ULL, 0x0066006600660066ULL, }, 90 { 0xffc10016006bffc1ULL, 0x0016006bffc10016ULL, }, 91 { 0x00a4004ffffa00a4ULL, 0x004ffffa00a4004fULL, }, 92 { 0xffe20037ff8dffe2ULL, 0x0037ff8dffe20037ULL, }, /* 48 */ 93 { 0xffe30038ff8effe3ULL, 0x0038ff8effe30038ULL, }, 94 { 0xff8dffe2ff38ff8dULL, 0xffe2ff38ff8dffe2ULL, }, 95 { 0x0038008dffe30038ULL, 0x008dffe30038008dULL, }, 96 { 0xffaf0004ff5affafULL, 0x0004ff5affaf0004ULL, }, 97 { 0x0016006bffc10016ULL, 0x006bffc10016006bULL, }, 98 { 0xff71001bffc6ff71ULL, 0x001bffc6ff71001bULL, }, 99 { 0x00540054ff550054ULL, 0x0054ff5500540054ULL, }, 100 { 0x001bffc60070001bULL, 0xffc60070001bffc6ULL, }, /* 56 */ 101 { 0x001cffc70071001cULL, 0xffc70071001cffc7ULL, }, 102 { 0xffc6ff71001bffc6ULL, 0xff71001bffc6ff71ULL, }, 103 { 0x0071001c00c60071ULL, 0x001c00c60071001cULL, }, 104 { 0xffe8ff93003dffe8ULL, 0xff93003dffe8ff93ULL, }, 105 { 0x004ffffa00a4004fULL, 0xfffa00a4004ffffaULL, }, 106 { 0xffaaffaa00a9ffaaULL, 0xffaa00a9ffaaffaaULL, }, 107 { 0x008dffe30038008dULL, 0xffe30038008dffe3ULL, }, 108 { 0xfff2ffb2008a0095ULL, 0x00b200690079ffbcULL, }, /* 64 */ 109 { 0xff460049ffbb005dULL, 0x00420025003dffacULL, }, 110 { 0xffe2ff90fff7ffd5ULL, 0x0023000a0029ffc4ULL, }, 111 { 0xffd70033005900a3ULL, 0x003cffe30040ff50ULL, }, 112 { 0x0065ffcc00af0007ULL, 0x007900190090005eULL, }, 113 { 0xffb90063ffe0ffcfULL, 0x0009ffd50054004eULL, }, 114 { 0x0055ffaa001cff47ULL, 0xffeaffba00400066ULL, }, 115 { 0x004a004d007e0015ULL, 0x0003ff930057fff2ULL, }, 116 { 0x0016ff7a001bffcbULL, 0x008e002400260031ULL, }, /* 72 */ 117 { 0xff6a0011ff4cff93ULL, 0x001effe0ffea0021ULL, }, 118 { 0x0006ff58ff88ff0bULL, 0xffffffc5ffd60039ULL, }, 119 { 0xfffbfffbffeaffd9ULL, 0x0018ff9effedffc5ULL, }, 120 { 0x00daffe200c00022ULL, 0xfff4ffe60024ffeeULL, }, 121 { 0x002e0079fff1ffeaULL, 0xff84ffa2ffe8ffdeULL, }, 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_H(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_H(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