rs6000: add effective-target test ppc_mma_hw
authorAaron Sawdey <acsawdey@linux.ibm.com>
Fri, 10 Jul 2020 22:46:17 +0000 (17:46 -0500)
committerAaron Sawdey <acsawdey@linux.ibm.com>
Mon, 13 Jul 2020 20:17:38 +0000 (15:17 -0500)
Add a test for dejagnu to determine if execution of MMA instructions is
supported in the test environment. Add an execution test to make sure
that __builtin_cpu_supports("mma") is true if we can execute MMA
instructions.

gcc/testsuite/

* lib/target-supports.exp (check_ppc_mma_hw_available):
New function.
(is-effective-target): Add ppc_mma_hw.
(is-effective-target-keyword): Add ppc_mma_hw.
* gcc.target/powerpc/mma-supported.c: New file.
* gcc.target/powerpc/mma-single-test.c: Require ppc_mma_hw.
* gcc.target/powerpc/mma-double-test.c: Require ppc_mma_hw.

gcc/testsuite/gcc.target/powerpc/mma-double-test.c
gcc/testsuite/gcc.target/powerpc/mma-single-test.c
gcc/testsuite/gcc.target/powerpc/mma-supported.c [new file with mode: 0644]
gcc/testsuite/lib/target-supports.exp

index 9ba0010978f90e5140327535f6fa7f434836c8bc..ac84ae3000485064e2af06d0834c14a0dad36054 100755 (executable)
@@ -1,5 +1,6 @@
 /* { dg-do run } */
 /* { dg-require-effective-target power10_hw } */
+/* { dg-require-effective-target ppc_mma_hw } */
 /* { dg-options "-mdejagnu-cpu=power10 -O2" } */
 
 #include <stdio.h>
index aa71fa7f0afd469b5539f723818463604ec8b7ff..15369a640258f1fb2ace22985824b20228c91ce3 100755 (executable)
@@ -1,5 +1,6 @@
 /* { dg-do run } */
 /* { dg-require-effective-target power10_hw } */
+/* { dg-require-effective-target ppc_mma_hw } */
 /* { dg-options "-mdejagnu-cpu=power10 -O2" } */
 
 #include <stdio.h>
diff --git a/gcc/testsuite/gcc.target/powerpc/mma-supported.c b/gcc/testsuite/gcc.target/powerpc/mma-supported.c
new file mode 100644 (file)
index 0000000..92d9a7f
--- /dev/null
@@ -0,0 +1,25 @@
+/* { dg-do run } */
+/* { dg-require-effective-target ppc_mma_hw } */
+/* { dg-options "-mdejagnu-cpu=power10 -O2" } */
+
+/* This test will only run when the ppc_mma_hw test passes.  If that
+   test passes, then we expect to see that mma feature is supported.
+   If this is not the case, then the test environment has problems. */
+
+#include <stdio.h>
+#include <stdlib.h>
+
+int
+main (int argc, char *argv[])
+{
+#ifdef __BUILTIN_CPU_SUPPORTS__
+  if ( !__builtin_cpu_supports ("mma"))
+    {
+#ifdef DEBUG      
+      printf ("Error: __builtin_cpu_supports says mma not supported, but ppc_mma_hw test passed.\n");
+#endif
+      abort();
+    }
+#endif
+  exit (0);
+}
index aeb0351073d71b05f88381711a574a37f7cd9f91..2e4c696fdd1e08f3323b8940e054049829b822be 100644 (file)
@@ -2234,6 +2234,31 @@ proc check_power10_hw_available { } {
     }]
 }
 
+# Return 1 if the target supports executing MMA instructions, 0 otherwise.
+# Cache the result.  It is assumed that if a simulator does not support the
+# MMA instructions, that it will generate an error and this test will fail.
+
+proc check_ppc_mma_hw_available { } {
+    return [check_cached_effective_target ppc_mma_hw_available {
+       check_runtime_nocache ppc_mma_hw_available {
+           #include <altivec.h>
+           typedef double v4sf_t __attribute__ ((vector_size (16)));
+
+           int main()
+           {
+               __vector_quad acc0;
+               v4sf_t result[4];
+               result[0][0] = 1.0;
+               __builtin_mma_xxsetaccz (&acc0);
+               __builtin_mma_disassemble_acc (result, &acc0);
+               if (result[0][0] != 0.0)
+                  return 1;
+               return 0;
+           }
+       } "-mcpu=power10"
+    }]
+}
+
 # Return 1 if the target supports executing __float128 on PowerPC via software
 # emulation, 0 otherwise.  Cache the result.
 
@@ -7830,6 +7855,7 @@ proc is-effective-target { arg } {
          "ppc_float128_hw" { set selected [check_ppc_float128_hw_available] }
          "ppc_recip_hw"   { set selected [check_ppc_recip_hw_available] }
          "ppc_cpu_supports_hw" { set selected [check_ppc_cpu_supports_hw_available] }
+         "ppc_mma_hw"     { set selected [check_ppc_mma_hw_available] }
          "dfp_hw"         { set selected [check_dfp_hw_available] }
          "htm_hw"         { set selected [check_htm_hw_available] }
          "named_sections" { set selected [check_named_sections_available] }
@@ -7860,6 +7886,7 @@ proc is-effective-target-keyword { arg } {
          "ppc_float128_sw" { return 1 }
          "ppc_float128_hw" { return 1 }
          "ppc_recip_hw"   { return 1 }
+         "ppc_mma_hw"     { return 1 }
          "dfp_hw"         { return 1 }
          "htm_hw"         { return 1 }
          "named_sections" { return 1 }