10fdd986aSMateja Marjanovic /* 20fdd986aSMateja Marjanovic * Test program for MSA instruction ADD_A.W 30fdd986aSMateja Marjanovic * 4*dd8d6a2dSAleksandar Markovic * Copyright (C) 2019 RT-RK Computer Based Systems LLC 50fdd986aSMateja Marjanovic * Copyright (C) 2019 Mateja Marjanovic <mateja.marjanovic@rt-rk.com> 60fdd986aSMateja Marjanovic * 70fdd986aSMateja Marjanovic * This program is free software: you can redistribute it and/or modify 80fdd986aSMateja Marjanovic * it under the terms of the GNU General Public License as published by 90fdd986aSMateja Marjanovic * the Free Software Foundation, either version 2 of the License, or 100fdd986aSMateja Marjanovic * (at your option) any later version. 110fdd986aSMateja Marjanovic * 120fdd986aSMateja Marjanovic * This program is distributed in the hope that it will be useful, 130fdd986aSMateja Marjanovic * but WITHOUT ANY WARRANTY; without even the implied warranty of 140fdd986aSMateja Marjanovic * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 150fdd986aSMateja Marjanovic * GNU General Public License for more details. 160fdd986aSMateja Marjanovic * 170fdd986aSMateja Marjanovic * You should have received a copy of the GNU General Public License 180fdd986aSMateja Marjanovic * along with this program. If not, see <https://www.gnu.org/licenses/>. 190fdd986aSMateja Marjanovic * 200fdd986aSMateja Marjanovic */ 210fdd986aSMateja Marjanovic 220fdd986aSMateja Marjanovic #include <sys/time.h> 230fdd986aSMateja Marjanovic #include <stdint.h> 240fdd986aSMateja Marjanovic 250fdd986aSMateja Marjanovic #include "../../../../include/wrappers_msa.h" 260fdd986aSMateja Marjanovic #include "../../../../include/test_inputs.h" 270fdd986aSMateja Marjanovic #include "../../../../include/test_utils.h" 280fdd986aSMateja Marjanovic 290fdd986aSMateja Marjanovic #define TEST_COUNT_TOTAL ( \ 300fdd986aSMateja Marjanovic (PATTERN_INPUTS_SHORT_COUNT) * (PATTERN_INPUTS_SHORT_COUNT) + \ 310fdd986aSMateja Marjanovic (RANDOM_INPUTS_SHORT_COUNT) * (RANDOM_INPUTS_SHORT_COUNT)) 320fdd986aSMateja Marjanovic 330fdd986aSMateja Marjanovic 340fdd986aSMateja Marjanovic int32_t main(void) 350fdd986aSMateja Marjanovic { 360fdd986aSMateja Marjanovic char *instruction_name = "ADD_A.W"; 370fdd986aSMateja Marjanovic int32_t ret; 380fdd986aSMateja Marjanovic uint32_t i, j; 390fdd986aSMateja Marjanovic struct timeval start, end; 400fdd986aSMateja Marjanovic double elapsed_time; 410fdd986aSMateja Marjanovic 420fdd986aSMateja Marjanovic uint64_t b128_result[TEST_COUNT_TOTAL][2]; 430fdd986aSMateja Marjanovic uint64_t b128_expect[TEST_COUNT_TOTAL][2] = { 440fdd986aSMateja Marjanovic { 0x0000000200000002ULL, 0x0000000200000002ULL, }, /* 0 */ 450fdd986aSMateja Marjanovic { 0x0000000100000001ULL, 0x0000000100000001ULL, }, 460fdd986aSMateja Marjanovic { 0x5555555755555557ULL, 0x5555555755555557ULL, }, 470fdd986aSMateja Marjanovic { 0x5555555655555556ULL, 0x5555555655555556ULL, }, 480fdd986aSMateja Marjanovic { 0x3333333533333335ULL, 0x3333333533333335ULL, }, 490fdd986aSMateja Marjanovic { 0x3333333433333334ULL, 0x3333333433333334ULL, }, 500fdd986aSMateja Marjanovic { 0x1c71c71e71c71c73ULL, 0x38e38e391c71c71eULL, }, 510fdd986aSMateja Marjanovic { 0x1c71c71d71c71c72ULL, 0x38e38e3a1c71c71dULL, }, 520fdd986aSMateja Marjanovic { 0x0000000100000001ULL, 0x0000000100000001ULL, }, /* 8 */ 530fdd986aSMateja Marjanovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, 540fdd986aSMateja Marjanovic { 0x5555555655555556ULL, 0x5555555655555556ULL, }, 550fdd986aSMateja Marjanovic { 0x5555555555555555ULL, 0x5555555555555555ULL, }, 560fdd986aSMateja Marjanovic { 0x3333333433333334ULL, 0x3333333433333334ULL, }, 570fdd986aSMateja Marjanovic { 0x3333333333333333ULL, 0x3333333333333333ULL, }, 580fdd986aSMateja Marjanovic { 0x1c71c71d71c71c72ULL, 0x38e38e381c71c71dULL, }, 590fdd986aSMateja Marjanovic { 0x1c71c71c71c71c71ULL, 0x38e38e391c71c71cULL, }, 600fdd986aSMateja Marjanovic { 0x5555555755555557ULL, 0x5555555755555557ULL, }, /* 16 */ 610fdd986aSMateja Marjanovic { 0x5555555655555556ULL, 0x5555555655555556ULL, }, 620fdd986aSMateja Marjanovic { 0xaaaaaaacaaaaaaacULL, 0xaaaaaaacaaaaaaacULL, }, 630fdd986aSMateja Marjanovic { 0xaaaaaaabaaaaaaabULL, 0xaaaaaaabaaaaaaabULL, }, 640fdd986aSMateja Marjanovic { 0x8888888a8888888aULL, 0x8888888a8888888aULL, }, 650fdd986aSMateja Marjanovic { 0x8888888988888889ULL, 0x8888888988888889ULL, }, 660fdd986aSMateja Marjanovic { 0x71c71c73c71c71c8ULL, 0x8e38e38e71c71c73ULL, }, 670fdd986aSMateja Marjanovic { 0x71c71c72c71c71c7ULL, 0x8e38e38f71c71c72ULL, }, 680fdd986aSMateja Marjanovic { 0x5555555655555556ULL, 0x5555555655555556ULL, }, /* 24 */ 690fdd986aSMateja Marjanovic { 0x5555555555555555ULL, 0x5555555555555555ULL, }, 700fdd986aSMateja Marjanovic { 0xaaaaaaabaaaaaaabULL, 0xaaaaaaabaaaaaaabULL, }, 710fdd986aSMateja Marjanovic { 0xaaaaaaaaaaaaaaaaULL, 0xaaaaaaaaaaaaaaaaULL, }, 720fdd986aSMateja Marjanovic { 0x8888888988888889ULL, 0x8888888988888889ULL, }, 730fdd986aSMateja Marjanovic { 0x8888888888888888ULL, 0x8888888888888888ULL, }, 740fdd986aSMateja Marjanovic { 0x71c71c72c71c71c7ULL, 0x8e38e38d71c71c72ULL, }, 750fdd986aSMateja Marjanovic { 0x71c71c71c71c71c6ULL, 0x8e38e38e71c71c71ULL, }, 760fdd986aSMateja Marjanovic { 0x3333333533333335ULL, 0x3333333533333335ULL, }, /* 32 */ 770fdd986aSMateja Marjanovic { 0x3333333433333334ULL, 0x3333333433333334ULL, }, 780fdd986aSMateja Marjanovic { 0x8888888a8888888aULL, 0x8888888a8888888aULL, }, 790fdd986aSMateja Marjanovic { 0x8888888988888889ULL, 0x8888888988888889ULL, }, 800fdd986aSMateja Marjanovic { 0x6666666866666668ULL, 0x6666666866666668ULL, }, 810fdd986aSMateja Marjanovic { 0x6666666766666667ULL, 0x6666666766666667ULL, }, 820fdd986aSMateja Marjanovic { 0x4fa4fa51a4fa4fa6ULL, 0x6c16c16c4fa4fa51ULL, }, 830fdd986aSMateja Marjanovic { 0x4fa4fa50a4fa4fa5ULL, 0x6c16c16d4fa4fa50ULL, }, 840fdd986aSMateja Marjanovic { 0x3333333433333334ULL, 0x3333333433333334ULL, }, /* 40 */ 850fdd986aSMateja Marjanovic { 0x3333333333333333ULL, 0x3333333333333333ULL, }, 860fdd986aSMateja Marjanovic { 0x8888888988888889ULL, 0x8888888988888889ULL, }, 870fdd986aSMateja Marjanovic { 0x8888888888888888ULL, 0x8888888888888888ULL, }, 880fdd986aSMateja Marjanovic { 0x6666666766666667ULL, 0x6666666766666667ULL, }, 890fdd986aSMateja Marjanovic { 0x6666666666666666ULL, 0x6666666666666666ULL, }, 900fdd986aSMateja Marjanovic { 0x4fa4fa50a4fa4fa5ULL, 0x6c16c16b4fa4fa50ULL, }, 910fdd986aSMateja Marjanovic { 0x4fa4fa4fa4fa4fa4ULL, 0x6c16c16c4fa4fa4fULL, }, 920fdd986aSMateja Marjanovic { 0x1c71c71e71c71c73ULL, 0x38e38e391c71c71eULL, }, /* 48 */ 930fdd986aSMateja Marjanovic { 0x1c71c71d71c71c72ULL, 0x38e38e381c71c71dULL, }, 940fdd986aSMateja Marjanovic { 0x71c71c73c71c71c8ULL, 0x8e38e38e71c71c73ULL, }, 950fdd986aSMateja Marjanovic { 0x71c71c72c71c71c7ULL, 0x8e38e38d71c71c72ULL, }, 960fdd986aSMateja Marjanovic { 0x4fa4fa51a4fa4fa6ULL, 0x6c16c16c4fa4fa51ULL, }, 970fdd986aSMateja Marjanovic { 0x4fa4fa50a4fa4fa5ULL, 0x6c16c16b4fa4fa50ULL, }, 980fdd986aSMateja Marjanovic { 0x38e38e3ae38e38e4ULL, 0x71c71c7038e38e3aULL, }, 990fdd986aSMateja Marjanovic { 0x38e38e39e38e38e3ULL, 0x71c71c7138e38e39ULL, }, 1000fdd986aSMateja Marjanovic { 0x1c71c71d71c71c72ULL, 0x38e38e3a1c71c71dULL, }, /* 56 */ 1010fdd986aSMateja Marjanovic { 0x1c71c71c71c71c71ULL, 0x38e38e391c71c71cULL, }, 1020fdd986aSMateja Marjanovic { 0x71c71c72c71c71c7ULL, 0x8e38e38f71c71c72ULL, }, 1030fdd986aSMateja Marjanovic { 0x71c71c71c71c71c6ULL, 0x8e38e38e71c71c71ULL, }, 1040fdd986aSMateja Marjanovic { 0x4fa4fa50a4fa4fa5ULL, 0x6c16c16d4fa4fa50ULL, }, 1050fdd986aSMateja Marjanovic { 0x4fa4fa4fa4fa4fa4ULL, 0x6c16c16c4fa4fa4fULL, }, 1060fdd986aSMateja Marjanovic { 0x38e38e39e38e38e3ULL, 0x71c71c7138e38e39ULL, }, 1070fdd986aSMateja Marjanovic { 0x38e38e38e38e38e2ULL, 0x71c71c7238e38e38ULL, }, 1080fdd986aSMateja Marjanovic { 0xef2a326850c4aa80ULL, 0x96ce16bc03089fe8ULL, }, /* 64 */ 1090fdd986aSMateja Marjanovic { 0x7bd718d175f61c48ULL, 0x5e5ec67816c3a2f0ULL, }, 1100fdd986aSMateja Marjanovic { 0xcb3a6a8a6e92c9c0ULL, 0x733fd25d56592ae0ULL, }, 1110fdd986aSMateja Marjanovic { 0xe7e42f818694378eULL, 0xbd75828658416d54ULL, }, 1120fdd986aSMateja Marjanovic { 0x7bd718d175f61c48ULL, 0x5e5ec67816c3a2f0ULL, }, 1130fdd986aSMateja Marjanovic { 0x0883ff3a9b278e10ULL, 0x25ef76342a7ea5f8ULL, }, 1140fdd986aSMateja Marjanovic { 0x57e750f393c43b88ULL, 0x3ad082196a142de8ULL, }, 1150fdd986aSMateja Marjanovic { 0x749115eaabc5a956ULL, 0x850632426bfc705cULL, }, 1160fdd986aSMateja Marjanovic { 0xcb3a6a8a6e92c9c0ULL, 0x733fd25d56592ae0ULL, }, /* 72 */ 1170fdd986aSMateja Marjanovic { 0x57e750f393c43b88ULL, 0x3ad082196a142de8ULL, }, 1180fdd986aSMateja Marjanovic { 0xa74aa2ac8c60e900ULL, 0x4fb18dfea9a9b5d8ULL, }, 1190fdd986aSMateja Marjanovic { 0xc3f467a3a46256ceULL, 0x99e73e27ab91f84cULL, }, 1200fdd986aSMateja Marjanovic { 0xe7e42f818694378eULL, 0xbd75828658416d54ULL, }, 1210fdd986aSMateja Marjanovic { 0x749115eaabc5a956ULL, 0x850632426bfc705cULL, }, 1220fdd986aSMateja Marjanovic }; 1230fdd986aSMateja Marjanovic 1240fdd986aSMateja Marjanovic gettimeofday(&start, NULL); 1250fdd986aSMateja Marjanovic 1260fdd986aSMateja Marjanovic for (i = 0; i < PATTERN_INPUTS_SHORT_COUNT; i++) { 1270fdd986aSMateja Marjanovic for (j = 0; j < PATTERN_INPUTS_SHORT_COUNT; j++) { 1280fdd986aSMateja Marjanovic do_msa_ADD_A_W(b128_pattern[i], b128_pattern[j], 1290fdd986aSMateja Marjanovic b128_result[PATTERN_INPUTS_SHORT_COUNT * i + j]); 1300fdd986aSMateja Marjanovic } 1310fdd986aSMateja Marjanovic } 1320fdd986aSMateja Marjanovic 1330fdd986aSMateja Marjanovic for (i = 0; i < RANDOM_INPUTS_SHORT_COUNT; i++) { 1340fdd986aSMateja Marjanovic for (j = 0; j < RANDOM_INPUTS_SHORT_COUNT; j++) { 1350fdd986aSMateja Marjanovic do_msa_ADD_A_W(b128_random[i], b128_random[j], 1360fdd986aSMateja Marjanovic b128_result[((PATTERN_INPUTS_SHORT_COUNT) * 1370fdd986aSMateja Marjanovic (PATTERN_INPUTS_SHORT_COUNT)) + 1380fdd986aSMateja Marjanovic RANDOM_INPUTS_SHORT_COUNT * i + j]); 1390fdd986aSMateja Marjanovic } 1400fdd986aSMateja Marjanovic } 1410fdd986aSMateja Marjanovic 1420fdd986aSMateja Marjanovic gettimeofday(&end, NULL); 1430fdd986aSMateja Marjanovic 1440fdd986aSMateja Marjanovic elapsed_time = (end.tv_sec - start.tv_sec) * 1000.0; 1450fdd986aSMateja Marjanovic elapsed_time += (end.tv_usec - start.tv_usec) / 1000.0; 1460fdd986aSMateja Marjanovic 1470fdd986aSMateja Marjanovic ret = check_results(instruction_name, TEST_COUNT_TOTAL, elapsed_time, 1480fdd986aSMateja Marjanovic &b128_result[0][0], &b128_expect[0][0]); 1490fdd986aSMateja Marjanovic 1500fdd986aSMateja Marjanovic return ret; 1510fdd986aSMateja Marjanovic } 152