aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulian Brown <julian@codesourcery.com>2015-05-28 09:29:19 +0000
committerJulian Brown <jules@gcc.gnu.org>2015-05-28 09:29:19 +0000
commit32eaed9380bfff86977823c0bf88fb69c2a375a6 (patch)
tree2bd3ae354d8dfe258860472c06b79b535af2b30b
parent7d9880c94ce8d5bbce64f56f4e75c1ed073a1e52 (diff)
downloadgcc-32eaed9380bfff86977823c0bf88fb69c2a375a6.zip
gcc-32eaed9380bfff86977823c0bf88fb69c2a375a6.tar.gz
gcc-32eaed9380bfff86977823c0bf88fb69c2a375a6.tar.bz2
re PR libgomp/65742 (Several libgomp.oacc-* failures after r221922.)
PR libgomp/65742 gcc/ * builtins.c (expand_builtin_acc_on_device): Don't use open-coded sequence for !ACCEL_COMPILER. libgomp/ * oacc-init.c (plugin/plugin-host.h): Include. (acc_on_device): Check whether we're in an offloaded region for host_nonshm plugin. Don't use __builtin_acc_on_device. * plugin/plugin-host.c (GOMP_OFFLOAD_openacc_parallel): Set nonshm_exec flag in thread-local data. (GOMP_OFFLOAD_openacc_create_thread_data): Allocate thread-local data for host_nonshm plugin. (GOMP_OFFLOAD_openacc_destroy_thread_data): Free thread-local data for host_nonshm plugin. * plugin/plugin-host.h: New. From-SVN: r223801
-rw-r--r--gcc/ChangeLog7
-rw-r--r--gcc/builtins.c9
-rw-r--r--libgomp/ChangeLog16
-rw-r--r--libgomp/oacc-init.c14
-rw-r--r--libgomp/plugin/plugin-host.c21
-rw-r--r--libgomp/plugin/plugin-host.h37
6 files changed, 94 insertions, 10 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 712dacc..a376938 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,10 @@
+2015-05-28 Julian Brown <julian@codesourcery.com>
+
+ PR libgomp/65742
+
+ * builtins.c (expand_builtin_acc_on_device): Don't use open-coded
+ sequence for !ACCEL_COMPILER.
+
2015-05-28 Nick Clifton <nickc@redhat.com>
* config/rx/rx.c (push_regs): New function. Extracts code from...
diff --git a/gcc/builtins.c b/gcc/builtins.c
index d92535e..4ce8e52 100644
--- a/gcc/builtins.c
+++ b/gcc/builtins.c
@@ -5913,6 +5913,7 @@ expand_stack_save (void)
static rtx
expand_builtin_acc_on_device (tree exp, rtx target)
{
+#ifdef ACCEL_COMPILER
if (!validate_arglist (exp, INTEGER_TYPE, VOID_TYPE))
return NULL_RTX;
@@ -5921,13 +5922,8 @@ expand_builtin_acc_on_device (tree exp, rtx target)
/* Return (arg == v1 || arg == v2) ? 1 : 0. */
machine_mode v_mode = TYPE_MODE (TREE_TYPE (arg));
rtx v = expand_normal (arg), v1, v2;
-#ifdef ACCEL_COMPILER
v1 = GEN_INT (GOMP_DEVICE_NOT_HOST);
v2 = GEN_INT (ACCEL_COMPILER_acc_device);
-#else
- v1 = GEN_INT (GOMP_DEVICE_NONE);
- v2 = GEN_INT (GOMP_DEVICE_HOST);
-#endif
machine_mode target_mode = TYPE_MODE (integer_type_node);
if (!target || !register_operand (target, target_mode))
target = gen_reg_rtx (target_mode);
@@ -5941,6 +5937,9 @@ expand_builtin_acc_on_device (tree exp, rtx target)
emit_label (done_label);
return target;
+#else
+ return NULL;
+#endif
}
diff --git a/libgomp/ChangeLog b/libgomp/ChangeLog
index bfae17c..fda3b5f 100644
--- a/libgomp/ChangeLog
+++ b/libgomp/ChangeLog
@@ -1,3 +1,19 @@
+2015-05-28 Julian Brown <julian@codesourcery.com>
+
+ PR libgomp/65742
+
+ * oacc-init.c (plugin/plugin-host.h): Include.
+ (acc_on_device): Check whether we're in an offloaded region for
+ host_nonshm
+ plugin. Don't use __builtin_acc_on_device.
+ * plugin/plugin-host.c (GOMP_OFFLOAD_openacc_parallel): Set
+ nonshm_exec flag in thread-local data.
+ (GOMP_OFFLOAD_openacc_create_thread_data): Allocate thread-local
+ data for host_nonshm plugin.
+ (GOMP_OFFLOAD_openacc_destroy_thread_data): Free thread-local data
+ for host_nonshm plugin.
+ * plugin/plugin-host.h: New.
+
2015-05-27 Uros Bizjak <ubizjak@gmail.com>
* config/linux/ia64/futex.h (sys_futex0) Change operand "op" to int.
diff --git a/libgomp/oacc-init.c b/libgomp/oacc-init.c
index 54995e3..8e5fc3b 100644
--- a/libgomp/oacc-init.c
+++ b/libgomp/oacc-init.c
@@ -29,6 +29,7 @@
#include "libgomp.h"
#include "oacc-int.h"
#include "openacc.h"
+#include "plugin/plugin-host.h"
#include <assert.h>
#include <stdlib.h>
#include <strings.h>
@@ -580,11 +581,18 @@ ialias (acc_set_device_num)
int
acc_on_device (acc_device_t dev)
{
- if (acc_get_device_type () == acc_device_host_nonshm)
+ struct goacc_thread *thr = goacc_thread ();
+
+ /* We only want to appear to be the "host_nonshm" plugin from "offloaded"
+ code -- i.e. within a parallel region. Test a flag set by the
+ openacc_parallel hook of the host_nonshm plugin to determine that. */
+ if (acc_get_device_type () == acc_device_host_nonshm
+ && thr && thr->target_tls
+ && ((struct nonshm_thread *)thr->target_tls)->nonshm_exec)
return dev == acc_device_host_nonshm || dev == acc_device_not_host;
- /* Just rely on the compiler builtin. */
- return __builtin_acc_on_device (dev);
+ /* For OpenACC, libgomp is only built for the host, so this is sufficient. */
+ return dev == acc_device_host || dev == acc_device_none;
}
ialias (acc_on_device)
diff --git a/libgomp/plugin/plugin-host.c b/libgomp/plugin/plugin-host.c
index 1faf5bc..3cb4dab 100644
--- a/libgomp/plugin/plugin-host.c
+++ b/libgomp/plugin/plugin-host.c
@@ -44,6 +44,7 @@
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
+#include <stdbool.h>
#ifdef HOST_NONSHM_PLUGIN
#define STATIC
@@ -55,6 +56,10 @@
#define SELF "host: "
#endif
+#ifdef HOST_NONSHM_PLUGIN
+#include "plugin-host.h"
+#endif
+
STATIC const char *
GOMP_OFFLOAD_get_name (void)
{
@@ -174,7 +179,10 @@ GOMP_OFFLOAD_openacc_parallel (void (*fn) (void *),
void *targ_mem_desc __attribute__ ((unused)))
{
#ifdef HOST_NONSHM_PLUGIN
+ struct nonshm_thread *thd = GOMP_PLUGIN_acc_thread ();
+ thd->nonshm_exec = true;
fn (devaddrs);
+ thd->nonshm_exec = false;
#else
fn (hostaddrs);
#endif
@@ -232,11 +240,20 @@ STATIC void *
GOMP_OFFLOAD_openacc_create_thread_data (int ord
__attribute__ ((unused)))
{
+#ifdef HOST_NONSHM_PLUGIN
+ struct nonshm_thread *thd
+ = GOMP_PLUGIN_malloc (sizeof (struct nonshm_thread));
+ thd->nonshm_exec = false;
+ return thd;
+#else
return NULL;
+#endif
}
STATIC void
-GOMP_OFFLOAD_openacc_destroy_thread_data (void *tls_data
- __attribute__ ((unused)))
+GOMP_OFFLOAD_openacc_destroy_thread_data (void *tls_data)
{
+#ifdef HOST_NONSHM_PLUGIN
+ free (tls_data);
+#endif
}
diff --git a/libgomp/plugin/plugin-host.h b/libgomp/plugin/plugin-host.h
new file mode 100644
index 0000000..96955d1
--- /dev/null
+++ b/libgomp/plugin/plugin-host.h
@@ -0,0 +1,37 @@
+/* OpenACC Runtime Library: acc_device_host, acc_device_host_nonshm.
+
+ Copyright (C) 2015 Free Software Foundation, Inc.
+
+ Contributed by Mentor Embedded.
+
+ This file is part of the GNU Offloading and Multi Processing Library
+ (libgomp).
+
+ Libgomp is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3, or (at your option)
+ any later version.
+
+ Libgomp is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ more details.
+
+ Under Section 7 of GPL version 3, you are granted additional
+ permissions described in the GCC Runtime Library Exception, version
+ 3.1, as published by the Free Software Foundation.
+
+ You should have received a copy of the GNU General Public License and
+ a copy of the GCC Runtime Library Exception along with this program;
+ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef PLUGIN_HOST_H
+#define PLUGIN_HOST_H
+
+struct nonshm_thread
+{
+ bool nonshm_exec;
+};
+
+#endif