aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTobias Burnus <tobias@codesourcery.com>2021-04-13 08:58:51 +0000
committerThomas Schwinge <thomas@codesourcery.com>2023-09-04 14:49:50 +0200
commitfe0f9e09413047484441468b05288412760d8a09 (patch)
treee7c707fb087cb597ba8bdb811e1c9f7db8c3c0a5
parentb3ab28c3e85af7995fffb87eb190ef942b7e9e4a (diff)
downloadgcc-fe0f9e09413047484441468b05288412760d8a09.zip
gcc-fe0f9e09413047484441468b05288412760d8a09.tar.gz
gcc-fe0f9e09413047484441468b05288412760d8a09.tar.bz2
Add 'libgomp.c-c++-common/pr100059-1.c'
For nvptx offloading, it'll FAIL its execution test until nvptx-tools updated to include commit 1b5946d78ef5dcfb640e9f545a7c791b7f623911 "Merge commit '26095fd01232061de9f79decb3e8222ef7b46191' into HEAD [#29]", <https://github.com/MentorEmbedded/nvptx-tools/commit/1b5946d78ef5dcfb640e9f545a7c791b7f623911>. libgomp/ * testsuite/libgomp.c-c++-common/pr100059-1.c: New. Co-authored-by: Thomas Schwinge <thomas@codesourcery.com>
-rw-r--r--libgomp/testsuite/libgomp.c-c++-common/pr100059-1.c55
1 files changed, 55 insertions, 0 deletions
diff --git a/libgomp/testsuite/libgomp.c-c++-common/pr100059-1.c b/libgomp/testsuite/libgomp.c-c++-common/pr100059-1.c
new file mode 100644
index 0000000..af12295
--- /dev/null
+++ b/libgomp/testsuite/libgomp.c-c++-common/pr100059-1.c
@@ -0,0 +1,55 @@
+/* Based on sollve_vv's tests/5.0/declare_target/test_nested_declare_target.c. */
+
+#define N 1024
+int a[N], b[N], c[N];
+int i = 0;
+
+void
+update ()
+{
+ for (i = 0; i < N; i++)
+ {
+ a[i] += 1;
+ b[i] += 2;
+ c[i] += 3;
+ }
+}
+
+#pragma omp declare target
+#pragma omp declare target link(a,c,b,i)
+#pragma omp declare target to(update)
+#pragma omp end declare target
+
+int
+main ()
+{
+ for (i = 0; i < N; i++)
+ {
+ a[i] = i;
+ b[i] = i + 1;
+ c[i] = i + 2;
+ }
+
+ //__builtin_printf("i=5: A=%d, B=%d, C=%d\n", a[5], b[5], c[5]);
+
+ #pragma omp target map(to: i) map(tofrom: a, b, c)
+ {
+ update(); /* Device. */
+ }
+
+ //__builtin_printf("i=5: A=%d, B=%d, C=%d\n", a[5], b[5], c[5]);
+
+ for (i = 0; i < N; i++)
+ if ( a[i] != i + 1 || b[i] != i + 3 || c[i] != i + 5)
+ __builtin_abort();
+
+ update(); /* Host. */
+
+ //__builtin_printf("i=5: A=%d, B=%d, C=%d\n", a[5], b[5], c[5]);
+
+ for (i = 0; i < N; i++)
+ if ( a[i] != i + 2 || b[i] != i + 5 || c[i] != i + 8)
+ __builtin_abort ();
+
+ return 0;
+}