test_msa_ilvev_h.c (7540B)
1/* 2 * Test program for MSA instruction ILVEV.H 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 (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 = "Interleave"; 38 char *instruction_name = "ILVEV.H"; 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 { 0xffff0000ffff0000ULL, 0xffff0000ffff0000ULL, }, 48 { 0xffffaaaaffffaaaaULL, 0xffffaaaaffffaaaaULL, }, 49 { 0xffff5555ffff5555ULL, 0xffff5555ffff5555ULL, }, 50 { 0xffffccccffffccccULL, 0xffffccccffffccccULL, }, 51 { 0xffff3333ffff3333ULL, 0xffff3333ffff3333ULL, }, 52 { 0xffff38e3ffffe38eULL, 0xffff8e38ffff38e3ULL, }, 53 { 0xffffc71cffff1c71ULL, 0xffff71c7ffffc71cULL, }, 54 { 0x0000ffff0000ffffULL, 0x0000ffff0000ffffULL, }, /* 8 */ 55 { 0x0000000000000000ULL, 0x0000000000000000ULL, }, 56 { 0x0000aaaa0000aaaaULL, 0x0000aaaa0000aaaaULL, }, 57 { 0x0000555500005555ULL, 0x0000555500005555ULL, }, 58 { 0x0000cccc0000ccccULL, 0x0000cccc0000ccccULL, }, 59 { 0x0000333300003333ULL, 0x0000333300003333ULL, }, 60 { 0x000038e30000e38eULL, 0x00008e38000038e3ULL, }, 61 { 0x0000c71c00001c71ULL, 0x000071c70000c71cULL, }, 62 { 0xaaaaffffaaaaffffULL, 0xaaaaffffaaaaffffULL, }, /* 16 */ 63 { 0xaaaa0000aaaa0000ULL, 0xaaaa0000aaaa0000ULL, }, 64 { 0xaaaaaaaaaaaaaaaaULL, 0xaaaaaaaaaaaaaaaaULL, }, 65 { 0xaaaa5555aaaa5555ULL, 0xaaaa5555aaaa5555ULL, }, 66 { 0xaaaaccccaaaaccccULL, 0xaaaaccccaaaaccccULL, }, 67 { 0xaaaa3333aaaa3333ULL, 0xaaaa3333aaaa3333ULL, }, 68 { 0xaaaa38e3aaaae38eULL, 0xaaaa8e38aaaa38e3ULL, }, 69 { 0xaaaac71caaaa1c71ULL, 0xaaaa71c7aaaac71cULL, }, 70 { 0x5555ffff5555ffffULL, 0x5555ffff5555ffffULL, }, /* 24 */ 71 { 0x5555000055550000ULL, 0x5555000055550000ULL, }, 72 { 0x5555aaaa5555aaaaULL, 0x5555aaaa5555aaaaULL, }, 73 { 0x5555555555555555ULL, 0x5555555555555555ULL, }, 74 { 0x5555cccc5555ccccULL, 0x5555cccc5555ccccULL, }, 75 { 0x5555333355553333ULL, 0x5555333355553333ULL, }, 76 { 0x555538e35555e38eULL, 0x55558e38555538e3ULL, }, 77 { 0x5555c71c55551c71ULL, 0x555571c75555c71cULL, }, 78 { 0xccccffffccccffffULL, 0xccccffffccccffffULL, }, /* 32 */ 79 { 0xcccc0000cccc0000ULL, 0xcccc0000cccc0000ULL, }, 80 { 0xccccaaaaccccaaaaULL, 0xccccaaaaccccaaaaULL, }, 81 { 0xcccc5555cccc5555ULL, 0xcccc5555cccc5555ULL, }, 82 { 0xccccccccccccccccULL, 0xccccccccccccccccULL, }, 83 { 0xcccc3333cccc3333ULL, 0xcccc3333cccc3333ULL, }, 84 { 0xcccc38e3cccce38eULL, 0xcccc8e38cccc38e3ULL, }, 85 { 0xccccc71ccccc1c71ULL, 0xcccc71c7ccccc71cULL, }, 86 { 0x3333ffff3333ffffULL, 0x3333ffff3333ffffULL, }, /* 40 */ 87 { 0x3333000033330000ULL, 0x3333000033330000ULL, }, 88 { 0x3333aaaa3333aaaaULL, 0x3333aaaa3333aaaaULL, }, 89 { 0x3333555533335555ULL, 0x3333555533335555ULL, }, 90 { 0x3333cccc3333ccccULL, 0x3333cccc3333ccccULL, }, 91 { 0x3333333333333333ULL, 0x3333333333333333ULL, }, 92 { 0x333338e33333e38eULL, 0x33338e38333338e3ULL, }, 93 { 0x3333c71c33331c71ULL, 0x333371c73333c71cULL, }, 94 { 0x38e3ffffe38effffULL, 0x8e38ffff38e3ffffULL, }, /* 48 */ 95 { 0x38e30000e38e0000ULL, 0x8e38000038e30000ULL, }, 96 { 0x38e3aaaae38eaaaaULL, 0x8e38aaaa38e3aaaaULL, }, 97 { 0x38e35555e38e5555ULL, 0x8e38555538e35555ULL, }, 98 { 0x38e3cccce38eccccULL, 0x8e38cccc38e3ccccULL, }, 99 { 0x38e33333e38e3333ULL, 0x8e38333338e33333ULL, }, 100 { 0x38e338e3e38ee38eULL, 0x8e388e3838e338e3ULL, }, 101 { 0x38e3c71ce38e1c71ULL, 0x8e3871c738e3c71cULL, }, 102 { 0xc71cffff1c71ffffULL, 0x71c7ffffc71cffffULL, }, /* 56 */ 103 { 0xc71c00001c710000ULL, 0x71c70000c71c0000ULL, }, 104 { 0xc71caaaa1c71aaaaULL, 0x71c7aaaac71caaaaULL, }, 105 { 0xc71c55551c715555ULL, 0x71c75555c71c5555ULL, }, 106 { 0xc71ccccc1c71ccccULL, 0x71c7ccccc71cccccULL, }, 107 { 0xc71c33331c713333ULL, 0x71c73333c71c3333ULL, }, 108 { 0xc71c38e31c71e38eULL, 0x71c78e38c71c38e3ULL, }, 109 { 0xc71cc71c1c711c71ULL, 0x71c771c7c71cc71cULL, }, 110 { 0xe6cce6cc55405540ULL, 0x0b5e0b5eb00cb00cULL, }, /* 64 */ 111 { 0xe6cc00635540c708ULL, 0x0b5ebb1ab00c52fcULL, }, 112 { 0xe6ccaeaa55408b80ULL, 0x0b5ec6ffb00c2514ULL, }, 113 { 0xe6cc164d5540e24eULL, 0x0b5e88d8b00ce2a0ULL, }, 114 { 0x0063e6ccc7085540ULL, 0xbb1a0b5e52fcb00cULL, }, 115 { 0x00630063c708c708ULL, 0xbb1abb1a52fc52fcULL, }, 116 { 0x0063aeaac7088b80ULL, 0xbb1ac6ff52fc2514ULL, }, 117 { 0x0063164dc708e24eULL, 0xbb1a88d852fce2a0ULL, }, 118 { 0xaeaae6cc8b805540ULL, 0xc6ff0b5e2514b00cULL, }, /* 72 */ 119 { 0xaeaa00638b80c708ULL, 0xc6ffbb1a251452fcULL, }, 120 { 0xaeaaaeaa8b808b80ULL, 0xc6ffc6ff25142514ULL, }, 121 { 0xaeaa164d8b80e24eULL, 0xc6ff88d82514e2a0ULL, }, 122 { 0x164de6cce24e5540ULL, 0x88d80b5ee2a0b00cULL, }, 123 { 0x164d0063e24ec708ULL, 0x88d8bb1ae2a052fcULL, }, 124 { 0x164daeaae24e8b80ULL, 0x88d8c6ffe2a02514ULL, }, 125 { 0x164d164de24ee24eULL, 0x88d888d8e2a0e2a0ULL, }, 126 }; 127 128 reset_msa_registers(); 129 130 gettimeofday(&start, NULL); 131 132 for (i = 0; i < PATTERN_INPUTS_SHORT_COUNT; i++) { 133 for (j = 0; j < PATTERN_INPUTS_SHORT_COUNT; j++) { 134 do_msa_ILVEV_H(b128_pattern[i], b128_pattern[j], 135 b128_result[PATTERN_INPUTS_SHORT_COUNT * i + j]); 136 } 137 } 138 139 for (i = 0; i < RANDOM_INPUTS_SHORT_COUNT; i++) { 140 for (j = 0; j < RANDOM_INPUTS_SHORT_COUNT; j++) { 141 do_msa_ILVEV_H(b128_random[i], b128_random[j], 142 b128_result[((PATTERN_INPUTS_SHORT_COUNT) * 143 (PATTERN_INPUTS_SHORT_COUNT)) + 144 RANDOM_INPUTS_SHORT_COUNT * i + j]); 145 } 146 } 147 148 gettimeofday(&end, NULL); 149 150 elapsed_time = (end.tv_sec - start.tv_sec) * 1000.0; 151 elapsed_time += (end.tv_usec - start.tv_usec) / 1000.0; 152 153 ret = check_results_128(isa_ase_name, group_name, instruction_name, 154 TEST_COUNT_TOTAL, elapsed_time, 155 &b128_result[0][0], &b128_expect[0][0]); 156 157 return ret; 158}