This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[gomp4] Add tests for atomic read / write.
- From: James Norris <jnorris at codesourcery dot com>
- To: <gcc-patches at gcc dot gnu dot org>
- Cc: Thomas Schwinge <Thomas_Schwinge at mentor dot com>
- Date: Wed, 10 Jun 2015 07:16:32 -0500
- Subject: [gomp4] Add tests for atomic read / write.
- Authentication-results: sourceware.org; auth=none
Hi,
This patch adds tests for OpenACC atomic read and atomic write.
Patch applied to gomp-4_0-branch
Regards,
Jim
diff --git a/libgomp/testsuite/libgomp.oacc-c-c++-common/atomic_rw-1.c b/libgomp/testsuite/libgomp.oacc-c-c++-common/atomic_rw-1.c
new file mode 100644
index 0000000..ae4f22e
--- /dev/null
+++ b/libgomp/testsuite/libgomp.oacc-c-c++-common/atomic_rw-1.c
@@ -0,0 +1,34 @@
+/* { dg-do run } */
+
+#include <stdlib.h>
+
+int
+main(int argc, char **argv)
+{
+ int v1, v2;
+ int x;
+
+ x = 99;
+
+#pragma acc parallel copy (v1, v2, x)
+ {
+
+#pragma acc atomic read
+ v1 = x;
+
+#pragma acc atomic write
+ x = 32;
+
+#pragma acc atomic read
+ v2 = x;
+
+ }
+
+ if (v1 != 99)
+ abort ();
+
+ if (v2 != 32)
+ abort ();
+
+ return 0;
+}