Skip to contentSkip to conversation

target/mips: Add MSA ASE tests

PATCH Superseded Aleksandar Markovic 4 participants 9 messages Feb 12, 2019 – Feb 13, 2019

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

cover target/mips: Add MSA ASE tests

From: Aleksandar Markovic <[email protected]>

This series begins to add unit tests (aka tcg tests) for MIPS' MSA ASE. More tests and related test infrastructure will be added in subsequent version of this series.

There are several checkpatch warnings that are all false positives for given circumstances.

Aleksandar Markovic (5):
tests/tcg: target/mips: Remove an unnecessary file tests/tcg: target/mips: Add a header with test inputs tests/tcg: target/mips: Add a header with MSA wrappers tests/tcg: target/mips: Add a header with test utilities tests/tcg: target/mips: Add tests for MSA bit counting instructions

 tests/tcg/mips/include/test_inputs.h               | 120 +++++++++++++++++
 tests/tcg/mips/include/test_utils.h                |  84 ++++++++++++
 tests/tcg/mips/include/wrappers_msa.h              |  57 ++++++++
 tests/tcg/mips/mips64-dspr2/.directory             |   2 -
 .../user/ase/msa/bit_counting/test_msa_nloc_b.c    | 144 +++++++++++++++++++++
 .../user/ase/msa/bit_counting/test_msa_nloc_d.c    | 144 +++++++++++++++++++++
 .../user/ase/msa/bit_counting/test_msa_nloc_h.c    | 144 +++++++++++++++++++++
 .../user/ase/msa/bit_counting/test_msa_nloc_w.c    | 144 +++++++++++++++++++++
 .../user/ase/msa/bit_counting/test_msa_nlzc_b.c    | 144 +++++++++++++++++++++
 .../user/ase/msa/bit_counting/test_msa_nlzc_d.c    | 144 +++++++++++++++++++++
 .../user/ase/msa/bit_counting/test_msa_nlzc_h.c    | 144 +++++++++++++++++++++
 .../user/ase/msa/bit_counting/test_msa_nlzc_w.c    | 144 +++++++++++++++++++++
 .../user/ase/msa/bit_counting/test_msa_pcnt_b.c    | 144 +++++++++++++++++++++
 .../user/ase/msa/bit_counting/test_msa_pcnt_d.c    | 144 +++++++++++++++++++++
 .../user/ase/msa/bit_counting/test_msa_pcnt_h.c    | 144 +++++++++++++++++++++
 .../user/ase/msa/bit_counting/test_msa_pcnt_w.c    | 144 +++++++++++++++++++++
 16 files changed, 1989 insertions(+), 2 deletions(-)
 create mode 100644 tests/tcg/mips/include/test_inputs.h
 create mode 100644 tests/tcg/mips/include/test_utils.h
 create mode 100644 tests/tcg/mips/include/wrappers_msa.h
 delete mode 100644 tests/tcg/mips/mips64-dspr2/.directory
 create mode 100644 tests/tcg/mips/user/ase/msa/bit_counting/test_msa_nloc_b.c
 create mode 100644 tests/tcg/mips/user/ase/msa/bit_counting/test_msa_nloc_d.c
 create mode 100644 tests/tcg/mips/user/ase/msa/bit_counting/test_msa_nloc_h.c
 create mode 100644 tests/tcg/mips/user/ase/msa/bit_counting/test_msa_nloc_w.c
 create mode 100644 tests/tcg/mips/user/ase/msa/bit_counting/test_msa_nlzc_b.c
 create mode 100644 tests/tcg/mips/user/ase/msa/bit_counting/test_msa_nlzc_d.c
 create mode 100644 tests/tcg/mips/user/ase/msa/bit_counting/test_msa_nlzc_h.c
 create mode 100644 tests/tcg/mips/user/ase/msa/bit_counting/test_msa_nlzc_w.c
 create mode 100644 tests/tcg/mips/user/ase/msa/bit_counting/test_msa_pcnt_b.c
 create mode 100644 tests/tcg/mips/user/ase/msa/bit_counting/test_msa_pcnt_d.c
 create mode 100644 tests/tcg/mips/user/ase/msa/bit_counting/test_msa_pcnt_h.c
 create mode 100644 tests/tcg/mips/user/ase/msa/bit_counting/test_msa_pcnt_w.c
Signature · 1 line
2.7.4
#1 lore raw

PATCH 1/5 tests/tcg: target/mips: Remove an unnecessary file

From: Aleksandar Markovic <[email protected]>

Remove a file that was added long time ago by mistake.

---
 tests/tcg/mips/mips64-dspr2/.directory | 2 --
 1 file changed, 2 deletions(-)
 delete mode 100644 tests/tcg/mips/mips64-dspr2/.directory
tests/tcg/mips/mips64-dspr2/.directory deleted +0 -2
deleted file mode 100644
index c75a914..0000000
@@ -1,2 +0,0 @@
-[Dolphin]
-Timestamp=2012,8,3,16,41,52
Signature · 1 line
2.7.4
Reviewed-by on v1 1/5
#2 lore raw

Re: [Qemu-devel] [PATCH 1/5] tests/tcg: target/mips: Remove an unnecessary file

Quoted 3 lines · Aleksandar Markovic

From: Aleksandar Markovic <[email protected]>

Remove a file that was added long time ago by mistake.

Might be worth mentioning commit d70080c4 (in 2012).

Is this the sort of file that is likely enough to be created during typical workflows that it should be listed in the project's .gitignore for everyone? Or is it particular enough to your environment that you could 'echo .directory >> .git/info/exclude' to ensure it doesn't happen again for your setup, without bothering other developers with your exclusion?

Either way, the cleanup itself makes sense.

Signature · 3 lines
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org
#3 lore raw

Re: [Qemu-devel] [PATCH 1/5] tests/tcg: target/mips: Remove an unnecessary file

Quoted 6 lines

From: Eric Blake <[email protected]>
Sent: Tuesday, February 12, 2019 9:04 PM
To: Aleksandar Markovic; [email protected]
Cc: Aleksandar Rikalo; [email protected]; Aleksandar Markovic; [email protected]
Subject: Re: [Qemu-devel] [PATCH 1/5] tests/tcg: target/mips: Remove an unnecessary file

Quoted 6 lines
Quoted 3 lines · Aleksandar Markovic

From: Aleksandar Markovic <[email protected]>

Remove a file that was added long time ago by mistake.

Might be worth mentioning commit d70080c4 (in 2012).

I am going to mention it in the next version of this series.

Quoted 8 lines

Is this the sort of file that is likely enough to be created during typical workflows that it should be listed in the project's .gitignore for everyone? Or is it particular enough to your environment that you could 'echo .directory >> .git/info/exclude' to ensure it doesn't happen again for your setup, without bothering other developers with your exclusion?

It is particular enough, no need to update .gitingnore for everyone, IMHO.

Quoted 8 lines

Either way, the cleanup itself makes sense.

--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3226
Virtualization: qemu.org | libvirt.org

Thanks,
Aleksandar

Acked-by on v1 1/5
#4 lore raw

Re: [Qemu-devel] [PATCH 1/5] tests/tcg: target/mips: Remove an unnecessary file

In reply to Aleksandar Markovic
Quoted 5 lines · Aleksandar Markovic

From: Aleksandar Markovic <[email protected]>

Remove a file that was added long time ago by mistake.

tests/tcg/mips/mips64-dspr2/.directory line 2

Quoted 13 lines
---
 tests/tcg/mips/mips64-dspr2/.directory | 2 --
 1 file changed, 2 deletions(-)
 delete mode 100644 tests/tcg/mips/mips64-dspr2/.directory
tests/tcg/mips/mips64-dspr2/.directory deleted +0 -2
deleted file mode 100644
index c75a914..0000000
@@ -1,2 +0,0 @@
-[Dolphin]
-Timestamp=2012,8,3,16,41,52

--
Alex Bennée

#5 lore raw

PATCH 2/5 tests/tcg: target/mips: Add a header with test inputs

In reply to Aleksandar Markovic

From: Aleksandar Markovic <[email protected]>

The file tests/tcg/mips/include/test_inputs.h is planned to contain various test inputs. For now, it contains 64 128-bit pattern inputs (alternating groups od ones and zeroes) and 16 128-bit random inputs.

---
 tests/tcg/mips/include/test_inputs.h | 120 +++++++++++++++++++++++++++++++++++
 1 file changed, 120 insertions(+)
 create mode 100644 tests/tcg/mips/include/test_inputs.h
tests/tcg/mips/include/test_inputs.h new file +120 -0
new file mode 100644
index 0000000..88f4e0e
@@ -0,0 +1,120 @@
+/*
+ *  Header file for pattern and random test inputs
+ *
+ *  Copyright (C) 2018  Wave Computing, Inc.
+ *  Copyright (C) 2018  Aleksandar Markovic <[email protected]>
+ *
+ *  This program is free software: you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation, either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program.  If not, see <https://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef TEST_INPUTS_H
+#define TEST_INPUTS_H
+
+#include <stdint.h>
+
+
+#define PATTERN_INPUTS_COUNT   64
+
+uint64_t b128_pattern[PATTERN_INPUTS_COUNT][2] = {
+    { 0xFFFFFFFFFFFFFFFFULL, 0xFFFFFFFFFFFFFFFFULL, },   /*   0 */
+    { 0x0000000000000000ULL, 0x0000000000000000ULL, },
+    { 0xAAAAAAAAAAAAAAAAULL, 0xAAAAAAAAAAAAAAAAULL, },
+    { 0x5555555555555555ULL, 0x5555555555555555ULL, },
+    { 0xCCCCCCCCCCCCCCCCULL, 0xCCCCCCCCCCCCCCCCULL, },
+    { 0x3333333333333333ULL, 0x3333333333333333ULL, },
+    { 0xE38E38E38E38E38EULL, 0x38E38E38E38E38E3ULL, },
+    { 0x1C71C71C71C71C71ULL, 0xC71C71C71C71C71CULL, },
+    { 0xF0F0F0F0F0F0F0F0ULL, 0xF0F0F0F0F0F0F0F0ULL, },   /*   8 */
+    { 0x0F0F0F0F0F0F0F0FULL, 0x0F0F0F0F0F0F0F0FULL, },
+    { 0xF83E0F83E0F83E0FULL, 0x83E0F83E0F83E0F8ULL, },
+    { 0x07C1F07C1F07C1F0ULL, 0x7C1F07C1F07C1F07ULL, },
+    { 0xFC0FC0FC0FC0FC0FULL, 0xC0FC0FC0FC0FC0FCULL, },
+    { 0x03F03F03F03F03F0ULL, 0x3F03F03F03F03F03ULL, },
+    { 0xFE03F80FE03F80FEULL, 0x03F80FE03F80FE03ULL, },
+    { 0x01FC07F01FC07F01ULL, 0xFC07F01FC07F01FCULL, },
+    { 0xFF00FF00FF00FF00ULL, 0xFF00FF00FF00FF00ULL, },   /*  16 */
+    { 0x00FF00FF00FF00FFULL, 0x00FF00FF00FF00FFULL, },
+    { 0xFF803FE00FF803FEULL, 0x00FF803FE00FF803ULL, },
+    { 0x007FC01FF007FC01ULL, 0xFF007FC01FF007FCULL, },
+    { 0xFFC00FFC00FFC00FULL, 0xFC00FFC00FFC00FFULL, },
+    { 0x003FF003FF003FF0ULL, 0x03FF003FF003FF00ULL, },
+    { 0xFFE003FF800FFE00ULL, 0x3FF800FFE003FF80ULL, },
+    { 0x001FFC007FF001FFULL, 0xC007FF001FFC007FULL, },
+    { 0xFFF000FFF000FFF0ULL, 0x00FFF000FFF000FFULL, },   /*  24 */
+    { 0x000FFF000FFF000FULL, 0xFF000FFF000FFF00ULL, },
+    { 0xFFF8003FFE000FFFULL, 0x8003FFE000FFF800ULL, },
+    { 0x0007FFC001FFF000ULL, 0x7FFC001FFF0007FFULL, },
+    { 0xFFFC000FFFC000FFULL, 0xFC000FFFC000FFFCULL, },
+    { 0x0003FFF0003FFF00ULL, 0x03FFF0003FFF0003ULL, },
+    { 0xFFFE0003FFF8000FULL, 0xFFE0003FFF8000FFULL, },
+    { 0x0001FFFC0007FFF0ULL, 0x001FFFC0007FFF00ULL, },
+    { 0xFFFF0000FFFF0000ULL, 0xFFFF0000FFFF0000ULL, },   /*  32 */
+    { 0x0000FFFF0000FFFFULL, 0x0000FFFF0000FFFFULL, },
+    { 0xFFFF80003FFFE000ULL, 0x0FFFF80003FFFE00ULL, },
+    { 0x00007FFFC0001FFFULL, 0xF00007FFFC0001FFULL, },
+    { 0xFFFFC0000FFFFC00ULL, 0x00FFFFC0000FFFFCULL, },
+    { 0x00003FFFF00003FFULL, 0xFF00003FFFF00003ULL, },
+    { 0xFFFFE00003FFFF80ULL, 0x000FFFFE00003FFFULL, },
+    { 0x00001FFFFC00007FULL, 0xFFF00001FFFFC000ULL, },
+    { 0xFFFFF00000FFFFF0ULL, 0x0000FFFFF00000FFULL, },   /*  40 */
+    { 0x00000FFFFF00000FULL, 0xFFFF00000FFFFF00ULL, },
+    { 0xFFFFF800003FFFFEULL, 0x00000FFFFF800003ULL, },
+    { 0x000007FFFFC00001ULL, 0xFFFFF000007FFFFCULL, },
+    { 0xFFFFFC00000FFFFFULL, 0xC00000FFFFFC0000ULL, },
+    { 0x000003FFFFF00000ULL, 0x3FFFFF000003FFFFULL, },
+    { 0xFFFFFE000003FFFFULL, 0xF800000FFFFFE000ULL, },
+    { 0x000001FFFFFC0000ULL, 0x07FFFFF000001FFFULL, },
+    { 0xFFFFFF000000FFFFULL, 0xFF000000FFFFFF00ULL, },   /*  48 */
+    { 0x000000FFFFFF0000ULL, 0x00FFFFFF000000FFULL, },
+    { 0xFFFFFF8000003FFFULL, 0xFFE000000FFFFFF8ULL, },
+    { 0x0000007FFFFFC000ULL, 0x001FFFFFF0000007ULL, },
+    { 0xFFFFFFC000000FFFULL, 0xFFFC000000FFFFFFULL, },
+    { 0x0000003FFFFFF000ULL, 0x0003FFFFFF000000ULL, },
+    { 0xFFFFFFE0000003FFULL, 0xFFFF8000000FFFFFULL, },
+    { 0x0000001FFFFFFC00ULL, 0x00007FFFFFF00000ULL, },
+    { 0xFFFFFFF0000000FFULL, 0xFFFFF0000000FFFFULL, },   /*  56 */
+    { 0x0000000FFFFFFF00ULL, 0x00000FFFFFFF0000ULL, },
+    { 0xFFFFFFF80000003FULL, 0xFFFFFE0000000FFFULL, },
+    { 0x00000007FFFFFFC0ULL, 0x000001FFFFFFF000ULL, },
+    { 0xFFFFFFFC0000000FULL, 0xFFFFFFC0000000FFULL, },
+    { 0x00000003FFFFFFF0ULL, 0x0000003FFFFFFF00ULL, },
+    { 0xFFFFFFFE00000003ULL, 0xFFFFFFF80000000FULL, },
+    { 0x00000001FFFFFFFCULL, 0x00000007FFFFFFF0ULL, },
+};
+
+
+#define RANDOM_INPUTS_COUNT    16
+
+uint64_t b128_random[RANDOM_INPUTS_COUNT][2] = {
+    { 0x886AE6CC28625540ULL, 0x4B670B5EFE7BB00CULL, },   /*   0 */
+    { 0xFBBE00634D93C708ULL, 0x12F7BB1A153F52FCULL, },
+    { 0xAC5AAEAAB9CF8B80ULL, 0x27D8C6FFAB2B2514ULL, },
+    { 0x704F164D5E31E24EULL, 0x8DF188D8A942E2A0ULL, },
+    { 0xB9926B7C7DAF4258ULL, 0xA1227CADDCCE65B6ULL, },
+    { 0xD027BE89FF0A2EF9ULL, 0x170B5050FEA53078ULL, },
+    { 0xB83B580665CABC4AULL, 0x91230822BFF0BA62ULL, },
+    { 0xFC8F23F09AA6B782ULL, 0x93FD6637124275AEULL, },
+    { 0x201E09CD56AEE649ULL, 0xEF5DE039A6A52758ULL, },   /*   8 */
+    { 0xA57CD91365D9E5D7ULL, 0x9321BC9881ECBA5CULL, },
+    { 0xA2E8F6F5C9CBC61BULL, 0xB2C471545E0D7A12ULL, },
+    { 0xA89CF2F131A864AEULL, 0xD2A3E87A5DB986E7ULL, },
+    { 0xE61438E9A652EA0AULL, 0xA85483D97879D41CULL, },
+    { 0x944A35FD192361A8ULL, 0xF3912DA36A0B2D6BULL, },
+    { 0x4630426322BEF79CULL, 0xEB5686F7CB19304EULL, },
+    { 0x8B5AA7A2F259DEADULL, 0xD278CBCD696417E3ULL, },
+};
+
+
+#endif
Signature · 1 line
2.7.4
#6 lore raw

PATCH 3/5 tests/tcg: target/mips: Add a header with MSA wrappers

In reply to Aleksandar Markovic

From: Aleksandar Markovic <[email protected]>

Add a header that contains wrappers around MSA instructions assembler invocations. For now, only bit counting instructions (NLOC, NLZC, and PCNT; each in four data format flavors) are supported.

---
 tests/tcg/mips/include/wrappers_msa.h | 57 +++++++++++++++++++++++++++++++++++
 1 file changed, 57 insertions(+)
 create mode 100644 tests/tcg/mips/include/wrappers_msa.h
tests/tcg/mips/include/wrappers_msa.h new file +57 -0
new file mode 100644
index 0000000..8f8d00b
@@ -0,0 +1,57 @@
+/*
+ *  Header file for wrappers around MSA instructions assembler invocations
+ *
+ *  Copyright (C) 2018  Wave Computing, Inc.
+ *  Copyright (C) 2018  Aleksandar Markovic <[email protected]>
+ *
+ *  This program is free software: you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation, either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program.  If not, see <https://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef WRAPPERS_MSA_H
+#define WRAPPERS_MSA_H
+
+
+#define DO_MSA__WD__WS(suffix, mnemonic)                               \
+static inline void do_msa_##suffix(void *input, void *output)          \
+{                                                                      \
+   __asm__ volatile (                                                  \
+      "move $t0, %0\n\t"                                               \
+      "ld.d $w11, 0($t0)\n\t"                                          \
+      #mnemonic " $w10, $w11\n\t"                                      \
+      "move $t0, %1\n\t"                                               \
+      "st.d $w10, 0($t0)\n\t"                                          \
+      :                                                                \
+      : "r" (input), "r" (output)                                      \
+      : "t0", "memory"                                                 \
+   );                                                                  \
+}
+
+DO_MSA__WD__WS(NLOC_B, nloc.b)
+DO_MSA__WD__WS(NLOC_H, nloc.h)
+DO_MSA__WD__WS(NLOC_W, nloc.w)
+DO_MSA__WD__WS(NLOC_D, nloc.d)
+
+DO_MSA__WD__WS(NLZC_B, nlzc.b)
+DO_MSA__WD__WS(NLZC_H, nlzc.h)
+DO_MSA__WD__WS(NLZC_W, nlzc.w)
+DO_MSA__WD__WS(NLZC_D, nlzc.d)
+
+DO_MSA__WD__WS(PCNT_B, pcnt.b)
+DO_MSA__WD__WS(PCNT_H, pcnt.h)
+DO_MSA__WD__WS(PCNT_W, pcnt.w)
+DO_MSA__WD__WS(PCNT_D, pcnt.d)
+
+
+#endif
Signature · 1 line
2.7.4
#7 lore raw

PATCH 4/5 tests/tcg: target/mips: Add a header with test utilities

In reply to Aleksandar Markovic

From: Aleksandar Markovic <[email protected]>

Add a header that contains test utilities. For now, it contains only a function for checking and printing test results for bit counting and similar MSA instructions.

---
 tests/tcg/mips/include/test_utils.h | 84 +++++++++++++++++++++++++++++++++++++
 1 file changed, 84 insertions(+)
 create mode 100644 tests/tcg/mips/include/test_utils.h
tests/tcg/mips/include/test_utils.h new file +84 -0
new file mode 100644
index 0000000..03f3191
@@ -0,0 +1,84 @@
+/*
+ *  Header file for test utilities
+ *
+ *  Copyright (C) 2018  Wave Computing, Inc.
+ *  Copyright (C) 2018  Aleksandar Markovic <[email protected]>
+ *
+ *  This program is free software: you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation, either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program.  If not, see <https://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef TEST_UTILS_H
+#define TEST_UTILS_H
+
+#include <stdio.h>
+#include <stdint.h>
+#include <inttypes.h>
+#include <string.h>
+
+#define PRINT_RESULTS 0
+
+static inline int32_t check_results(char *instruction_name,
+                                    uint32_t test_count,
+                                    double elapsed_time,
+                                    uint64_t *b128_result,
+                                    uint64_t *b128_expect)
+{
+#if PRINT_RESULTS
+
+    uint32_t i;
+    printf("\n");
+    for (i = 0; i < test_count; i++) {
+        uint64_t a, b;
+        memcpy(&a, (b128_result + 2 * i), 8);
+        memcpy(&b, (b128_result + 2 * i + 1), 8);
+        if (i % 8 != 0) {
+            printf("        { 0x%016llxULL, 0x%016llxULL, },\n", a, b);
+        } else {
+            printf("        { 0x%016llxULL, 0x%016llxULL, },    /* %3d  */\n",
+                   a, b, i);
+        }
+    }
+    printf("\n");
+
+    return 0;
+
+#else
+
+    uint32_t i;
+    uint32_t pass_count = 0;
+    uint32_t fail_count = 0;
+
+    printf("%s:   ", instruction_name);
+    for (i = 0; i < test_count; i++) {
+        if (b128_result[i] == b128_expect[i]) {
+            pass_count++;
+        } else {
+            fail_count++;
+        }
+    }
+
+    printf("PASS: %3d   FAIL: %3d   elapsed time: %5.2f ms\n",
+           pass_count, fail_count, elapsed_time);
+
+    if (fail_count > 0) {
+        return -1;
+    } else {
+        return 0;
+    }
+
+#endif
+}
+
+#endif
Signature · 1 line
2.7.4
#8 lore raw

PATCH 5/5 tests/tcg: target/mips: Add tests for MSA bit counting instructions

In reply to Aleksandar Markovic

From: Aleksandar Markovic <[email protected]>

Add tests for MSA bit counting instructions. Each test consists of 80 test cases, so altogether there are 960 test cases.

---
 .../user/ase/msa/bit_counting/test_msa_nloc_b.c    | 144 +++++++++++++++++++++
 .../user/ase/msa/bit_counting/test_msa_nloc_d.c    | 144 +++++++++++++++++++++
 .../user/ase/msa/bit_counting/test_msa_nloc_h.c    | 144 +++++++++++++++++++++
 .../user/ase/msa/bit_counting/test_msa_nloc_w.c    | 144 +++++++++++++++++++++
 .../user/ase/msa/bit_counting/test_msa_nlzc_b.c    | 144 +++++++++++++++++++++
 .../user/ase/msa/bit_counting/test_msa_nlzc_d.c    | 144 +++++++++++++++++++++
 .../user/ase/msa/bit_counting/test_msa_nlzc_h.c    | 144 +++++++++++++++++++++
 .../user/ase/msa/bit_counting/test_msa_nlzc_w.c    | 144 +++++++++++++++++++++
 .../user/ase/msa/bit_counting/test_msa_pcnt_b.c    | 144 +++++++++++++++++++++
 .../user/ase/msa/bit_counting/test_msa_pcnt_d.c    | 144 +++++++++++++++++++++
 .../user/ase/msa/bit_counting/test_msa_pcnt_h.c    | 144 +++++++++++++++++++++
 .../user/ase/msa/bit_counting/test_msa_pcnt_w.c    | 144 +++++++++++++++++++++
 12 files changed, 1728 insertions(+)
 create mode 100644 tests/tcg/mips/user/ase/msa/bit_counting/test_msa_nloc_b.c
 create mode 100644 tests/tcg/mips/user/ase/msa/bit_counting/test_msa_nloc_d.c
 create mode 100644 tests/tcg/mips/user/ase/msa/bit_counting/test_msa_nloc_h.c
 create mode 100644 tests/tcg/mips/user/ase/msa/bit_counting/test_msa_nloc_w.c
 create mode 100644 tests/tcg/mips/user/ase/msa/bit_counting/test_msa_nlzc_b.c
 create mode 100644 tests/tcg/mips/user/ase/msa/bit_counting/test_msa_nlzc_d.c
 create mode 100644 tests/tcg/mips/user/ase/msa/bit_counting/test_msa_nlzc_h.c
 create mode 100644 tests/tcg/mips/user/ase/msa/bit_counting/test_msa_nlzc_w.c
 create mode 100644 tests/tcg/mips/user/ase/msa/bit_counting/test_msa_pcnt_b.c
 create mode 100644 tests/tcg/mips/user/ase/msa/bit_counting/test_msa_pcnt_d.c
 create mode 100644 tests/tcg/mips/user/ase/msa/bit_counting/test_msa_pcnt_h.c
 create mode 100644 tests/tcg/mips/user/ase/msa/bit_counting/test_msa_pcnt_w.c
tests/tcg/mips/user/ase/msa/bit_counting/test_msa_nloc_b.c new file +144 -0
new file mode 100644
index 0000000..8d174ac
@@ -0,0 +1,144 @@
+/*
+ *  Test program for MSA instruction PCNT.B
+ *
+ *  Copyright (C) 2018  Wave Computing, Inc.
+ *  Copyright (C) 2018  Aleksandar Markovic <[email protected]>
+ *
+ *  This program is free software: you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation, either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program.  If not, see <https://www.gnu.org/licenses/>.
+ *
+ */
+
+#include <sys/time.h>
+#include <stdint.h>
+
+#include "../../../include/wrappers_msa.h"
+#include "../../../include/test_inputs.h"
+#include "../../../include/test_utils.h"
+
+#define TEST_COUNT_TOTAL (PATTERN_INPUTS_COUNT + RANDOM_INPUTS_COUNT)
+
+
+int32_t main(void)
+{
+    char *instruction_name = "NLOC.B";
+    int32_t ret;
+    uint32_t i;
+    struct timeval start, end;
+    double elapsed_time;
+
+    uint64_t b128_result[TEST_COUNT_TOTAL][2];
+    uint64_t b128_expect[TEST_COUNT_TOTAL][2] = {
+        { 0x0808080808080808ULL, 0x0808080808080808ULL, },    /*   0  */
+        { 0x0000000000000000ULL, 0x0000000000000000ULL, },
+        { 0x0101010101010101ULL, 0x0101010101010101ULL, },
+        { 0x0000000000000000ULL, 0x0000000000000000ULL, },
+        { 0x0202020202020202ULL, 0x0202020202020202ULL, },
+        { 0x0000000000000000ULL, 0x0000000000000000ULL, },
+        { 0x0301000301000301ULL, 0x0003010003010003ULL, },
+        { 0x0000020000020000ULL, 0x0200000200000200ULL, },
+        { 0x0404040404040404ULL, 0x0404040404040404ULL, },    /*   8  */
+        { 0x0000000000000000ULL, 0x0000000000000000ULL, },
+        { 0x0500000103050000ULL, 0x0103050000010305ULL, },
+        { 0x0002040000000204ULL, 0x0000000204000000ULL, },
+        { 0x0600020600020600ULL, 0x0206000206000206ULL, },
+        { 0x0004000004000004ULL, 0x0000040000040000ULL, },
+        { 0x0700050003000107ULL, 0x0005000300010700ULL, },
+        { 0x0006000400020000ULL, 0x0600040002000006ULL, },
+        { 0x0800080008000800ULL, 0x0800080008000800ULL, },    /*  16  */
+        { 0x0008000800080008ULL, 0x0008000800080008ULL, },
+        { 0x0801000300050007ULL, 0x0008010003000500ULL, },
+        { 0x0000020004000600ULL, 0x0800000200040006ULL, },
+        { 0x0802000600080200ULL, 0x0600080200060008ULL, },
+        { 0x0000040008000004ULL, 0x0008000004000800ULL, },
+        { 0x0803000801000700ULL, 0x0005000803000801ULL, },
+        { 0x0000060000040008ULL, 0x0200080000060000ULL, },
+        { 0x0804000804000804ULL, 0x0008040008040008ULL, },    /*  24  */
+        { 0x0000080000080000ULL, 0x0800000800000800ULL, },
+        { 0x0805000007000008ULL, 0x0100080300080500ULL, },
+        { 0x0000080200080400ULL, 0x0006000008000008ULL, },
+        { 0x0806000008020008ULL, 0x0600000802000806ULL, },
+        { 0x0000080400000800ULL, 0x0008040000080000ULL, },
+        { 0x0807000008050000ULL, 0x0803000008010008ULL, },
+        { 0x0000080600000804ULL, 0x0000080200000800ULL, },
+        { 0x0808000008080000ULL, 0x0808000008080000ULL, },    /*  32  */
+        { 0x0000080800000808ULL, 0x0000080800000808ULL, },
+        { 0x0808010000080300ULL, 0x0008050000080700ULL, },
+        { 0x0000000802000008ULL, 0x0400000806000008ULL, },
+        { 0x0808020000080600ULL, 0x0008080200000806ULL, },
+        { 0x0000000804000008ULL, 0x0800000008040000ULL, },
+        { 0x0808030000080801ULL, 0x0000080700000008ULL, },
+        { 0x0000000806000000ULL, 0x0804000008080200ULL, },
+        { 0x0808040000080804ULL, 0x0000080804000008ULL, },    /*  40  */
+        { 0x0000000808000000ULL, 0x0808000000080800ULL, },
+        { 0x0808050000000807ULL, 0x0000000808010000ULL, },
+        { 0x0000000808020000ULL, 0x0808040000000806ULL, },
+        { 0x0808060000000808ULL, 0x0200000808060000ULL, },
+        { 0x0000000808040000ULL, 0x0008080000000808ULL, },
+        { 0x0808070000000808ULL, 0x0500000008080300ULL, },
+        { 0x0000000808060000ULL, 0x0008080400000008ULL, },
+        { 0x0808080000000808ULL, 0x0800000008080800ULL, },    /*  48  */
+        { 0x0000000808080000ULL, 0x0008080800000008ULL, },
+        { 0x0808080100000008ULL, 0x0803000000080805ULL, },
+        { 0x0000000008080200ULL, 0x0000080804000000ULL, },
+        { 0x0808080200000008ULL, 0x0806000000080808ULL, },
+        { 0x0000000008080400ULL, 0x0000080808000000ULL, },
+        { 0x0808080300000008ULL, 0x0808010000000808ULL, },
+        { 0x0000000008080600ULL, 0x0000000808040000ULL, },
+        { 0x0808080400000008ULL, 0x0808040000000808ULL, },    /*  56  */
+        { 0x0000000008080800ULL, 0x0000000808080000ULL, },
+        { 0x0808080500000000ULL, 0x0808070000000008ULL, },
+        { 0x0000000008080802ULL, 0x0000000808080400ULL, },
+        { 0x0808080600000000ULL, 0x0808080200000008ULL, },
+        { 0x0000000008080804ULL, 0x0000000008080800ULL, },
+        { 0x0808080700000000ULL, 0x0808080500000000ULL, },
+        { 0x0000000008080806ULL, 0x0000000008080804ULL, },
+        { 0x0100030200000000ULL, 0x0000000007000100ULL, },    /*  64  */
+        { 0x0501000000010200ULL, 0x0004010000000006ULL, },
+        { 0x0100010101020101ULL, 0x0002020801000000ULL, },
+        { 0x0000000000000300ULL, 0x0104010201000301ULL, },
+        { 0x0101000000010000ULL, 0x0100000102020001ULL, },
+        { 0x0200010108000005ULL, 0x0000000007010000ULL, },
+        { 0x0100000000020100ULL, 0x0100000001040100ULL, },
+        { 0x0601000401010101ULL, 0x0106000000000001ULL, },
+        { 0x0000000200010300ULL, 0x0300030001010000ULL, },    /*  72  */
+        { 0x0100020000020302ULL, 0x0100010101030100ULL, },
+        { 0x0103040402020200ULL, 0x0102000000000000ULL, },
+        { 0x0101040400010001ULL, 0x0201030000010103ULL, },
+        { 0x0300000301000300ULL, 0x0100010200000200ULL, },
+        { 0x0100000600000001ULL, 0x0401000100000000ULL, },
+        { 0x0000000000010401ULL, 0x0300010402000000ULL, },
+        { 0x0100010104000201ULL, 0x0200020200000003ULL, },
+    };
+
+    gettimeofday(&start, NULL);
+
+    for (i = 0; i < TEST_COUNT_TOTAL; i++) {
+        if (i < PATTERN_INPUTS_COUNT) {
+            do_msa_NLOC_B(b128_pattern[i], b128_result[i]);
+        } else {
+            do_msa_NLOC_B(b128_random[i - PATTERN_INPUTS_COUNT],
+                          b128_result[i]);
+        }
+    }
+
+    gettimeofday(&end, NULL);
+
+    elapsed_time = (end.tv_sec - start.tv_sec) * 1000.0;
+    elapsed_time += (end.tv_usec - start.tv_usec) / 1000.0;
+
+    ret = check_results(instruction_name, TEST_COUNT_TOTAL, elapsed_time,
+                        &b128_result[0][0], &b128_expect[0][0]);
+
+    return ret;
+}
tests/tcg/mips/user/ase/msa/bit_counting/test_msa_nloc_d.c new file +144 -0

144 lines not on this page · raw message

tests/tcg/mips/user/ase/msa/bit_counting/test_msa_nloc_h.c new file +144 -0

144 lines not on this page · raw message

tests/tcg/mips/user/ase/msa/bit_counting/test_msa_nloc_w.c new file +144 -0

144 lines not on this page · raw message

tests/tcg/mips/user/ase/msa/bit_counting/test_msa_nlzc_b.c new file +144 -0

144 lines not on this page · raw message

tests/tcg/mips/user/ase/msa/bit_counting/test_msa_nlzc_d.c new file +144 -0

144 lines not on this page · raw message

tests/tcg/mips/user/ase/msa/bit_counting/test_msa_nlzc_h.c new file +144 -0

144 lines not on this page · raw message

tests/tcg/mips/user/ase/msa/bit_counting/test_msa_nlzc_w.c new file +144 -0

144 lines not on this page · raw message

tests/tcg/mips/user/ase/msa/bit_counting/test_msa_pcnt_b.c new file +144 -0

144 lines not on this page · raw message

tests/tcg/mips/user/ase/msa/bit_counting/test_msa_pcnt_d.c new file +144 -0

144 lines not on this page · raw message

tests/tcg/mips/user/ase/msa/bit_counting/test_msa_pcnt_h.c new file +144 -0

144 lines not on this page · raw message

tests/tcg/mips/user/ase/msa/bit_counting/test_msa_pcnt_w.c new file +144 -0

144 lines not on this page · raw message

Signature · 1 line
2.7.4