10fdd986aSMateja Marjanovic /* 20fdd986aSMateja Marjanovic * Test program for MSA instruction HADD_S.H 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.H"; 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 { 0xfffefffefffefffeULL, 0xfffefffefffefffeULL, }, /* 0 */ 450fdd986aSMateja Marjanovic { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, 460fdd986aSMateja Marjanovic { 0xffa9ffa9ffa9ffa9ULL, 0xffa9ffa9ffa9ffa9ULL, }, 470fdd986aSMateja Marjanovic { 0x0054005400540054ULL, 0x0054005400540054ULL, }, 480fdd986aSMateja Marjanovic { 0xffcbffcbffcbffcbULL, 0xffcbffcbffcbffcbULL, }, 490fdd986aSMateja Marjanovic { 0x0032003200320032ULL, 0x0032003200320032ULL, }, 500fdd986aSMateja Marjanovic { 0xff8dffe20037ff8dULL, 0xffe20037ff8dffe2ULL, }, 510fdd986aSMateja Marjanovic { 0x0070001bffc60070ULL, 0x001bffc60070001bULL, }, 520fdd986aSMateja Marjanovic { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, /* 8 */ 530fdd986aSMateja Marjanovic { 0x0000000000000000ULL, 0x0000000000000000ULL, }, 540fdd986aSMateja Marjanovic { 0xffaaffaaffaaffaaULL, 0xffaaffaaffaaffaaULL, }, 550fdd986aSMateja Marjanovic { 0x0055005500550055ULL, 0x0055005500550055ULL, }, 560fdd986aSMateja Marjanovic { 0xffccffccffccffccULL, 0xffccffccffccffccULL, }, 570fdd986aSMateja Marjanovic { 0x0033003300330033ULL, 0x0033003300330033ULL, }, 580fdd986aSMateja Marjanovic { 0xff8effe30038ff8eULL, 0xffe30038ff8effe3ULL, }, 590fdd986aSMateja Marjanovic { 0x0071001cffc70071ULL, 0x001cffc70071001cULL, }, 600fdd986aSMateja Marjanovic { 0xffa9ffa9ffa9ffa9ULL, 0xffa9ffa9ffa9ffa9ULL, }, /* 16 */ 610fdd986aSMateja Marjanovic { 0xffaaffaaffaaffaaULL, 0xffaaffaaffaaffaaULL, }, 620fdd986aSMateja Marjanovic { 0xff54ff54ff54ff54ULL, 0xff54ff54ff54ff54ULL, }, 630fdd986aSMateja Marjanovic { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, 640fdd986aSMateja Marjanovic { 0xff76ff76ff76ff76ULL, 0xff76ff76ff76ff76ULL, }, 650fdd986aSMateja Marjanovic { 0xffddffddffddffddULL, 0xffddffddffddffddULL, }, 660fdd986aSMateja Marjanovic { 0xff38ff8dffe2ff38ULL, 0xff8dffe2ff38ff8dULL, }, 670fdd986aSMateja Marjanovic { 0x001bffc6ff71001bULL, 0xffc6ff71001bffc6ULL, }, 680fdd986aSMateja Marjanovic { 0x0054005400540054ULL, 0x0054005400540054ULL, }, /* 24 */ 690fdd986aSMateja Marjanovic { 0x0055005500550055ULL, 0x0055005500550055ULL, }, 700fdd986aSMateja Marjanovic { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, 710fdd986aSMateja Marjanovic { 0x00aa00aa00aa00aaULL, 0x00aa00aa00aa00aaULL, }, 720fdd986aSMateja Marjanovic { 0x0021002100210021ULL, 0x0021002100210021ULL, }, 730fdd986aSMateja Marjanovic { 0x0088008800880088ULL, 0x0088008800880088ULL, }, 740fdd986aSMateja Marjanovic { 0xffe30038008dffe3ULL, 0x0038008dffe30038ULL, }, 750fdd986aSMateja Marjanovic { 0x00c60071001c00c6ULL, 0x0071001c00c60071ULL, }, 760fdd986aSMateja Marjanovic { 0xffcbffcbffcbffcbULL, 0xffcbffcbffcbffcbULL, }, /* 32 */ 770fdd986aSMateja Marjanovic { 0xffccffccffccffccULL, 0xffccffccffccffccULL, }, 780fdd986aSMateja Marjanovic { 0xff76ff76ff76ff76ULL, 0xff76ff76ff76ff76ULL, }, 790fdd986aSMateja Marjanovic { 0x0021002100210021ULL, 0x0021002100210021ULL, }, 800fdd986aSMateja Marjanovic { 0xff98ff98ff98ff98ULL, 0xff98ff98ff98ff98ULL, }, 810fdd986aSMateja Marjanovic { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, 820fdd986aSMateja Marjanovic { 0xff5affaf0004ff5aULL, 0xffaf0004ff5affafULL, }, 830fdd986aSMateja Marjanovic { 0x003dffe8ff93003dULL, 0xffe8ff93003dffe8ULL, }, 840fdd986aSMateja Marjanovic { 0x0032003200320032ULL, 0x0032003200320032ULL, }, /* 40 */ 850fdd986aSMateja Marjanovic { 0x0033003300330033ULL, 0x0033003300330033ULL, }, 860fdd986aSMateja Marjanovic { 0xffddffddffddffddULL, 0xffddffddffddffddULL, }, 870fdd986aSMateja Marjanovic { 0x0088008800880088ULL, 0x0088008800880088ULL, }, 880fdd986aSMateja Marjanovic { 0xffffffffffffffffULL, 0xffffffffffffffffULL, }, 890fdd986aSMateja Marjanovic { 0x0066006600660066ULL, 0x0066006600660066ULL, }, 900fdd986aSMateja Marjanovic { 0xffc10016006bffc1ULL, 0x0016006bffc10016ULL, }, 910fdd986aSMateja Marjanovic { 0x00a4004ffffa00a4ULL, 0x004ffffa00a4004fULL, }, 920fdd986aSMateja Marjanovic { 0xffe20037ff8dffe2ULL, 0x0037ff8dffe20037ULL, }, /* 48 */ 930fdd986aSMateja Marjanovic { 0xffe30038ff8effe3ULL, 0x0038ff8effe30038ULL, }, 940fdd986aSMateja Marjanovic { 0xff8dffe2ff38ff8dULL, 0xffe2ff38ff8dffe2ULL, }, 950fdd986aSMateja Marjanovic { 0x0038008dffe30038ULL, 0x008dffe30038008dULL, }, 960fdd986aSMateja Marjanovic { 0xffaf0004ff5affafULL, 0x0004ff5affaf0004ULL, }, 970fdd986aSMateja Marjanovic { 0x0016006bffc10016ULL, 0x006bffc10016006bULL, }, 980fdd986aSMateja Marjanovic { 0xff71001bffc6ff71ULL, 0x001bffc6ff71001bULL, }, 990fdd986aSMateja Marjanovic { 0x00540054ff550054ULL, 0x0054ff5500540054ULL, }, 1000fdd986aSMateja Marjanovic { 0x001bffc60070001bULL, 0xffc60070001bffc6ULL, }, /* 56 */ 1010fdd986aSMateja Marjanovic { 0x001cffc70071001cULL, 0xffc70071001cffc7ULL, }, 1020fdd986aSMateja Marjanovic { 0xffc6ff71001bffc6ULL, 0xff71001bffc6ff71ULL, }, 1030fdd986aSMateja Marjanovic { 0x0071001c00c60071ULL, 0x001c00c60071001cULL, }, 1040fdd986aSMateja Marjanovic { 0xffe8ff93003dffe8ULL, 0xff93003dffe8ff93ULL, }, 1050fdd986aSMateja Marjanovic { 0x004ffffa00a4004fULL, 0xfffa00a4004ffffaULL, }, 1060fdd986aSMateja Marjanovic { 0xffaaffaa00a9ffaaULL, 0xffaa00a9ffaaffaaULL, }, 1070fdd986aSMateja Marjanovic { 0x008dffe30038008dULL, 0xffe30038008dffe3ULL, }, 1080fdd986aSMateja Marjanovic { 0xfff2ffb2008a0095ULL, 0x00b200690079ffbcULL, }, /* 64 */ 1090fdd986aSMateja Marjanovic { 0xff460049ffbb005dULL, 0x00420025003dffacULL, }, 1100fdd986aSMateja Marjanovic { 0xffe2ff90fff7ffd5ULL, 0x0023000a0029ffc4ULL, }, 1110fdd986aSMateja Marjanovic { 0xffd70033005900a3ULL, 0x003cffe30040ff50ULL, }, 1120fdd986aSMateja Marjanovic { 0x0065ffcc00af0007ULL, 0x007900190090005eULL, }, 1130fdd986aSMateja Marjanovic { 0xffb90063ffe0ffcfULL, 0x0009ffd50054004eULL, }, 1140fdd986aSMateja Marjanovic { 0x0055ffaa001cff47ULL, 0xffeaffba00400066ULL, }, 1150fdd986aSMateja Marjanovic { 0x004a004d007e0015ULL, 0x0003ff930057fff2ULL, }, 1160fdd986aSMateja Marjanovic { 0x0016ff7a001bffcbULL, 0x008e002400260031ULL, }, /* 72 */ 1170fdd986aSMateja Marjanovic { 0xff6a0011ff4cff93ULL, 0x001effe0ffea0021ULL, }, 1180fdd986aSMateja Marjanovic { 0x0006ff58ff88ff0bULL, 0xffffffc5ffd60039ULL, }, 1190fdd986aSMateja Marjanovic { 0xfffbfffbffeaffd9ULL, 0x0018ff9effedffc5ULL, }, 1200fdd986aSMateja Marjanovic { 0x00daffe200c00022ULL, 0xfff4ffe60024ffeeULL, }, 1210fdd986aSMateja Marjanovic { 0x002e0079fff1ffeaULL, 0xff84ffa2ffe8ffdeULL, }, 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_H(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_H(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