test_msa_msubv_w.c (10661B)
1/* 2 * Test program for MSA instruction MSUBV.W 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 = "MSUBV.W"; 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 { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, /* 0 */ 47 { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, 48 { 0xaaaaaaa9aaaaaaa9ULL, 0xaaaaaaa9aaaaaaa9ULL, }, 49 { 0xfffffffefffffffeULL, 0xfffffffefffffffeULL, }, 50 { 0xcccccccacccccccaULL, 0xcccccccacccccccaULL, }, 51 { 0xfffffffdfffffffdULL, 0xfffffffdfffffffdULL, }, 52 { 0xe38e38e08e38e38bULL, 0x38e38e35e38e38e0ULL, }, 53 { 0xfffffffcfffffffcULL, 0xfffffffcfffffffcULL, }, 54 { 0xfffffffcfffffffcULL, 0xfffffffcfffffffcULL, }, /* 8 */ 55 { 0xfffffffcfffffffcULL, 0xfffffffcfffffffcULL, }, 56 { 0xfffffffcfffffffcULL, 0xfffffffcfffffffcULL, }, 57 { 0xfffffffcfffffffcULL, 0xfffffffcfffffffcULL, }, 58 { 0xfffffffcfffffffcULL, 0xfffffffcfffffffcULL, }, 59 { 0xfffffffcfffffffcULL, 0xfffffffcfffffffcULL, }, 60 { 0xfffffffcfffffffcULL, 0xfffffffcfffffffcULL, }, 61 { 0xfffffffcfffffffcULL, 0xfffffffcfffffffcULL, }, 62 { 0xaaaaaaa6aaaaaaa6ULL, 0xaaaaaaa6aaaaaaa6ULL, }, /* 16 */ 63 { 0xaaaaaaa6aaaaaaa6ULL, 0xaaaaaaa6aaaaaaa6ULL, }, 64 { 0xc71c71c2c71c71c2ULL, 0xc71c71c2c71c71c2ULL, }, 65 { 0x5555555055555550ULL, 0x5555555055555550ULL, }, 66 { 0xddddddd8ddddddd8ULL, 0xddddddd8ddddddd8ULL, }, 67 { 0xfffffffafffffffaULL, 0xfffffffafffffffaULL, }, 68 { 0xed097b3c5ed097aeULL, 0x7b425ecaed097b3cULL, }, 69 { 0xaaaaaaa4aaaaaaa4ULL, 0xaaaaaaa4aaaaaaa4ULL, }, 70 { 0xfffffff9fffffff9ULL, 0xfffffff9fffffff9ULL, }, /* 24 */ 71 { 0xfffffff9fffffff9ULL, 0xfffffff9fffffff9ULL, }, 72 { 0x8e38e3878e38e387ULL, 0x8e38e3878e38e387ULL, }, 73 { 0x5555554e5555554eULL, 0x5555554e5555554eULL, }, 74 { 0x9999999299999992ULL, 0x9999999299999992ULL, }, 75 { 0xaaaaaaa3aaaaaaa3ULL, 0xaaaaaaa3aaaaaaa3ULL, }, 76 { 0xa12f6844da12f67dULL, 0x684bda0ba12f6844ULL, }, 77 { 0xfffffff8fffffff8ULL, 0xfffffff8fffffff8ULL, }, 78 { 0xccccccc4ccccccc4ULL, 0xccccccc4ccccccc4ULL, }, /* 32 */ 79 { 0xccccccc4ccccccc4ULL, 0xccccccc4ccccccc4ULL, }, 80 { 0x5555554c5555554cULL, 0x5555554c5555554cULL, }, 81 { 0x9999999099999990ULL, 0x9999999099999990ULL, }, 82 { 0x70a3d70070a3d700ULL, 0x70a3d70070a3d700ULL, }, 83 { 0x6666665c6666665cULL, 0x6666665c6666665cULL, }, 84 { 0x82d82d783e93e934ULL, 0xc71c71bc82d82d78ULL, }, 85 { 0x3333332833333328ULL, 0x3333332833333328ULL, }, 86 { 0x6666665b6666665bULL, 0x6666665b6666665bULL, }, /* 40 */ 87 { 0x6666665b6666665bULL, 0x6666665b6666665bULL, }, 88 { 0x8888887d8888887dULL, 0x8888887d8888887dULL, }, 89 { 0x9999998e9999998eULL, 0x9999998e9999998eULL, }, 90 { 0x8f5c28ea8f5c28eaULL, 0x8f5c28ea8f5c28eaULL, }, 91 { 0xccccccc1ccccccc1ULL, 0xccccccc1ccccccc1ULL, }, 92 { 0x93e93e8882d82d77ULL, 0xa4fa4f9993e93e88ULL, }, 93 { 0xfffffff4fffffff4ULL, 0xfffffff4fffffff4ULL, }, 94 { 0xe38e38d78e38e382ULL, 0x38e38e2ce38e38d7ULL, }, /* 48 */ 95 { 0xe38e38d78e38e382ULL, 0x38e38e2ce38e38d7ULL, }, 96 { 0xd097b419ed097b36ULL, 0xb425ecfcd097b419ULL, }, 97 { 0xc71c71ba1c71c710ULL, 0x71c71c64c71c71baULL, }, 98 { 0xe38e38d6f49f49e8ULL, 0xd27d27c4e38e38d6ULL, }, 99 { 0xaaaaaa9daaaaaa9eULL, 0xaaaaaa9caaaaaa9dULL, }, 100 { 0xf0329154ca4587daULL, 0xa4587e5cf0329154ULL, }, 101 { 0x8e38e38038e38e2cULL, 0xe38e38d48e38e380ULL, }, 102 { 0xaaaaaa9caaaaaa9dULL, 0xaaaaaa9baaaaaa9cULL, }, /* 56 */ 103 { 0xaaaaaa9caaaaaa9dULL, 0xaaaaaa9baaaaaa9cULL, }, 104 { 0x684bda04f684bd93ULL, 0xda12f675684bda04ULL, }, 105 { 0xc71c71b81c71c70eULL, 0x71c71c62c71c71b8ULL, }, 106 { 0x7777776811111102ULL, 0xddddddce77777768ULL, }, 107 { 0xe38e38d48e38e37fULL, 0x38e38e29e38e38d4ULL, }, 108 { 0x81948b00fcd6e9d1ULL, 0x781948a181948b00ULL, }, 109 { 0xfffffff0fffffff0ULL, 0xfffffff0fffffff0ULL, }, 110 { 0x4efccd609e9c6ff0ULL, 0xc5dac96c8b677f60ULL, }, /* 64 */ 111 { 0x3e3d8c7cb78505f0ULL, 0x4463f7e01c4e5b90ULL, }, 112 { 0xcaa9a104f350a5f0ULL, 0x8ca4f13ec42edea0ULL, }, 113 { 0x19b8ada804d82c70ULL, 0xb62b69ee365e3f20ULL, }, 114 { 0x08f96cc41dc0c270ULL, 0x34b49862c7451b50ULL, }, 115 { 0x5405467b1fd35230ULL, 0xf7c999be7c56b340ULL, }, 116 { 0x5cc7babd61667630ULL, 0xa4601ed86811cb90ULL, }, 117 { 0xe20c1af64022c1c0ULL, 0x927a70e878437610ULL, }, 118 { 0x6e782f7e7bee61c0ULL, 0xdabb6a462023f920ULL, }, /* 72 */ 119 { 0x773aa3c0bd8185c0ULL, 0x8751ef600bdf1170ULL, }, 120 { 0xc0871adcd87d45c0ULL, 0x6c527d5fd9c847e0ULL, }, 121 { 0xd7c7f5ba4e99c4c0ULL, 0xdaa41e3704ed7360ULL, }, 122 { 0x26d7025e60214b40ULL, 0x042a96e7771cd3e0ULL, }, 123 { 0xac1b62973edd96d0ULL, 0xf244e8f7874e7e60ULL, }, 124 { 0xc35c3d75b4fa15d0ULL, 0x609689cfb273a9e0ULL, }, 125 { 0x9de4ea4c0310460cULL, 0x80c0538fcf54c5e0ULL, }, 126 { 0xbd81edbc2724c70cULL, 0x7301800d7cb17f60ULL, }, /* 80 */ 127 { 0xaebafe086f603aacULL, 0x35c5ffbbaa8b5ce0ULL, }, 128 { 0xdf14dcb8c25380acULL, 0x3ef9a276f99bbb60ULL, }, 129 { 0x5e0ea9600c5e7444ULL, 0x8ef3dee6ce1bdf60ULL, }, 130 { 0x1c7370e0761ecf44ULL, 0x864a2472681b66e0ULL, }, 131 { 0xb58eca4059fe7924ULL, 0x8c252ade750e6260ULL, }, 132 { 0xfcc4fbc036df5b24ULL, 0x36a7c3bc9596d2e0ULL, }, 133 { 0x57a2c300a677ce2cULL, 0x2922bd1cb36946e0ULL, }, 134 { 0x88bd5f007437a72cULL, 0x45fd18d49c1ff460ULL, }, /* 88 */ 135 { 0x2581a200554339ccULL, 0x6c99b74cacc4a5e0ULL, }, 136 { 0x2d500e000b508fccULL, 0x1f975a9844ce5060ULL, }, 137 { 0x5907d8000bc6a7a4ULL, 0x0eaa2a5808275460ULL, }, 138 { 0xeab7b80057ab4aa4ULL, 0x8af4d608d22d5fe0ULL, }, 139 { 0x95ab9000431f7984ULL, 0x840741386cad3f60ULL, }, 140 { 0xf5ddf000f6ac0b84ULL, 0xd51bfa701fdb6be0ULL, }, 141 { 0xdf7cc0003fd2014cULL, 0xb5052bf0d1bc3fe0ULL, }, 142 { 0x3393c00031cb724cULL, 0x06abb9d0a05f4160ULL, }, /* 96 */ 143 { 0xdb56c00090e3a34cULL, 0x7ff18f70f5d630e0ULL, }, 144 { 0xa1b5c0005faa944cULL, 0x9e0514507291e660ULL, }, 145 { 0xfa60c0002cb0454cULL, 0xc4182ef0d53919e0ULL, }, 146 { 0xa6f680001aac06ecULL, 0x05ca1a90e899e160ULL, }, 147 { 0x15a3000096665b8cULL, 0x0cec37f0504f46e0ULL, }, 148 { 0xb79a0000a4a5ab2cULL, 0x578239900c71c260ULL, }, 149 { 0xb70c000031251dccULL, 0xaa4c30f0a693abe0ULL, }, 150 { 0x01140000f37473ccULL, 0x400dd1e0cc92de60ULL, }, /* 104 */ 151 { 0xb1cc0000f066c9ccULL, 0x8cf683c01cd59ee0ULL, }, 152 { 0xf8540000557c1fccULL, 0x0f82c780ac8ed560ULL, }, 153 { 0xf88c0000103475ccULL, 0xa1f10f00956f49e0ULL, }, 154 { 0x2e7000005c2e79a4ULL, 0xcf94670004e95de0ULL, }, 155 { 0x96c00000be3ea1acULL, 0xdca57f00da6ef1e0ULL, }, 156 { 0xbf00000062838744ULL, 0x368a570027d005e0ULL, }, 157 { 0x4c0000006502488cULL, 0xcc98ef003cdc99e0ULL, }, 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_MSUBV_W(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_MSUBV_W(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_MSUBV_W__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_MSUBV_W__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}