aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathan Sidwell <nathan@codesourcery.com>2015-10-30 00:13:22 +0000
committerNathan Sidwell <nathan@gcc.gnu.org>2015-10-30 00:13:22 +0000
commita0e701d8a2d31d3fcbaad4de67639aadca7a1681 (patch)
treedd2241361205d8674dc6b7d973e1d78df3ddc6d4
parente7c6980e55d974035a4d85b3551eca47181d1bfc (diff)
downloadgcc-a0e701d8a2d31d3fcbaad4de67639aadca7a1681.zip
gcc-a0e701d8a2d31d3fcbaad4de67639aadca7a1681.tar.gz
gcc-a0e701d8a2d31d3fcbaad4de67639aadca7a1681.tar.bz2
openacc.h (enum acc_device_t): Reformat.
gcc/ * openacc.h (enum acc_device_t): Reformat. Ensure layout compatibility. (enum acc_async_t): Reformat. (acc_on_device): Declare compatible with builtin and provide C++ wrapper. * testsuite/libgomp.oacc-c-c++-common/acc-on-device.c: New. gcc/testsuite/ * c-c++-common/goacc/acc_on_device-2-off.c: Delete. * c-c++-common/goacc/acc_on_device-2.c: Delete. From-SVN: r229562
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/c-c++-common/goacc/acc_on_device-2-off.c24
-rw-r--r--gcc/testsuite/c-c++-common/goacc/acc_on_device-2.c28
-rw-r--r--libgomp/ChangeLog9
-rw-r--r--libgomp/openacc.h50
-rw-r--r--libgomp/testsuite/libgomp.oacc-c-c++-common/acc-on-device.c11
6 files changed, 56 insertions, 71 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 71f3148..ffefb43c 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2015-10-29 Nathan Sidwell <nathan@codesourcery.com>
+
+ * c-c++-common/goacc/acc_on_device-2-off.c: Delete.
+ * c-c++-common/goacc/acc_on_device-2.c: Delete.
+
2015-10-29 Richard Sandiford <richard.sandiford@arm.com>
* gcc.dg/torture/builtin-convert-1.c: Require c99_runtime.
diff --git a/gcc/testsuite/c-c++-common/goacc/acc_on_device-2-off.c b/gcc/testsuite/c-c++-common/goacc/acc_on_device-2-off.c
deleted file mode 100644
index 59c72f7..0000000
--- a/gcc/testsuite/c-c++-common/goacc/acc_on_device-2-off.c
+++ /dev/null
@@ -1,24 +0,0 @@
-/* Have to enable optimizations, as otherwise builtins won't be expanded. */
-/* { dg-additional-options "-O -fdump-rtl-expand -fno-openacc" } */
-
-#if __cplusplus
-extern "C" {
-#endif
-
-typedef enum acc_device_t { acc_device_X = 123 } acc_device_t;
-extern int acc_on_device (acc_device_t);
-
-#if __cplusplus
-}
-#endif
-
-int
-f (void)
-{
- const acc_device_t dev = acc_device_X;
- return acc_on_device (dev);
-}
-
-/* Without -fopenacc, we're expecting one call.
- { dg-final { scan-rtl-dump-times "\\\(call \[^\\n\]* acc_on_device" 1 "expand" } } */
-
diff --git a/gcc/testsuite/c-c++-common/goacc/acc_on_device-2.c b/gcc/testsuite/c-c++-common/goacc/acc_on_device-2.c
deleted file mode 100644
index ef622a8..0000000
--- a/gcc/testsuite/c-c++-common/goacc/acc_on_device-2.c
+++ /dev/null
@@ -1,28 +0,0 @@
-/* Have to enable optimizations, as otherwise builtins won't be expanded. */
-/* { dg-additional-options "-O -fdump-rtl-expand" } */
-
-#if __cplusplus
-extern "C" {
-#endif
-
-typedef enum acc_device_t { acc_device_X = 123 } acc_device_t;
-extern int acc_on_device (acc_device_t);
-
-#if __cplusplus
-}
-#endif
-
-int
-f (void)
-{
- const acc_device_t dev = acc_device_X;
- return acc_on_device (dev);
-}
-
-/* With -fopenacc, we're expecting the builtin to be expanded, so no calls.
- TODO: in C++, even under extern "C", the use of enum for acc_device_t
- perturbs expansion as a builtin, which expects an int parameter. It's fine
- when changing acc_device_t to plain int, but that's not what we're doing in
- <openacc.h>.
-
- { dg-final { scan-rtl-dump-times "\\\(call \[^\\n\]* acc_on_device" 0 "expand" { xfail c++ } } } */
diff --git a/libgomp/ChangeLog b/libgomp/ChangeLog
index c78881b..4d19066 100644
--- a/libgomp/ChangeLog
+++ b/libgomp/ChangeLog
@@ -1,3 +1,12 @@
+2015-10-29 Nathan Sidwell <nathan@codesourcery.com>
+
+ * openacc.h (enum acc_device_t): Reformat. Ensure layout
+ compatibility.
+ (enum acc_async_t): Reformat.
+ (acc_on_device): Declare compatible with builtin and provide C++
+ wrapper.
+ * testsuite/libgomp.oacc-c-c++-common/acc-on-device.c: New.
+
2015-10-29 Thomas Schwinge <thomas@codesourcery.com>
Cesar Philippidis <cesar@codesourcery.com>
diff --git a/libgomp/openacc.h b/libgomp/openacc.h
index fc353e1..30b18db 100644
--- a/libgomp/openacc.h
+++ b/libgomp/openacc.h
@@ -47,24 +47,25 @@ extern "C" {
#endif
/* Types */
-typedef enum acc_device_t
- {
- /* Keep in sync with include/gomp-constants.h. */
- acc_device_none = 0,
- acc_device_default = 1,
- acc_device_host = 2,
- /* acc_device_host_nonshm = 3 removed. */
- acc_device_not_host = 4,
- acc_device_nvidia = 5,
- _ACC_device_hwm
- } acc_device_t;
-
-typedef enum acc_async_t
- {
- /* Keep in sync with include/gomp-constants.h. */
- acc_async_noval = -1,
- acc_async_sync = -2
- } acc_async_t;
+typedef enum acc_device_t {
+ /* Keep in sync with include/gomp-constants.h. */
+ acc_device_none = 0,
+ acc_device_default = 1,
+ acc_device_host = 2,
+ /* acc_device_host_nonshm = 3 removed. */
+ acc_device_not_host = 4,
+ acc_device_nvidia = 5,
+ _ACC_device_hwm,
+ /* Ensure enumeration is layout compatible with int. */
+ _ACC_highest = __INT_MAX__,
+ _ACC_neg = -1
+} acc_device_t;
+
+typedef enum acc_async_t {
+ /* Keep in sync with include/gomp-constants.h. */
+ acc_async_noval = -1,
+ acc_async_sync = -2
+} acc_async_t;
int acc_get_num_devices (acc_device_t) __GOACC_NOTHROW;
void acc_set_device_type (acc_device_t) __GOACC_NOTHROW;
@@ -79,7 +80,11 @@ void acc_wait_all (void) __GOACC_NOTHROW;
void acc_wait_all_async (int) __GOACC_NOTHROW;
void acc_init (acc_device_t) __GOACC_NOTHROW;
void acc_shutdown (acc_device_t) __GOACC_NOTHROW;
-int acc_on_device (acc_device_t) __GOACC_NOTHROW;
+#ifdef __cplusplus
+int acc_on_device (int __arg) __GOACC_NOTHROW;
+#else
+int acc_on_device (acc_device_t __arg) __GOACC_NOTHROW;
+#endif
void *acc_malloc (size_t) __GOACC_NOTHROW;
void acc_free (void *) __GOACC_NOTHROW;
/* Some of these would be more correct with const qualifiers, but
@@ -113,6 +118,13 @@ int acc_set_cuda_stream (int, void *) __GOACC_NOTHROW;
#ifdef __cplusplus
}
+
+/* Forwarding function with correctly typed arg. */
+
+inline int acc_on_device (acc_device_t __arg) __GOACC_NOTHROW
+{
+ return acc_on_device ((int) __arg);
+}
#endif
#endif /* _OPENACC_H */
diff --git a/libgomp/testsuite/libgomp.oacc-c-c++-common/acc-on-device.c b/libgomp/testsuite/libgomp.oacc-c-c++-common/acc-on-device.c
new file mode 100644
index 0000000..88c000e
--- /dev/null
+++ b/libgomp/testsuite/libgomp.oacc-c-c++-common/acc-on-device.c
@@ -0,0 +1,11 @@
+/* { dg-do compile } */
+/* { dg-additional-options "-O2" } */
+
+#include <openacc.h>
+
+int Foo (acc_device_t x)
+{
+ return acc_on_device (x);
+}
+
+/* { dg-final { scan-assembler-not "acc_on_device" } } */