11d336c87SAleksandar Markovic /* 21d336c87SAleksandar Markovic * Test program for MSA instruction BNEG.B 31d336c87SAleksandar Markovic * 41d336c87SAleksandar Markovic * Copyright (C) 2019 Wave Computing, Inc. 51d336c87SAleksandar Markovic * Copyright (C) 2019 Aleksandar Markovic <amarkovic@wavecomp.com> 61d336c87SAleksandar Markovic * 71d336c87SAleksandar Markovic * This program is free software: you can redistribute it and/or modify 81d336c87SAleksandar Markovic * it under the terms of the GNU General Public License as published by 91d336c87SAleksandar Markovic * the Free Software Foundation, either version 2 of the License, or 101d336c87SAleksandar Markovic * (at your option) any later version. 111d336c87SAleksandar Markovic * 121d336c87SAleksandar Markovic * This program is distributed in the hope that it will be useful, 131d336c87SAleksandar Markovic * but WITHOUT ANY WARRANTY; without even the implied warranty of 141d336c87SAleksandar Markovic * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 151d336c87SAleksandar Markovic * GNU General Public License for more details. 161d336c87SAleksandar Markovic * 171d336c87SAleksandar Markovic * You should have received a copy of the GNU General Public License 181d336c87SAleksandar Markovic * along with this program. If not, see <https://www.gnu.org/licenses/>. 191d336c87SAleksandar Markovic * 201d336c87SAleksandar Markovic */ 211d336c87SAleksandar Markovic 221d336c87SAleksandar Markovic #include <sys/time.h> 231d336c87SAleksandar Markovic #include <stdint.h> 241d336c87SAleksandar Markovic 251d336c87SAleksandar Markovic #include "../../../../include/wrappers_msa.h" 261d336c87SAleksandar Markovic #include "../../../../include/test_inputs_128.h" 271d336c87SAleksandar Markovic #include "../../../../include/test_utils_128.h" 281d336c87SAleksandar Markovic 291d336c87SAleksandar Markovic #define TEST_COUNT_TOTAL ( \ 301d336c87SAleksandar Markovic (PATTERN_INPUTS_SHORT_COUNT) * (PATTERN_INPUTS_SHORT_COUNT) + \ 311d336c87SAleksandar Markovic (RANDOM_INPUTS_SHORT_COUNT) * (RANDOM_INPUTS_SHORT_COUNT)) 321d336c87SAleksandar Markovic 331d336c87SAleksandar Markovic 341d336c87SAleksandar Markovic int32_t main(void) 351d336c87SAleksandar Markovic { 36*8e6fe6b8SAleksandar Markovic char *isa_ase_name = "MSA"; 37*8e6fe6b8SAleksandar Markovic char *group_name = "Bit Set"; 381d336c87SAleksandar Markovic char *instruction_name = "BNEG.B"; 391d336c87SAleksandar Markovic int32_t ret; 401d336c87SAleksandar Markovic uint32_t i, j; 411d336c87SAleksandar Markovic struct timeval start, end; 421d336c87SAleksandar Markovic double elapsed_time; 431d336c87SAleksandar Markovic 441d336c87SAleksandar Markovic uint64_t b128_result[TEST_COUNT_TOTAL][2]; 451d336c87SAleksandar Markovic uint64_t b128_expect[TEST_COUNT_TOTAL][2] = { 461d336c87SAleksandar Markovic { 0x7f7f7f7f7f7f7f7fULL, 0x7f7f7f7f7f7f7f7fULL, }, /* 0 */ 471d336c87SAleksandar Markovic { 0xfefefefefefefefeULL, 0xfefefefefefefefeULL, }, 481d336c87SAleksandar Markovic { 0xfbfbfbfbfbfbfbfbULL, 0xfbfbfbfbfbfbfbfbULL, }, 491d336c87SAleksandar Markovic { 0xdfdfdfdfdfdfdfdfULL, 0xdfdfdfdfdfdfdfdfULL, }, 501d336c87SAleksandar Markovic { 0xefefefefefefefefULL, 0xefefefefefefefefULL, }, 511d336c87SAleksandar Markovic { 0xf7f7f7f7f7f7f7f7ULL, 0xf7f7f7f7f7f7f7f7ULL, }, 521d336c87SAleksandar Markovic { 0xf7bffef7bffef7bfULL, 0xfef7bffef7bffef7ULL, }, 531d336c87SAleksandar Markovic { 0xeffd7feffd7feffdULL, 0x7feffd7feffd7fefULL, }, 541d336c87SAleksandar Markovic { 0x8080808080808080ULL, 0x8080808080808080ULL, }, /* 8 */ 551d336c87SAleksandar Markovic { 0x0101010101010101ULL, 0x0101010101010101ULL, }, 561d336c87SAleksandar Markovic { 0x0404040404040404ULL, 0x0404040404040404ULL, }, 571d336c87SAleksandar Markovic { 0x2020202020202020ULL, 0x2020202020202020ULL, }, 581d336c87SAleksandar Markovic { 0x1010101010101010ULL, 0x1010101010101010ULL, }, 591d336c87SAleksandar Markovic { 0x0808080808080808ULL, 0x0808080808080808ULL, }, 601d336c87SAleksandar Markovic { 0x0840010840010840ULL, 0x0108400108400108ULL, }, 611d336c87SAleksandar Markovic { 0x1002801002801002ULL, 0x8010028010028010ULL, }, 621d336c87SAleksandar Markovic { 0x2a2a2a2a2a2a2a2aULL, 0x2a2a2a2a2a2a2a2aULL, }, /* 16 */ 631d336c87SAleksandar Markovic { 0xababababababababULL, 0xababababababababULL, }, 641d336c87SAleksandar Markovic { 0xaeaeaeaeaeaeaeaeULL, 0xaeaeaeaeaeaeaeaeULL, }, 651d336c87SAleksandar Markovic { 0x8a8a8a8a8a8a8a8aULL, 0x8a8a8a8a8a8a8a8aULL, }, 661d336c87SAleksandar Markovic { 0xbabababababababaULL, 0xbabababababababaULL, }, 671d336c87SAleksandar Markovic { 0xa2a2a2a2a2a2a2a2ULL, 0xa2a2a2a2a2a2a2a2ULL, }, 681d336c87SAleksandar Markovic { 0xa2eaaba2eaaba2eaULL, 0xaba2eaaba2eaaba2ULL, }, 691d336c87SAleksandar Markovic { 0xbaa82abaa82abaa8ULL, 0x2abaa82abaa82abaULL, }, 701d336c87SAleksandar Markovic { 0xd5d5d5d5d5d5d5d5ULL, 0xd5d5d5d5d5d5d5d5ULL, }, /* 24 */ 711d336c87SAleksandar Markovic { 0x5454545454545454ULL, 0x5454545454545454ULL, }, 721d336c87SAleksandar Markovic { 0x5151515151515151ULL, 0x5151515151515151ULL, }, 731d336c87SAleksandar Markovic { 0x7575757575757575ULL, 0x7575757575757575ULL, }, 741d336c87SAleksandar Markovic { 0x4545454545454545ULL, 0x4545454545454545ULL, }, 751d336c87SAleksandar Markovic { 0x5d5d5d5d5d5d5d5dULL, 0x5d5d5d5d5d5d5d5dULL, }, 761d336c87SAleksandar Markovic { 0x5d15545d15545d15ULL, 0x545d15545d15545dULL, }, 771d336c87SAleksandar Markovic { 0x4557d54557d54557ULL, 0xd54557d54557d545ULL, }, 781d336c87SAleksandar Markovic { 0x4c4c4c4c4c4c4c4cULL, 0x4c4c4c4c4c4c4c4cULL, }, /* 32 */ 791d336c87SAleksandar Markovic { 0xcdcdcdcdcdcdcdcdULL, 0xcdcdcdcdcdcdcdcdULL, }, 801d336c87SAleksandar Markovic { 0xc8c8c8c8c8c8c8c8ULL, 0xc8c8c8c8c8c8c8c8ULL, }, 811d336c87SAleksandar Markovic { 0xececececececececULL, 0xececececececececULL, }, 821d336c87SAleksandar Markovic { 0xdcdcdcdcdcdcdcdcULL, 0xdcdcdcdcdcdcdcdcULL, }, 831d336c87SAleksandar Markovic { 0xc4c4c4c4c4c4c4c4ULL, 0xc4c4c4c4c4c4c4c4ULL, }, 841d336c87SAleksandar Markovic { 0xc48ccdc48ccdc48cULL, 0xcdc48ccdc48ccdc4ULL, }, 851d336c87SAleksandar Markovic { 0xdcce4cdcce4cdcceULL, 0x4cdcce4cdcce4cdcULL, }, 861d336c87SAleksandar Markovic { 0xb3b3b3b3b3b3b3b3ULL, 0xb3b3b3b3b3b3b3b3ULL, }, /* 40 */ 871d336c87SAleksandar Markovic { 0x3232323232323232ULL, 0x3232323232323232ULL, }, 881d336c87SAleksandar Markovic { 0x3737373737373737ULL, 0x3737373737373737ULL, }, 891d336c87SAleksandar Markovic { 0x1313131313131313ULL, 0x1313131313131313ULL, }, 901d336c87SAleksandar Markovic { 0x2323232323232323ULL, 0x2323232323232323ULL, }, 911d336c87SAleksandar Markovic { 0x3b3b3b3b3b3b3b3bULL, 0x3b3b3b3b3b3b3b3bULL, }, 921d336c87SAleksandar Markovic { 0x3b73323b73323b73ULL, 0x323b73323b73323bULL, }, 931d336c87SAleksandar Markovic { 0x2331b32331b32331ULL, 0xb32331b32331b323ULL, }, 941d336c87SAleksandar Markovic { 0x630eb8630eb8630eULL, 0xb8630eb8630eb863ULL, }, /* 48 */ 951d336c87SAleksandar Markovic { 0xe28f39e28f39e28fULL, 0x39e28f39e28f39e2ULL, }, 961d336c87SAleksandar Markovic { 0xe78a3ce78a3ce78aULL, 0x3ce78a3ce78a3ce7ULL, }, 971d336c87SAleksandar Markovic { 0xc3ae18c3ae18c3aeULL, 0x18c3ae18c3ae18c3ULL, }, 981d336c87SAleksandar Markovic { 0xf39e28f39e28f39eULL, 0x28f39e28f39e28f3ULL, }, 991d336c87SAleksandar Markovic { 0xeb8630eb8630eb86ULL, 0x30eb8630eb8630ebULL, }, 1001d336c87SAleksandar Markovic { 0xebce39ebce39ebceULL, 0x39ebce39ebce39ebULL, }, 1011d336c87SAleksandar Markovic { 0xf38cb8f38cb8f38cULL, 0xb8f38cb8f38cb8f3ULL, }, 1021d336c87SAleksandar Markovic { 0x9cf1479cf1479cf1ULL, 0x479cf1479cf1479cULL, }, /* 56 */ 1031d336c87SAleksandar Markovic { 0x1d70c61d70c61d70ULL, 0xc61d70c61d70c61dULL, }, 1041d336c87SAleksandar Markovic { 0x1875c31875c31875ULL, 0xc31875c31875c318ULL, }, 1051d336c87SAleksandar Markovic { 0x3c51e73c51e73c51ULL, 0xe73c51e73c51e73cULL, }, 1061d336c87SAleksandar Markovic { 0x0c61d70c61d70c61ULL, 0xd70c61d70c61d70cULL, }, 1071d336c87SAleksandar Markovic { 0x1479cf1479cf1479ULL, 0xcf1479cf1479cf14ULL, }, 1081d336c87SAleksandar Markovic { 0x1431c61431c61431ULL, 0xc61431c61431c614ULL, }, 1091d336c87SAleksandar Markovic { 0x0c73470c73470c73ULL, 0x470c73470c73470cULL, }, 1101d336c87SAleksandar Markovic { 0x896ea6dc29667541ULL, 0x43e7031ebe73b11cULL, }, /* 64 */ 1111d336c87SAleksandar Markovic { 0x802ae7c4086ad541ULL, 0x4fe7035adefbb41cULL, }, 1121d336c87SAleksandar Markovic { 0x986ea6c82ae25d41ULL, 0xcb664bdef673901cULL, }, 1131d336c87SAleksandar Markovic { 0x89eaa6ec68605100ULL, 0x6b650a5ffc7fb40dULL, }, 1141d336c87SAleksandar Markovic { 0xfaba40734c97e709ULL, 0x1a77b35a553753ecULL, }, 1151d336c87SAleksandar Markovic { 0xf3fe016b6d9b4709ULL, 0x1677b31e35bf56ecULL, }, 1161d336c87SAleksandar Markovic { 0xebba40674f13cf09ULL, 0x92f6fb9a1d3772ecULL, }, 1171d336c87SAleksandar Markovic { 0xfa3e40430d91c348ULL, 0x32f5ba1b173b56fdULL, }, 1181d336c87SAleksandar Markovic { 0xad5eeebab8cbab81ULL, 0x2f58cebfeb232404ULL, }, /* 72 */ 1191d336c87SAleksandar Markovic { 0xa41aafa299c70b81ULL, 0x2358cefb8bab2104ULL, }, 1201d336c87SAleksandar Markovic { 0xbc5eeeaebb4f8381ULL, 0xa7d9867fa3230504ULL, }, 1211d336c87SAleksandar Markovic { 0xaddaee8af9cd8fc0ULL, 0x07dac7fea92f2115ULL, }, 1221d336c87SAleksandar Markovic { 0x714b565d5f35c24fULL, 0x85718098e94ae3b0ULL, }, 1231d336c87SAleksandar Markovic { 0x780f17457e39624fULL, 0x897180dc89c2e6b0ULL, }, 1241d336c87SAleksandar Markovic { 0x604b56495cb1ea4fULL, 0x0df0c858a14ac2b0ULL, }, 1251d336c87SAleksandar Markovic { 0x71cf566d1e33e60eULL, 0xadf389d9ab46e6a1ULL, }, 1261d336c87SAleksandar Markovic }; 1271d336c87SAleksandar Markovic 128ca693d1cSAleksandar Markovic reset_msa_registers(); 129ca693d1cSAleksandar Markovic 1301d336c87SAleksandar Markovic gettimeofday(&start, NULL); 1311d336c87SAleksandar Markovic 1321d336c87SAleksandar Markovic for (i = 0; i < PATTERN_INPUTS_SHORT_COUNT; i++) { 1331d336c87SAleksandar Markovic for (j = 0; j < PATTERN_INPUTS_SHORT_COUNT; j++) { 1341d336c87SAleksandar Markovic do_msa_BNEG_B(b128_pattern[i], b128_pattern[j], 1351d336c87SAleksandar Markovic b128_result[PATTERN_INPUTS_SHORT_COUNT * i + j]); 1361d336c87SAleksandar Markovic } 1371d336c87SAleksandar Markovic } 1381d336c87SAleksandar Markovic 1391d336c87SAleksandar Markovic for (i = 0; i < RANDOM_INPUTS_SHORT_COUNT; i++) { 1401d336c87SAleksandar Markovic for (j = 0; j < RANDOM_INPUTS_SHORT_COUNT; j++) { 1411d336c87SAleksandar Markovic do_msa_BNEG_B(b128_random[i], b128_random[j], 1421d336c87SAleksandar Markovic b128_result[((PATTERN_INPUTS_SHORT_COUNT) * 1431d336c87SAleksandar Markovic (PATTERN_INPUTS_SHORT_COUNT)) + 1441d336c87SAleksandar Markovic RANDOM_INPUTS_SHORT_COUNT * i + j]); 1451d336c87SAleksandar Markovic } 1461d336c87SAleksandar Markovic } 1471d336c87SAleksandar Markovic 1481d336c87SAleksandar Markovic gettimeofday(&end, NULL); 1491d336c87SAleksandar Markovic 1501d336c87SAleksandar Markovic elapsed_time = (end.tv_sec - start.tv_sec) * 1000.0; 1511d336c87SAleksandar Markovic elapsed_time += (end.tv_usec - start.tv_usec) / 1000.0; 1521d336c87SAleksandar Markovic 153*8e6fe6b8SAleksandar Markovic ret = check_results_128(isa_ase_name, group_name, instruction_name, 154*8e6fe6b8SAleksandar Markovic TEST_COUNT_TOTAL, elapsed_time, 1551d336c87SAleksandar Markovic &b128_result[0][0], &b128_expect[0][0]); 1561d336c87SAleksandar Markovic 1571d336c87SAleksandar Markovic return ret; 1581d336c87SAleksandar Markovic } 159