10fdd986aSMateja Marjanovic /* 20fdd986aSMateja Marjanovic * Test program for MSA instruction HADD_S.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 = "HADD_S.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 { 0xfffffffefffffffeULL, 0xfffffffefffffffeULL, }, /* 0 */ 450fdd986aSMateja Marjanovic { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, 460fdd986aSMateja Marjanovic { 0xffffaaa9ffffaaa9ULL, 0xffffaaa9ffffaaa9ULL, }, 470fdd986aSMateja Marjanovic { 0x0000555400005554ULL, 0x0000555400005554ULL, }, 480fdd986aSMateja Marjanovic { 0xffffcccbffffcccbULL, 0xffffcccbffffcccbULL, }, 490fdd986aSMateja Marjanovic { 0x0000333200003332ULL, 0x0000333200003332ULL, }, 500fdd986aSMateja Marjanovic { 0x000038e2ffffe38dULL, 0xffff8e37000038e2ULL, }, 510fdd986aSMateja Marjanovic { 0xffffc71b00001c70ULL, 0x000071c6ffffc71bULL, }, 520fdd986aSMateja Marjanovic { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, /* 8 */ 530fdd986aSMateja Marjanovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, 540fdd986aSMateja Marjanovic { 0xffffaaaaffffaaaaULL, 0xffffaaaaffffaaaaULL, }, 550fdd986aSMateja Marjanovic { 0x0000555500005555ULL, 0x0000555500005555ULL, }, 560fdd986aSMateja Marjanovic { 0xffffccccffffccccULL, 0xffffccccffffccccULL, }, 570fdd986aSMateja Marjanovic { 0x0000333300003333ULL, 0x0000333300003333ULL, }, 580fdd986aSMateja Marjanovic { 0x000038e3ffffe38eULL, 0xffff8e38000038e3ULL, }, 590fdd986aSMateja Marjanovic { 0xffffc71c00001c71ULL, 0x000071c7ffffc71cULL, }, 600fdd986aSMateja Marjanovic { 0xffffaaa9ffffaaa9ULL, 0xffffaaa9ffffaaa9ULL, }, /* 16 */ 610fdd986aSMateja Marjanovic { 0xffffaaaaffffaaaaULL, 0xffffaaaaffffaaaaULL, }, 620fdd986aSMateja Marjanovic { 0xffff5554ffff5554ULL, 0xffff5554ffff5554ULL, }, 630fdd986aSMateja Marjanovic { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, 640fdd986aSMateja Marjanovic { 0xffff7776ffff7776ULL, 0xffff7776ffff7776ULL, }, 650fdd986aSMateja Marjanovic { 0xffffddddffffddddULL, 0xffffddddffffddddULL, }, 660fdd986aSMateja Marjanovic { 0xffffe38dffff8e38ULL, 0xffff38e2ffffe38dULL, }, 670fdd986aSMateja Marjanovic { 0xffff71c6ffffc71bULL, 0x00001c71ffff71c6ULL, }, 680fdd986aSMateja Marjanovic { 0x0000555400005554ULL, 0x0000555400005554ULL, }, /* 24 */ 690fdd986aSMateja Marjanovic { 0x0000555500005555ULL, 0x0000555500005555ULL, }, 700fdd986aSMateja Marjanovic { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, 710fdd986aSMateja Marjanovic { 0x0000aaaa0000aaaaULL, 0x0000aaaa0000aaaaULL, }, 720fdd986aSMateja Marjanovic { 0x0000222100002221ULL, 0x0000222100002221ULL, }, 730fdd986aSMateja Marjanovic { 0x0000888800008888ULL, 0x0000888800008888ULL, }, 740fdd986aSMateja Marjanovic { 0x00008e38000038e3ULL, 0xffffe38d00008e38ULL, }, 750fdd986aSMateja Marjanovic { 0x00001c71000071c6ULL, 0x0000c71c00001c71ULL, }, 760fdd986aSMateja Marjanovic { 0xffffcccbffffcccbULL, 0xffffcccbffffcccbULL, }, /* 32 */ 770fdd986aSMateja Marjanovic { 0xffffccccffffccccULL, 0xffffccccffffccccULL, }, 780fdd986aSMateja Marjanovic { 0xffff7776ffff7776ULL, 0xffff7776ffff7776ULL, }, 790fdd986aSMateja Marjanovic { 0x0000222100002221ULL, 0x0000222100002221ULL, }, 800fdd986aSMateja Marjanovic { 0xffff9998ffff9998ULL, 0xffff9998ffff9998ULL, }, 810fdd986aSMateja Marjanovic { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, 820fdd986aSMateja Marjanovic { 0x000005afffffb05aULL, 0xffff5b04000005afULL, }, 830fdd986aSMateja Marjanovic { 0xffff93e8ffffe93dULL, 0x00003e93ffff93e8ULL, }, 840fdd986aSMateja Marjanovic { 0x0000333200003332ULL, 0x0000333200003332ULL, }, /* 40 */ 850fdd986aSMateja Marjanovic { 0x0000333300003333ULL, 0x0000333300003333ULL, }, 860fdd986aSMateja Marjanovic { 0xffffddddffffddddULL, 0xffffddddffffddddULL, }, 870fdd986aSMateja Marjanovic { 0x0000888800008888ULL, 0x0000888800008888ULL, }, 880fdd986aSMateja Marjanovic { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, 890fdd986aSMateja Marjanovic { 0x0000666600006666ULL, 0x0000666600006666ULL, }, 900fdd986aSMateja Marjanovic { 0x00006c16000016c1ULL, 0xffffc16b00006c16ULL, }, 910fdd986aSMateja Marjanovic { 0xfffffa4f00004fa4ULL, 0x0000a4fafffffa4fULL, }, 920fdd986aSMateja Marjanovic { 0xffffe38dffff8e37ULL, 0x000038e2ffffe38dULL, }, /* 48 */ 930fdd986aSMateja Marjanovic { 0xffffe38effff8e38ULL, 0x000038e3ffffe38eULL, }, 940fdd986aSMateja Marjanovic { 0xffff8e38ffff38e2ULL, 0xffffe38dffff8e38ULL, }, 950fdd986aSMateja Marjanovic { 0x000038e3ffffe38dULL, 0x00008e38000038e3ULL, }, 960fdd986aSMateja Marjanovic { 0xffffb05affff5b04ULL, 0x000005afffffb05aULL, }, 970fdd986aSMateja Marjanovic { 0x000016c1ffffc16bULL, 0x00006c16000016c1ULL, }, 980fdd986aSMateja Marjanovic { 0x00001c71ffff71c6ULL, 0xffffc71b00001c71ULL, }, 990fdd986aSMateja Marjanovic { 0xffffaaaaffffaaa9ULL, 0x0000aaaaffffaaaaULL, }, 1000fdd986aSMateja Marjanovic { 0x00001c70000071c6ULL, 0xffffc71b00001c70ULL, }, /* 56 */ 1010fdd986aSMateja Marjanovic { 0x00001c71000071c7ULL, 0xffffc71c00001c71ULL, }, 1020fdd986aSMateja Marjanovic { 0xffffc71b00001c71ULL, 0xffff71c6ffffc71bULL, }, 1030fdd986aSMateja Marjanovic { 0x000071c60000c71cULL, 0x00001c71000071c6ULL, }, 1040fdd986aSMateja Marjanovic { 0xffffe93d00003e93ULL, 0xffff93e8ffffe93dULL, }, 1050fdd986aSMateja Marjanovic { 0x00004fa40000a4faULL, 0xfffffa4f00004fa4ULL, }, 1060fdd986aSMateja Marjanovic { 0x0000555400005555ULL, 0xffff555400005554ULL, }, 1070fdd986aSMateja Marjanovic { 0xffffe38d00008e38ULL, 0x000038e3ffffe38dULL, }, 1080fdd986aSMateja Marjanovic { 0xffff6f3600007da2ULL, 0x000056c5ffffae87ULL, }, /* 64 */ 1090fdd986aSMateja Marjanovic { 0xffff88cdffffef6aULL, 0x0000068100005177ULL, }, 1100fdd986aSMateja Marjanovic { 0xffff3714ffffb3e2ULL, 0x000012660000238fULL, }, 1110fdd986aSMateja Marjanovic { 0xffff9eb700000ab0ULL, 0xffffd43fffffe11bULL, }, 1120fdd986aSMateja Marjanovic { 0xffffe28a0000a2d3ULL, 0x00001e55ffffc54bULL, }, 1130fdd986aSMateja Marjanovic { 0xfffffc210000149bULL, 0xffffce110000683bULL, }, 1140fdd986aSMateja Marjanovic { 0xffffaa68ffffd913ULL, 0xffffd9f600003a53ULL, }, 1150fdd986aSMateja Marjanovic { 0x0000120b00002fe1ULL, 0xffff9bcffffff7dfULL, }, 1160fdd986aSMateja Marjanovic { 0xffff932600000f0fULL, 0x00003336ffff5b37ULL, }, /* 72 */ 1170fdd986aSMateja Marjanovic { 0xffffacbdffff80d7ULL, 0xffffe2f2fffffe27ULL, }, 1180fdd986aSMateja Marjanovic { 0xffff5b04ffff454fULL, 0xffffeed7ffffd03fULL, }, 1190fdd986aSMateja Marjanovic { 0xffffc2a7ffff9c1dULL, 0xffffb0b0ffff8dcbULL, }, 1200fdd986aSMateja Marjanovic { 0x0000571b0000b371ULL, 0xffff994fffff594eULL, }, 1210fdd986aSMateja Marjanovic { 0x000070b200002539ULL, 0xffff490bfffffc3eULL, }, 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_HADD_S_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_HADD_S_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