@@ -1,5 +1,13 @@
2014-12-22 Thomas Schwinge <thomas@codesourcery.com>
+ * libgomp.h (TARGET_CAP_SHARED_MEM, TARGET_CAP_NATIVE_EXEC)
+ (TARGET_CAP_OPENMP_400, TARGET_CAP_OPENACC_200): Remove, and
+ instead...
+ * libgomp_target.h (GOMP_OFFLOAD_CAP_SHARED_MEM)
+ (GOMP_OFFLOAD_CAP_NATIVE_EXEC, GOMP_OFFLOAD_CAP_OPENMP_400)
+ (GOMP_OFFLOAD_CAP_OPENACC_200): ... add these new definitions.
+ Change all users.
+
* plugin/plugin-nvptx.c (GOMP_OFFLOAD_get_name): Return "nvptx".
* oacc-init.c (resolve_device): Update for that using...
(get_openacc_name): ... this new function.
@@ -662,11 +662,6 @@ struct target_mem_desc {
splay_tree_key list[];
};
-#define TARGET_CAP_SHARED_MEM 1
-#define TARGET_CAP_NATIVE_EXEC 2
-#define TARGET_CAP_OPENMP_400 4
-#define TARGET_CAP_OPENACC_200 8
-
/* Information about mapped memory regions (per device/context). */
struct gomp_memory_mapping
@@ -25,6 +25,12 @@
#ifndef LIBGOMP_TARGET_H
#define LIBGOMP_TARGET_H 1
+/* Capabilities of offloading devices. */
+#define GOMP_OFFLOAD_CAP_SHARED_MEM (1 << 0)
+#define GOMP_OFFLOAD_CAP_NATIVE_EXEC (1 << 1)
+#define GOMP_OFFLOAD_CAP_OPENMP_400 (1 << 2)
+#define GOMP_OFFLOAD_CAP_OPENACC_200 (1 << 3)
+
/* Type of offload target device. Keep in sync with include/gomp-constants.h. */
enum offload_target_type
{
@@ -35,8 +35,9 @@ static struct gomp_device_descr host_dispatch =
.name = "host",
.type = OFFLOAD_TARGET_TYPE_HOST,
- .capabilities = TARGET_CAP_OPENACC_200 | TARGET_CAP_NATIVE_EXEC
- | TARGET_CAP_SHARED_MEM,
+ .capabilities = (GOMP_OFFLOAD_CAP_OPENACC_200
+ | GOMP_OFFLOAD_CAP_NATIVE_EXEC
+ | GOMP_OFFLOAD_CAP_SHARED_MEM),
.id = 0,
.is_initialized = false,
@@ -259,7 +259,7 @@ acc_map_data (void *h, void *d, size_t s)
struct goacc_thread *thr = goacc_thread ();
struct gomp_device_descr *acc_dev = thr->dev;
- if (acc_dev->capabilities & TARGET_CAP_SHARED_MEM)
+ if (acc_dev->capabilities & GOMP_OFFLOAD_CAP_SHARED_MEM)
{
if (d != h)
gomp_fatal ("cannot map data on shared-memory system");
@@ -131,7 +131,7 @@ GOACC_parallel (int device, void (*fn) (void *), const void *offload_table,
acc_dev->openacc.async_set_async_func (async);
- if (!(acc_dev->capabilities & TARGET_CAP_NATIVE_EXEC))
+ if (!(acc_dev->capabilities & GOMP_OFFLOAD_CAP_NATIVE_EXEC))
{
k.host_start = (uintptr_t) fn;
k.host_end = k.host_start + 1;
@@ -187,7 +187,7 @@ GOACC_data_start (int device, const void *offload_table, size_t mapnum,
struct gomp_device_descr *acc_dev = thr->dev;
/* Host fallback or 'do nothing'. */
- if ((acc_dev->capabilities & TARGET_CAP_SHARED_MEM)
+ if ((acc_dev->capabilities & GOMP_OFFLOAD_CAP_SHARED_MEM)
|| host_fallback)
{
tgt = gomp_map_vars (NULL, 0, NULL, NULL, NULL, NULL, true, false);
@@ -233,7 +233,7 @@ GOACC_enter_exit_data (int device, const void *offload_table, size_t mapnum,
thr = goacc_thread ();
acc_dev = thr->dev;
- if ((acc_dev->capabilities & TARGET_CAP_SHARED_MEM)
+ if ((acc_dev->capabilities & GOMP_OFFLOAD_CAP_SHARED_MEM)
|| host_fallback)
return;
@@ -445,7 +445,7 @@ GOACC_update (int device, const void *offload_table, size_t mapnum,
struct goacc_thread *thr = goacc_thread ();
struct gomp_device_descr *acc_dev = thr->dev;
- if ((acc_dev->capabilities & TARGET_CAP_SHARED_MEM)
+ if ((acc_dev->capabilities & GOMP_OFFLOAD_CAP_SHARED_MEM)
|| host_fallback)
return;
@@ -70,29 +70,30 @@ GOMP_OFFLOAD_get_name (void)
#endif
}
-STATIC int
-GOMP_OFFLOAD_get_type (void)
-{
-#ifdef HOST_NONSHM_PLUGIN
- return OFFLOAD_TARGET_TYPE_HOST_NONSHM;
-#else
- return OFFLOAD_TARGET_TYPE_HOST;
-#endif
-}
-
STATIC unsigned int
GOMP_OFFLOAD_get_caps (void)
{
- unsigned int caps = TARGET_CAP_OPENACC_200 | TARGET_CAP_NATIVE_EXEC;
+ unsigned int caps = (GOMP_OFFLOAD_CAP_OPENACC_200
+ | GOMP_OFFLOAD_CAP_NATIVE_EXEC);
#ifndef HOST_NONSHM_PLUGIN
- caps |= TARGET_CAP_SHARED_MEM;
+ caps |= GOMP_OFFLOAD_CAP_SHARED_MEM;
#endif
return caps;
}
STATIC int
+GOMP_OFFLOAD_get_type (void)
+{
+#ifdef HOST_NONSHM_PLUGIN
+ return OFFLOAD_TARGET_TYPE_HOST_NONSHM;
+#else
+ return OFFLOAD_TARGET_TYPE_HOST;
+#endif
+}
+
+STATIC int
GOMP_OFFLOAD_get_num_devices (void)
{
return 1;
@@ -1483,25 +1483,24 @@ nvptx_set_cuda_stream (int async, void *stream)
/* Plugin entry points. */
-
-int
-GOMP_OFFLOAD_get_type (void)
-{
- return OFFLOAD_TARGET_TYPE_NVIDIA_PTX;
-}
-
-unsigned int
-GOMP_OFFLOAD_get_caps (void)
-{
- return TARGET_CAP_OPENACC_200;
-}
-
const char *
GOMP_OFFLOAD_get_name (void)
{
return "nvptx";
}
+unsigned int
+GOMP_OFFLOAD_get_caps (void)
+{
+ return GOMP_OFFLOAD_CAP_OPENACC_200;
+}
+
+int
+GOMP_OFFLOAD_get_type (void)
+{
+ return OFFLOAD_TARGET_TYPE_NVIDIA_PTX;
+}
+
int
GOMP_OFFLOAD_get_num_devices (void)
{
@@ -844,7 +844,8 @@ GOMP_target (int device, void (*fn) (void *), const void *offload_table,
if (devicep != NULL && !devicep->is_initialized)
gomp_init_dev_tables (devicep);
- if (devicep == NULL || !(devicep->capabilities & TARGET_CAP_OPENMP_400))
+ if (devicep == NULL
+ || !(devicep->capabilities & GOMP_OFFLOAD_CAP_OPENMP_400))
{
/* Host fallback. */
struct gomp_thread old_thr, *thr = gomp_thread ();
@@ -863,7 +864,7 @@ GOMP_target (int device, void (*fn) (void *), const void *offload_table,
void *fn_addr;
- if (devicep->capabilities & TARGET_CAP_NATIVE_EXEC)
+ if (devicep->capabilities & GOMP_OFFLOAD_CAP_NATIVE_EXEC)
fn_addr = (void *) fn;
else
{
@@ -909,7 +910,8 @@ GOMP_target_data (int device, const void *offload_table, size_t mapnum,
if (devicep != NULL && !devicep->is_initialized)
gomp_init_dev_tables (devicep);
- if (devicep == NULL || !(devicep->capabilities & TARGET_CAP_OPENMP_400))
+ if (devicep == NULL
+ || !(devicep->capabilities & GOMP_OFFLOAD_CAP_OPENMP_400))
{
/* Host fallback. */
struct gomp_task_icv *icv = gomp_icv (false);
@@ -968,7 +970,7 @@ GOMP_target_update (int device, const void *offload_table, size_t mapnum,
gomp_init_device (devicep);
gomp_mutex_unlock (&mm->lock);
- if (!(devicep->capabilities & TARGET_CAP_OPENMP_400))
+ if (!(devicep->capabilities & GOMP_OFFLOAD_CAP_OPENMP_400))
return;
gomp_update (devicep, &devicep->mem_map, mapnum, hostaddrs, sizes, kinds,
@@ -1050,9 +1052,9 @@ gomp_load_plugin_for_device (struct gomp_device_descr *device,
DLSYM (dev2host);
DLSYM (host2dev);
device->capabilities = device->get_caps_func ();
- if (device->capabilities & TARGET_CAP_OPENMP_400)
+ if (device->capabilities & GOMP_OFFLOAD_CAP_OPENMP_400)
DLSYM (run);
- if (device->capabilities & TARGET_CAP_OPENACC_200)
+ if (device->capabilities & GOMP_OFFLOAD_CAP_OPENACC_200)
{
optional_present = optional_total = 0;
DLSYM_OPT (openacc.exec, openacc_parallel);
@@ -1071,7 +1073,8 @@ gomp_load_plugin_for_device (struct gomp_device_descr *device,
DLSYM_OPT (openacc.async_set_async, openacc_async_set_async);
DLSYM_OPT (openacc.create_thread_data, openacc_create_thread_data);
DLSYM_OPT (openacc.destroy_thread_data, openacc_destroy_thread_data);
- /* Require all the OpenACC handlers if we have TARGET_CAP_OPENACC_200. */
+ /* Require all the OpenACC handlers if we have
+ GOMP_OFFLOAD_CAP_OPENACC_200. */
if (optional_present != optional_total)
{
err = "plugin missing OpenACC handler function";
@@ -1197,16 +1200,17 @@ gomp_target_init (void)
}
while (next);
- /* Prefer a device with TARGET_CAP_OPENMP_400 for ICV default-device-var. */
+ /* Prefer a device with GOMP_OFFLOAD_CAP_OPENMP_400 for ICV
+ default-device-var. */
if (num_devices > 1)
{
int d = gomp_icv (false)->default_device_var;
- if (!(devices[d].capabilities & TARGET_CAP_OPENMP_400))
+ if (!(devices[d].capabilities & GOMP_OFFLOAD_CAP_OPENMP_400))
{
for (i = 0; i < num_devices; i++)
{
- if (devices[i].capabilities & TARGET_CAP_OPENMP_400)
+ if (devices[i].capabilities & GOMP_OFFLOAD_CAP_OPENMP_400)
{
struct gomp_device_descr device_tmp = devices[d];
devices[d] = devices[i];
@@ -1230,7 +1234,7 @@ gomp_target_init (void)
/* The 'devices' array can be moved (by the realloc call) until we have
found all the plugins, so registering with the OpenACC runtime (which
takes a copy of the pointer argument) must be delayed until now. */
- if (devices[i].capabilities & TARGET_CAP_OPENACC_200)
+ if (devices[i].capabilities & GOMP_OFFLOAD_CAP_OPENACC_200)
goacc_register (&devices[i]);
}