]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Add 'libgomp.c++/pr96835-1{,-O0}.C', 'libgomp.oacc-c++/pr96835-1.C' [PR96835]
authorThomas Schwinge <tschwinge@baylibre.com>
Tue, 8 Oct 2024 07:59:45 +0000 (09:59 +0200)
committerThomas Schwinge <tschwinge@baylibre.com>
Mon, 24 Mar 2025 08:39:21 +0000 (09:39 +0100)
PR libgomp/96835
libgomp/
* testsuite/libgomp.c++/pr96835-1.C: New.
* testsuite/libgomp.c++/pr96835-1-O0.C: Likewise.
* testsuite/libgomp.oacc-c++/pr96835-1.C: Likewise.

libgomp/testsuite/libgomp.c++/pr96835-1-O0.C [new file with mode: 0644]
libgomp/testsuite/libgomp.c++/pr96835-1.C [new file with mode: 0644]
libgomp/testsuite/libgomp.oacc-c++/pr96835-1.C [new file with mode: 0644]

diff --git a/libgomp/testsuite/libgomp.c++/pr96835-1-O0.C b/libgomp/testsuite/libgomp.c++/pr96835-1-O0.C
new file mode 100644 (file)
index 0000000..85e4290
--- /dev/null
@@ -0,0 +1,3 @@
+// { dg-additional-options -O0 }
+
+#include "pr96835-1.C"
diff --git a/libgomp/testsuite/libgomp.c++/pr96835-1.C b/libgomp/testsuite/libgomp.c++/pr96835-1.C
new file mode 100644 (file)
index 0000000..c9f6475
--- /dev/null
@@ -0,0 +1,45 @@
+// See also '../libgomp.oacc-c++/pr96835-1.C'.
+#ifndef ALWAYS_INLINE
+# define ALWAYS_INLINE
+#endif
+
+#pragma omp declare target
+
+template<int sz>
+struct vector {
+  int values_[sz];
+  vector();
+  ALWAYS_INLINE
+  vector(int const& init_val);
+  ALWAYS_INLINE
+  int dot(vector o) {
+    int res = 0;
+    for (int i = 0; i < sz; ++ i)
+      res += values_[i] * o.values_[i];
+    return res;
+  }
+};
+
+template<int sz>
+vector<sz>::vector(int const& init_val) {
+  for (int i = 0; i < sz; ++ i) values_[i] = init_val;
+}
+template<int sz>
+vector<sz>::vector() : vector(0) {
+}
+
+#pragma omp end declare target
+
+int main() {
+  int res = 0;
+  #pragma omp target map(from:res)
+  #pragma acc serial copyout(res)
+  {
+    vector<4> v1(1);
+    vector<4> v2(2);
+    res = v1.dot(v2);
+  }
+  if (res != 8)
+    __builtin_abort();
+  return 0;
+}
diff --git a/libgomp/testsuite/libgomp.oacc-c++/pr96835-1.C b/libgomp/testsuite/libgomp.oacc-c++/pr96835-1.C
new file mode 100644 (file)
index 0000000..0a6ee22
--- /dev/null
@@ -0,0 +1,6 @@
+// { dg-additional-options -fno-inline } for stable results regarding OpenACC 'routine'.
+// But actually, as none of the '#pragma acc routine' syntax is accepted (see '../libgomp.c++/pr101544-1.C'), force inlining:
+#define ALWAYS_INLINE inline __attribute__((always_inline))
+
+#include "../libgomp.c++/pr96835-1.C"
+//TODO { dg-prune-output {using 'vector_length \(32\)', ignoring 1} }