qemu/tests/tcg/mips/user/ase/msa/bit-count/test_msa_nlzc_b.c
<<
>>
Prefs
   1/*
   2 *  Test program for MSA instruction NLZC.B
   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 (PATTERN_INPUTS_COUNT + RANDOM_INPUTS_COUNT)
  30
  31
  32int32_t main(void)
  33{
  34    char *isa_ase_name = "MSA";
  35    char *group_name = "Bit Count";
  36    char *instruction_name =  "NLZC.B";
  37    int32_t ret;
  38    uint32_t i;
  39    struct timeval start, end;
  40    double elapsed_time;
  41
  42    uint64_t b128_result[TEST_COUNT_TOTAL][2];
  43    uint64_t b128_expect[TEST_COUNT_TOTAL][2] = {
  44        { 0x0000000000000000ULL, 0x0000000000000000ULL, },    /*   0  */
  45        { 0x0808080808080808ULL, 0x0808080808080808ULL, },
  46        { 0x0000000000000000ULL, 0x0000000000000000ULL, },
  47        { 0x0101010101010101ULL, 0x0101010101010101ULL, },
  48        { 0x0000000000000000ULL, 0x0000000000000000ULL, },
  49        { 0x0202020202020202ULL, 0x0202020202020202ULL, },
  50        { 0x0000020000020000ULL, 0x0200000200000200ULL, },
  51        { 0x0301000301000301ULL, 0x0003010003010003ULL, },
  52        { 0x0000000000000000ULL, 0x0000000000000000ULL, },    /*   8  */
  53        { 0x0404040404040404ULL, 0x0404040404040404ULL, },
  54        { 0x0002040000000204ULL, 0x0000000204000000ULL, },
  55        { 0x0500000103050000ULL, 0x0103050000010305ULL, },
  56        { 0x0004000004000004ULL, 0x0000040000040000ULL, },
  57        { 0x0600020600020600ULL, 0x0206000206000206ULL, },
  58        { 0x0006000400020000ULL, 0x0600040002000006ULL, },
  59        { 0x0700050003000107ULL, 0x0005000300010700ULL, },
  60        { 0x0008000800080008ULL, 0x0008000800080008ULL, },    /*  16  */
  61        { 0x0800080008000800ULL, 0x0800080008000800ULL, },
  62        { 0x0000020004000600ULL, 0x0800000200040006ULL, },
  63        { 0x0801000300050007ULL, 0x0008010003000500ULL, },
  64        { 0x0000040008000004ULL, 0x0008000004000800ULL, },
  65        { 0x0802000600080200ULL, 0x0600080200060008ULL, },
  66        { 0x0000060000040008ULL, 0x0200080000060000ULL, },
  67        { 0x0803000801000700ULL, 0x0005000803000801ULL, },
  68        { 0x0000080000080000ULL, 0x0800000800000800ULL, },    /*  24  */
  69        { 0x0804000804000804ULL, 0x0008040008040008ULL, },
  70        { 0x0000080200080400ULL, 0x0006000008000008ULL, },
  71        { 0x0805000007000008ULL, 0x0100080300080500ULL, },
  72        { 0x0000080400000800ULL, 0x0008040000080000ULL, },
  73        { 0x0806000008020008ULL, 0x0600000802000806ULL, },
  74        { 0x0000080600000804ULL, 0x0000080200000800ULL, },
  75        { 0x0807000008050000ULL, 0x0803000008010008ULL, },
  76        { 0x0000080800000808ULL, 0x0000080800000808ULL, },    /*  32  */
  77        { 0x0808000008080000ULL, 0x0808000008080000ULL, },
  78        { 0x0000000802000008ULL, 0x0400000806000008ULL, },
  79        { 0x0808010000080300ULL, 0x0008050000080700ULL, },
  80        { 0x0000000804000008ULL, 0x0800000008040000ULL, },
  81        { 0x0808020000080600ULL, 0x0008080200000806ULL, },
  82        { 0x0000000806000000ULL, 0x0804000008080200ULL, },
  83        { 0x0808030000080801ULL, 0x0000080700000008ULL, },
  84        { 0x0000000808000000ULL, 0x0808000000080800ULL, },    /*  40  */
  85        { 0x0808040000080804ULL, 0x0000080804000008ULL, },
  86        { 0x0000000808020000ULL, 0x0808040000000806ULL, },
  87        { 0x0808050000000807ULL, 0x0000000808010000ULL, },
  88        { 0x0000000808040000ULL, 0x0008080000000808ULL, },
  89        { 0x0808060000000808ULL, 0x0200000808060000ULL, },
  90        { 0x0000000808060000ULL, 0x0008080400000008ULL, },
  91        { 0x0808070000000808ULL, 0x0500000008080300ULL, },
  92        { 0x0000000808080000ULL, 0x0008080800000008ULL, },    /*  48  */
  93        { 0x0808080000000808ULL, 0x0800000008080800ULL, },
  94        { 0x0000000008080200ULL, 0x0000080804000000ULL, },
  95        { 0x0808080100000008ULL, 0x0803000000080805ULL, },
  96        { 0x0000000008080400ULL, 0x0000080808000000ULL, },
  97        { 0x0808080200000008ULL, 0x0806000000080808ULL, },
  98        { 0x0000000008080600ULL, 0x0000000808040000ULL, },
  99        { 0x0808080300000008ULL, 0x0808010000000808ULL, },
 100        { 0x0000000008080800ULL, 0x0000000808080000ULL, },    /*  56  */
 101        { 0x0808080400000008ULL, 0x0808040000000808ULL, },
 102        { 0x0000000008080802ULL, 0x0000000808080400ULL, },
 103        { 0x0808080500000000ULL, 0x0808070000000008ULL, },
 104        { 0x0000000008080804ULL, 0x0000000008080800ULL, },
 105        { 0x0808080600000000ULL, 0x0808080200000008ULL, },
 106        { 0x0000000008080806ULL, 0x0000000008080804ULL, },
 107        { 0x0808080700000000ULL, 0x0808080500000000ULL, },
 108        { 0x0001000002010101ULL, 0x0101040100010004ULL, },    /*  64  */
 109        { 0x0000080101000004ULL, 0x0300000303020100ULL, },
 110        { 0x0001000000000000ULL, 0x0200000000020203ULL, },
 111        { 0x0101030101020001ULL, 0x0000000000010000ULL, },
 112        { 0x0000010101000101ULL, 0x0002010000000100ULL, },
 113        { 0x0002000000040200ULL, 0x0304010100000201ULL, },
 114        { 0x0002010501000001ULL, 0x0002040200000001ULL, },
 115        { 0x0000020000000000ULL, 0x0000010203010100ULL, },
 116        { 0x0203040001000001ULL, 0x0001000200000201ULL, },    /*  72  */
 117        { 0x0001000301000000ULL, 0x0002000000000001ULL, },
 118        { 0x0000000000000003ULL, 0x0000010101040103ULL, },
 119        { 0x0000000002000100ULL, 0x0000000101000000ULL, },
 120        { 0x0003020000010004ULL, 0x0001000001010003ULL, },
 121        { 0x0001020003020100ULL, 0x0000020001040201ULL, },
 122        { 0x0102010102000000ULL, 0x0001000000030201ULL, },
 123        { 0x0001000000010000ULL, 0x0001000001010300ULL, },
 124    };
 125
 126    reset_msa_registers();
 127
 128    gettimeofday(&start, NULL);
 129
 130    for (i = 0; i < TEST_COUNT_TOTAL; i++) {
 131        if (i < PATTERN_INPUTS_COUNT) {
 132            do_msa_NLZC_B(b128_pattern[i], b128_result[i]);
 133        } else {
 134            do_msa_NLZC_B(b128_random[i - PATTERN_INPUTS_COUNT],
 135                          b128_result[i]);
 136        }
 137    }
 138
 139    gettimeofday(&end, NULL);
 140
 141    elapsed_time = (end.tv_sec - start.tv_sec) * 1000.0;
 142    elapsed_time += (end.tv_usec - start.tv_usec) / 1000.0;
 143
 144    ret = check_results_128(isa_ase_name, group_name, instruction_name,
 145                            TEST_COUNT_TOTAL, elapsed_time,
 146                            &b128_result[0][0], &b128_expect[0][0]);
 147
 148    return ret;
 149}
 150