test_msa_maddv_d.c (10661B)
1/* 2 * Test program for MSA instruction MADDV.D 3 * 4 * Copyright (C) 2019 Wave Computing, Inc. 5 * Copyright (C) 2019 Aleksandar Markovic <amarkovic@wavecomp.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 3 * (RANDOM_INPUTS_SHORT_COUNT) * (RANDOM_INPUTS_SHORT_COUNT)) 32 33 34int32_t main(void) 35{ 36 char *isa_ase_name = "MSA"; 37 char *group_name = "Int Multiply"; 38 char *instruction_name = "MADDV.D"; 39 int32_t ret; 40 uint32_t i, j; 41 struct timeval start, end; 42 double elapsed_time; 43 44 uint64_t b128_result[TEST_COUNT_TOTAL][2]; 45 uint64_t b128_expect[TEST_COUNT_TOTAL][2] = { 46 { 0x0000000000000001ULL, 0x0000000000000001ULL, }, /* 0 */ 47 { 0x0000000000000001ULL, 0x0000000000000001ULL, }, 48 { 0x5555555555555557ULL, 0x5555555555555557ULL, }, 49 { 0x0000000000000002ULL, 0x0000000000000002ULL, }, 50 { 0x3333333333333336ULL, 0x3333333333333336ULL, }, 51 { 0x0000000000000003ULL, 0x0000000000000003ULL, }, 52 { 0x1c71c71c71c71c75ULL, 0xc71c71c71c71c720ULL, }, 53 { 0x0000000000000004ULL, 0x0000000000000004ULL, }, 54 { 0x0000000000000004ULL, 0x0000000000000004ULL, }, /* 8 */ 55 { 0x0000000000000004ULL, 0x0000000000000004ULL, }, 56 { 0x0000000000000004ULL, 0x0000000000000004ULL, }, 57 { 0x0000000000000004ULL, 0x0000000000000004ULL, }, 58 { 0x0000000000000004ULL, 0x0000000000000004ULL, }, 59 { 0x0000000000000004ULL, 0x0000000000000004ULL, }, 60 { 0x0000000000000004ULL, 0x0000000000000004ULL, }, 61 { 0x0000000000000004ULL, 0x0000000000000004ULL, }, 62 { 0x555555555555555aULL, 0x555555555555555aULL, }, /* 16 */ 63 { 0x555555555555555aULL, 0x555555555555555aULL, }, 64 { 0x8e38e38e38e38e3eULL, 0x8e38e38e38e38e3eULL, }, 65 { 0xaaaaaaaaaaaaaab0ULL, 0xaaaaaaaaaaaaaab0ULL, }, 66 { 0x2222222222222228ULL, 0x2222222222222228ULL, }, 67 { 0x0000000000000006ULL, 0x0000000000000006ULL, }, 68 { 0x12f684bda12f6852ULL, 0x2f684bda12f684c4ULL, }, 69 { 0x555555555555555cULL, 0x555555555555555cULL, }, 70 { 0x0000000000000007ULL, 0x0000000000000007ULL, }, /* 24 */ 71 { 0x0000000000000007ULL, 0x0000000000000007ULL, }, 72 { 0x1c71c71c71c71c79ULL, 0x1c71c71c71c71c79ULL, }, 73 { 0xaaaaaaaaaaaaaab2ULL, 0xaaaaaaaaaaaaaab2ULL, }, 74 { 0x666666666666666eULL, 0x666666666666666eULL, }, 75 { 0x555555555555555dULL, 0x555555555555555dULL, }, 76 { 0x5ed097b425ed0983ULL, 0xed097b425ed097bcULL, }, 77 { 0x0000000000000008ULL, 0x0000000000000008ULL, }, 78 { 0x333333333333333cULL, 0x333333333333333cULL, }, /* 32 */ 79 { 0x333333333333333cULL, 0x333333333333333cULL, }, 80 { 0xaaaaaaaaaaaaaab4ULL, 0xaaaaaaaaaaaaaab4ULL, }, 81 { 0x6666666666666670ULL, 0x6666666666666670ULL, }, 82 { 0x5c28f5c28f5c2900ULL, 0x5c28f5c28f5c2900ULL, }, 83 { 0x99999999999999a4ULL, 0x99999999999999a4ULL, }, 84 { 0x16c16c16c16c16ccULL, 0xd27d27d27d27d288ULL, }, 85 { 0xccccccccccccccd8ULL, 0xccccccccccccccd8ULL, }, 86 { 0x99999999999999a5ULL, 0x99999999999999a5ULL, }, /* 40 */ 87 { 0x99999999999999a5ULL, 0x99999999999999a5ULL, }, 88 { 0x7777777777777783ULL, 0x7777777777777783ULL, }, 89 { 0x6666666666666672ULL, 0x6666666666666672ULL, }, 90 { 0xa3d70a3d70a3d716ULL, 0xa3d70a3d70a3d716ULL, }, 91 { 0x333333333333333fULL, 0x333333333333333fULL, }, 92 { 0xd27d27d27d27d289ULL, 0xc16c16c16c16c178ULL, }, 93 { 0x000000000000000cULL, 0x000000000000000cULL, }, 94 { 0x1c71c71c71c71c7eULL, 0xc71c71c71c71c729ULL, }, /* 48 */ 95 { 0x1c71c71c71c71c7eULL, 0xc71c71c71c71c729ULL, }, 96 { 0x2f684bda12f684caULL, 0xf684bda12f684be7ULL, }, 97 { 0x38e38e38e38e38f0ULL, 0x8e38e38e38e38e46ULL, }, 98 { 0xb60b60b60b60b618ULL, 0xc71c71c71c71c72aULL, }, 99 { 0x5555555555555562ULL, 0x5555555555555563ULL, }, 100 { 0x06522c3f35ba7826ULL, 0xa781948b0fcd6eacULL, }, 101 { 0x71c71c71c71c71d4ULL, 0x1c71c71c71c71c80ULL, }, 102 { 0x5555555555555563ULL, 0x5555555555555564ULL, }, /* 56 */ 103 { 0x5555555555555563ULL, 0x5555555555555564ULL, }, 104 { 0x97b425ed097b426dULL, 0x7b425ed097b425fcULL, }, 105 { 0x38e38e38e38e38f2ULL, 0x8e38e38e38e38e48ULL, }, 106 { 0xeeeeeeeeeeeeeefeULL, 0x8888888888888898ULL, }, 107 { 0x1c71c71c71c71c81ULL, 0xc71c71c71c71c72cULL, }, 108 { 0x87e6b74f0329162fULL, 0x3c0ca4587e6b7500ULL, }, 109 { 0x0000000000000010ULL, 0x0000000000000010ULL, }, 110 { 0xad45be6961639010ULL, 0x3297fdea749880a0ULL, }, /* 64 */ 111 { 0x9ced640a487afa10ULL, 0xeaa90809e3b1a470ULL, }, 112 { 0xa5b377aa0caf5a10ULL, 0x95c9a7903bd12160ULL, }, 113 { 0xa194ffe4fb27d390ULL, 0x17e6ccd3c9a1c0e0ULL, }, 114 { 0x913ca585e23f3d90ULL, 0xcff7d6f338bae4b0ULL, }, 115 { 0xc8ead0bee02cadd0ULL, 0x381c4d6a83a94cc0ULL, }, 116 { 0x33b60e279e9989d0ULL, 0xe7f71f9b97ee3470ULL, }, 117 { 0x217580abbfdd3e40ULL, 0x6779436687bc89f0ULL, }, 118 { 0x2a3b944b84119e40ULL, 0x1299e2ecdfdc06e0ULL, }, /* 72 */ 119 { 0x9506d1b4427e7a40ULL, 0xc274b51df420ee90ULL, }, 120 { 0x1b2bb7962782ba40ULL, 0x9bf62dc42637b820ULL, }, 121 { 0x91d16316b1663b40ULL, 0x3cf7c824fb128ca0ULL, }, 122 { 0x8db2eb519fdeb4c0ULL, 0xbf14ed6888e32c20ULL, }, 123 { 0x7b725dd5c1226930ULL, 0x3e97113378b181a0ULL, }, 124 { 0xf21809564b05ea30ULL, 0xdf98ab944d8c5620ULL, }, 125 { 0x3dcc402bfcefb9f4ULL, 0xf26a7a4530ab3a20ULL, }, 126 { 0x81a8956a21043af4ULL, 0xe63ec4a9de07f3a0ULL, }, /* 80 */ 127 { 0x14acc7eab115be94ULL, 0xa72fae300e450520ULL, }, 128 { 0x4c5c3900181b6494ULL, 0xc26796e561c70ba0ULL, }, 129 { 0x513451003792b1acULL, 0x5acad191d5b18fa0ULL, }, 130 { 0x0daff27cb51538acULL, 0x31375ce2aea24b20ULL, }, 131 { 0xbb9ebee52390b20cULL, 0xd8cfb350af547ea0ULL, }, 132 { 0x4df25269204a3c0cULL, 0x07b9241bbd1b8320ULL, }, 133 { 0x39b3c4d066371fb4ULL, 0x2a4dc00c264fb720ULL, }, 134 { 0xf9aee458846dd0b4ULL, 0x79d838b37c524ca0ULL, }, /* 88 */ 135 { 0x115f9e7f00744254ULL, 0x46ec87fe3540fa20ULL, }, 136 { 0xb01458f6b0850854ULL, 0xde82246a25db24a0ULL, }, 137 { 0xc18097bf5a7bb9ecULL, 0x4155f0da566748a0ULL, }, 138 { 0x70c7391b1a7d90ecULL, 0x0400deec0a0cb020ULL, }, 139 { 0xf7a41980bd958c4cULL, 0xedfeb14ff6d44fa0ULL, }, 140 { 0x7906f19718fcf64cULL, 0x29e471752ecca820ULL, }, 141 { 0xb6393967140b1974ULL, 0xbd0ed4c39361fc20ULL, }, 142 { 0x74ecb57da4acfa74ULL, 0x36ea3f3dbcafcda0ULL, }, /* 96 */ 143 { 0x5b14aa5e3f7c1b74ULL, 0xeb031f17fe2b7120ULL, }, 144 { 0x0468573ef6087c74ULL, 0xe8ef35d2e05abea0ULL, }, 145 { 0xd69cf5cf0de21d74ULL, 0x39f569701e89ae20ULL, }, 146 { 0xf233f7a10f743514ULL, 0xf574fc00c1b755a0ULL, }, 147 { 0x873c421a5ed469b4ULL, 0x96f393305dfcdf20ULL, }, 148 { 0x17e80b0449fea354ULL, 0x2f05ddb06b40c2a0ULL, }, 149 { 0x0741f67f982609f4ULL, 0x9c23f2dbc2b79820ULL, }, 150 { 0x530275e3b2de7ff4ULL, 0xc6904e7f6f6c1aa0ULL, }, /* 104 */ 151 { 0xf8214644bbe3f5f4ULL, 0xe44a0de01c974f20ULL, }, 152 { 0xb59c90c0a8b66bf4ULL, 0x9abcf7a8e1391da0ULL, }, 153 { 0xb67d543caed5e1f4ULL, 0x4ce8f72994d78e20ULL, }, 154 { 0xcee67f5e9d2e224cULL, 0xba31bdf2ab48a220ULL, }, 155 { 0x87acb43db40fad74ULL, 0x8a259794c40e3620ULL, }, 156 { 0x45c27495332aeeccULL, 0xe81c4208ecf84a20ULL, }, 157 { 0x50a99b794e1bc8f4ULL, 0x17cdf4c275d6de20ULL, }, 158 }; 159 160 reset_msa_registers(); 161 162 gettimeofday(&start, NULL); 163 164 for (i = 0; i < PATTERN_INPUTS_SHORT_COUNT; i++) { 165 for (j = 0; j < PATTERN_INPUTS_SHORT_COUNT; j++) { 166 do_msa_MADDV_D(b128_pattern[i], b128_pattern[j], 167 b128_result[PATTERN_INPUTS_SHORT_COUNT * i + j]); 168 } 169 } 170 171 for (i = 0; i < RANDOM_INPUTS_SHORT_COUNT; i++) { 172 for (j = 0; j < RANDOM_INPUTS_SHORT_COUNT; j++) { 173 do_msa_MADDV_D(b128_random[i], b128_random[j], 174 b128_result[((PATTERN_INPUTS_SHORT_COUNT) * 175 (PATTERN_INPUTS_SHORT_COUNT)) + 176 RANDOM_INPUTS_SHORT_COUNT * i + j]); 177 } 178 } 179 180 for (i = 0; i < RANDOM_INPUTS_SHORT_COUNT; i++) { 181 for (j = 0; j < RANDOM_INPUTS_SHORT_COUNT; j++) { 182 do_msa_MADDV_D__DDT(b128_random[i], b128_random[j], 183 b128_result[ 184 ((PATTERN_INPUTS_SHORT_COUNT) * 185 (PATTERN_INPUTS_SHORT_COUNT)) + 186 ((RANDOM_INPUTS_SHORT_COUNT) * 187 (RANDOM_INPUTS_SHORT_COUNT)) + 188 RANDOM_INPUTS_SHORT_COUNT * i + j]); 189 } 190 } 191 192 for (i = 0; i < RANDOM_INPUTS_SHORT_COUNT; i++) { 193 for (j = 0; j < RANDOM_INPUTS_SHORT_COUNT; j++) { 194 do_msa_MADDV_D__DSD(b128_random[i], b128_random[j], 195 b128_result[ 196 ((PATTERN_INPUTS_SHORT_COUNT) * 197 (PATTERN_INPUTS_SHORT_COUNT)) + 198 (2 * (RANDOM_INPUTS_SHORT_COUNT) * 199 (RANDOM_INPUTS_SHORT_COUNT)) + 200 RANDOM_INPUTS_SHORT_COUNT * i + j]); 201 } 202 } 203 204 gettimeofday(&end, NULL); 205 206 elapsed_time = (end.tv_sec - start.tv_sec) * 1000.0; 207 elapsed_time += (end.tv_usec - start.tv_usec) / 1000.0; 208 209 ret = check_results_128(isa_ase_name, group_name, instruction_name, 210 TEST_COUNT_TOTAL, elapsed_time, 211 &b128_result[0][0], &b128_expect[0][0]); 212 213 return ret; 214}