+2020-01-10 Thomas Schwinge <thomas@codesourcery.com>
+
+ * gomp-constants.h (enum gomp_device_property): Remove.
+
2020-01-01 Jakub Jelinek <jakub@redhat.com>
Update copyright years.
#define GOMP_DEVICE_ICV -1
#define GOMP_DEVICE_HOST_FALLBACK -2
-/* Device property codes. Keep in sync with
- libgomp/{openacc.h,openacc.f90}:acc_device_property_t */
-/* Start from 1 to catch uninitialized use. */
-enum gomp_device_property
- {
- GOMP_DEVICE_PROPERTY_MEMORY = 1,
- GOMP_DEVICE_PROPERTY_FREE_MEMORY = 2,
- GOMP_DEVICE_PROPERTY_NAME = 0x10001,
- GOMP_DEVICE_PROPERTY_VENDOR = 0x10002,
- GOMP_DEVICE_PROPERTY_DRIVER = 0x10003
- };
-
-/* Internal property mask to tell numeric and string values apart. */
-#define GOMP_DEVICE_PROPERTY_STRING_MASK 0x10000
-
/* GOMP_task/GOMP_taskloop* flags argument. */
#define GOMP_TASK_FLAG_UNTIED (1 << 0)
#define GOMP_TASK_FLAG_FINAL (1 << 1)
2020-01-10 Thomas Schwinge <thomas@codesourcery.com>
+ * libgomp-plugin.h (enum goacc_property): New. Adjust all users
+ to use this instead of 'enum gomp_device_property'.
+ (GOMP_OFFLOAD_get_property): Rename to...
+ (GOMP_OFFLOAD_openacc_get_property): ... this. Adjust all users.
+ * libgomp.h (struct gomp_device_descr): Move
+ 'GOMP_OFFLOAD_openacc_get_property'...
+ (struct acc_dispatch_t): ... here. Adjust all users.
+ * plugin/plugin-hsa.c (GOMP_OFFLOAD_get_property): Remove.
+
* target.c (gomp_map_vars_internal)
<GOMP_MAP_USE_DEVICE_PTR_IF_PRESENT>: Clean up/elaborate code
paths.
OFFLOAD_TARGET_TYPE_GCN = 8
};
-/* Container type for passing device properties. */
-union gomp_device_property_value
-{
- const char *ptr;
- size_t val;
-};
-
/* Opaque type to represent plugin-dependent implementation of an
OpenACC asynchronous queue. */
struct goacc_asyncqueue;
typedef struct goacc_asyncqueue *goacc_aq;
typedef struct goacc_asyncqueue_list *goacc_aq_list;
+
+/* OpenACC 'acc_get_property' support. */
+
+/* Device property values. Keep in sync with
+ 'libgomp/{openacc.h,openacc.f90}:acc_device_property_t'. */
+enum goacc_property
+ {
+ /* Mask to tell numeric and string values apart. */
+#define GOACC_PROPERTY_STRING_MASK 0x10000
+
+ /* Start from 1 to catch uninitialized use. */
+ GOACC_PROPERTY_MEMORY = 1,
+ GOACC_PROPERTY_FREE_MEMORY = 2,
+ GOACC_PROPERTY_NAME = GOACC_PROPERTY_STRING_MASK | 1,
+ GOACC_PROPERTY_VENDOR = GOACC_PROPERTY_STRING_MASK | 2,
+ GOACC_PROPERTY_DRIVER = GOACC_PROPERTY_STRING_MASK | 3
+ };
+
+/* Container type for passing device properties. */
+union goacc_property_value
+{
+ const char *ptr;
+ size_t val;
+};
+
+
/* Auxiliary struct, used for transferring pairs of addresses from plugin
to libgomp. */
struct addr_pair
extern unsigned int GOMP_OFFLOAD_get_caps (void);
extern int GOMP_OFFLOAD_get_type (void);
extern int GOMP_OFFLOAD_get_num_devices (void);
-extern union gomp_device_property_value GOMP_OFFLOAD_get_property (int, int);
extern bool GOMP_OFFLOAD_init_device (int);
extern bool GOMP_OFFLOAD_fini_device (int);
extern unsigned GOMP_OFFLOAD_version (void);
extern void *GOMP_OFFLOAD_openacc_cuda_get_stream (struct goacc_asyncqueue *);
extern int GOMP_OFFLOAD_openacc_cuda_set_stream (struct goacc_asyncqueue *,
void *);
+extern union goacc_property_value
+ GOMP_OFFLOAD_openacc_get_property (int, enum goacc_property);
#ifdef __cplusplus
}
__typeof (GOMP_OFFLOAD_openacc_async_host2dev) *host2dev_func;
} async;
+ __typeof (GOMP_OFFLOAD_openacc_get_property) *get_property_func;
+
/* NVIDIA target specific routines. */
struct {
__typeof (GOMP_OFFLOAD_openacc_cuda_get_current_device)
__typeof (GOMP_OFFLOAD_get_caps) *get_caps_func;
__typeof (GOMP_OFFLOAD_get_type) *get_type_func;
__typeof (GOMP_OFFLOAD_get_num_devices) *get_num_devices_func;
- __typeof (GOMP_OFFLOAD_get_property) *get_property_func;
__typeof (GOMP_OFFLOAD_init_device) *init_device_func;
__typeof (GOMP_OFFLOAD_fini_device) *fini_device_func;
__typeof (GOMP_OFFLOAD_version) *version_func;
return 1;
}
-static union gomp_device_property_value
-host_get_property (int n, int prop)
-{
- union gomp_device_property_value nullval = { .val = 0 };
-
- if (n >= host_get_num_devices ())
- return nullval;
-
- switch (prop)
- {
- case GOMP_DEVICE_PROPERTY_NAME:
- return (union gomp_device_property_value) { .ptr = "GOMP" };
- case GOMP_DEVICE_PROPERTY_VENDOR:
- return (union gomp_device_property_value) { .ptr = "GNU" };
- case GOMP_DEVICE_PROPERTY_DRIVER:
- return (union gomp_device_property_value) { .ptr = VERSION };
- default:
- return nullval;
- }
-}
-
static bool
host_init_device (int n __attribute__ ((unused)))
{
return true;
}
+static union goacc_property_value
+host_openacc_get_property (int n, enum goacc_property prop)
+{
+ union goacc_property_value nullval = { .val = 0 };
+
+ if (n >= host_get_num_devices ())
+ return nullval;
+
+ switch (prop)
+ {
+ case GOACC_PROPERTY_NAME:
+ return (union goacc_property_value) { .ptr = "GOMP" };
+ case GOACC_PROPERTY_VENDOR:
+ return (union goacc_property_value) { .ptr = "GNU" };
+ case GOACC_PROPERTY_DRIVER:
+ return (union goacc_property_value) { .ptr = VERSION };
+ case GOACC_PROPERTY_MEMORY:
+ case GOACC_PROPERTY_FREE_MEMORY:
+ default:
+ return nullval;
+ }
+}
+
static void *
host_openacc_create_thread_data (int ord __attribute__ ((unused)))
{
.get_caps_func = host_get_caps,
.get_type_func = host_get_type,
.get_num_devices_func = host_get_num_devices,
- .get_property_func = host_get_property,
.init_device_func = host_init_device,
.fini_device_func = host_fini_device,
.version_func = host_version,
.host2dev_func = host_openacc_async_host2dev,
},
+ .get_property_func = host_openacc_get_property,
+
.cuda = {
.get_current_device_func = NULL,
.get_current_context_func = NULL,
ialias (acc_set_device_num)
-static union gomp_device_property_value
+static union goacc_property_value
get_property_any (int ord, acc_device_t d, acc_device_property_t prop)
{
goacc_lazy_initialize ();
struct goacc_thread *thr = goacc_thread ();
if (d == acc_device_current && thr && thr->dev)
- return thr->dev->get_property_func (thr->dev->target_id, prop);
+ return thr->dev->openacc.get_property_func (thr->dev->target_id, prop);
gomp_mutex_lock (&acc_device_lock);
assert (dev);
- return dev->get_property_func (dev->target_id, prop);
+ return dev->openacc.get_property_func (dev->target_id, prop);
}
size_t
if (!known_device_type_p (d))
unknown_device_type_error(d);
- if (prop & GOMP_DEVICE_PROPERTY_STRING_MASK)
+ if (prop & GOACC_PROPERTY_STRING_MASK)
return 0;
else
return get_property_any (ord, d, prop).val;
if (!known_device_type_p (d))
unknown_device_type_error(d);
- if (prop & GOMP_DEVICE_PROPERTY_STRING_MASK)
+ if (prop & GOACC_PROPERTY_STRING_MASK)
return get_property_any (ord, d, prop).ptr;
else
return NULL;
integer, parameter :: acc_device_property = c_size_t
- ! Keep in sync with include/gomp-constants.h.
+ ! Keep in sync with 'libgomp/libgomp-plugin.h:goacc_property'.
integer (acc_device_property), parameter :: acc_property_memory = 1
integer (acc_device_property), parameter :: acc_property_free_memory = 2
integer (acc_device_property), parameter :: acc_property_name = int(Z'10001')
} acc_device_t;
typedef enum acc_device_property_t {
- /* Keep in sync with include/gomp-constants.h. */
- /* Start from 1 to catch uninitialized use. */
+ /* Keep in sync with 'libgomp/libgomp-plugin.h:goacc_property'. */
acc_property_memory = 1,
acc_property_free_memory = 2,
acc_property_name = 0x10001,
return hsa_context.agent_count;
}
-union gomp_device_property_value
-GOMP_OFFLOAD_get_property (int device, int prop)
-{
- /* Stub. Check device and return default value for unsupported properties. */
- /* TODO: Implement this function. */
- get_agent_info (device);
-
- union gomp_device_property_value nullval = { .val = 0 };
- return nullval;
-}
-
/* Initialize device (agent) number N so that it can be used for computation.
Return TRUE on success. */
return true;
}
+union goacc_property_value
+GOMP_OFFLOAD_openacc_get_property (int device, enum goacc_property prop)
+{
+ /* Stub. Check device and return default value for unsupported properties. */
+ /* TODO: Implement this function. */
+ get_agent_info (device);
+
+ union goacc_property_value nullval = { .val = 0 };
+ return nullval;
+}
+
/* Set up plugin-specific thread-local-data (host-side). */
void *
return hsa_context.agent_count;
}
-/* Part of the libgomp plugin interface. Return the value of property
- PROP of agent number N. */
-
-union gomp_device_property_value
-GOMP_OFFLOAD_get_property (int n, int prop)
-{
- union gomp_device_property_value nullval = { .val = 0 };
-
- if (!init_hsa_context ())
- return nullval;
- if (n >= hsa_context.agent_count)
- {
- GOMP_PLUGIN_error
- ("Request for a property of a non-existing HSA device %i", n);
- return nullval;
- }
-
- switch (prop)
- {
- case GOMP_DEVICE_PROPERTY_VENDOR:
- return (union gomp_device_property_value) { .ptr = "HSA" };
- default:
- return nullval;
- }
-}
-
/* Part of the libgomp plugin interface. Initialize agent number N so that it
can be used for computation. Return TRUE on success. */
return nvptx_get_num_devices ();
}
-union gomp_device_property_value
-GOMP_OFFLOAD_get_property (int n, int prop)
-{
- union gomp_device_property_value propval = { .val = 0 };
-
- pthread_mutex_lock (&ptx_dev_lock);
-
- if (n >= nvptx_get_num_devices () || n < 0 || ptx_devices[n] == NULL)
- {
- pthread_mutex_unlock (&ptx_dev_lock);
- return propval;
- }
-
- struct ptx_device *ptx_dev = ptx_devices[n];
- switch (prop)
- {
- case GOMP_DEVICE_PROPERTY_MEMORY:
- {
- size_t total_mem;
-
- CUDA_CALL_ERET (propval, cuDeviceTotalMem, &total_mem, ptx_dev->dev);
- propval.val = total_mem;
- }
- break;
- case GOMP_DEVICE_PROPERTY_FREE_MEMORY:
- {
- size_t total_mem;
- size_t free_mem;
- CUdevice ctxdev;
-
- CUDA_CALL_ERET (propval, cuCtxGetDevice, &ctxdev);
- if (ptx_dev->dev == ctxdev)
- CUDA_CALL_ERET (propval, cuMemGetInfo, &free_mem, &total_mem);
- else if (ptx_dev->ctx)
- {
- CUcontext old_ctx;
-
- CUDA_CALL_ERET (propval, cuCtxPushCurrent, ptx_dev->ctx);
- CUDA_CALL_ERET (propval, cuMemGetInfo, &free_mem, &total_mem);
- CUDA_CALL_ASSERT (cuCtxPopCurrent, &old_ctx);
- }
- else
- {
- CUcontext new_ctx;
-
- CUDA_CALL_ERET (propval, cuCtxCreate, &new_ctx, CU_CTX_SCHED_AUTO,
- ptx_dev->dev);
- CUDA_CALL_ERET (propval, cuMemGetInfo, &free_mem, &total_mem);
- CUDA_CALL_ASSERT (cuCtxDestroy, new_ctx);
- }
- propval.val = free_mem;
- }
- break;
- case GOMP_DEVICE_PROPERTY_NAME:
- propval.ptr = ptx_dev->name;
- break;
- case GOMP_DEVICE_PROPERTY_VENDOR:
- propval.ptr = "Nvidia";
- break;
- case GOMP_DEVICE_PROPERTY_DRIVER:
- propval.ptr = cuda_driver_version_s;
- break;
- }
-
- pthread_mutex_unlock (&ptx_dev_lock);
- return propval;
-}
-
bool
GOMP_OFFLOAD_init_device (int n)
{
return true;
}
+union goacc_property_value
+GOMP_OFFLOAD_openacc_get_property (int n, enum goacc_property prop)
+{
+ union goacc_property_value propval = { .val = 0 };
+
+ pthread_mutex_lock (&ptx_dev_lock);
+
+ if (n >= nvptx_get_num_devices () || n < 0 || ptx_devices[n] == NULL)
+ {
+ pthread_mutex_unlock (&ptx_dev_lock);
+ return propval;
+ }
+
+ struct ptx_device *ptx_dev = ptx_devices[n];
+ switch (prop)
+ {
+ case GOACC_PROPERTY_MEMORY:
+ {
+ size_t total_mem;
+
+ CUDA_CALL_ERET (propval, cuDeviceTotalMem, &total_mem, ptx_dev->dev);
+ propval.val = total_mem;
+ }
+ break;
+ case GOACC_PROPERTY_FREE_MEMORY:
+ {
+ size_t total_mem;
+ size_t free_mem;
+ CUdevice ctxdev;
+
+ CUDA_CALL_ERET (propval, cuCtxGetDevice, &ctxdev);
+ if (ptx_dev->dev == ctxdev)
+ CUDA_CALL_ERET (propval, cuMemGetInfo, &free_mem, &total_mem);
+ else if (ptx_dev->ctx)
+ {
+ CUcontext old_ctx;
+
+ CUDA_CALL_ERET (propval, cuCtxPushCurrent, ptx_dev->ctx);
+ CUDA_CALL_ERET (propval, cuMemGetInfo, &free_mem, &total_mem);
+ CUDA_CALL_ASSERT (cuCtxPopCurrent, &old_ctx);
+ }
+ else
+ {
+ CUcontext new_ctx;
+
+ CUDA_CALL_ERET (propval, cuCtxCreate, &new_ctx, CU_CTX_SCHED_AUTO,
+ ptx_dev->dev);
+ CUDA_CALL_ERET (propval, cuMemGetInfo, &free_mem, &total_mem);
+ CUDA_CALL_ASSERT (cuCtxDestroy, new_ctx);
+ }
+ propval.val = free_mem;
+ }
+ break;
+ case GOACC_PROPERTY_NAME:
+ propval.ptr = ptx_dev->name;
+ break;
+ case GOACC_PROPERTY_VENDOR:
+ propval.ptr = "Nvidia";
+ break;
+ case GOACC_PROPERTY_DRIVER:
+ propval.ptr = cuda_driver_version_s;
+ break;
+ default:
+ break;
+ }
+
+ pthread_mutex_unlock (&ptx_dev_lock);
+ return propval;
+}
+
/* Adjust launch dimensions: pick good values for number of blocks and warps
and ensure that number of warps does not exceed CUDA limits as well as GCC's
own limits. */
DLSYM (get_caps);
DLSYM (get_type);
DLSYM (get_num_devices);
- DLSYM (get_property);
DLSYM (init_device);
DLSYM (fini_device);
DLSYM (load_image);
openacc_async_queue_callback)
|| !DLSYM_OPT (openacc.async.exec, openacc_async_exec)
|| !DLSYM_OPT (openacc.async.dev2host, openacc_async_dev2host)
- || !DLSYM_OPT (openacc.async.host2dev, openacc_async_host2dev))
+ || !DLSYM_OPT (openacc.async.host2dev, openacc_async_host2dev)
+ || !DLSYM_OPT (openacc.get_property, openacc_get_property))
{
/* Require all the OpenACC handlers if we have
GOMP_OFFLOAD_CAP_OPENACC_200. */
+2020-01-10 Thomas Schwinge <thomas@codesourcery.com>
+
+ * plugin/libgomp-plugin-intelmic.cpp (GOMP_OFFLOAD_get_property):
+ Remove.
+
2019-12-22 Maciej W. Rozycki <macro@codesourcery.com>
Frederik Harwath <frederik@codesourcery.com>
Thomas Schwinge <tschwinge@codesourcery.com>
return num_devices;
}
-extern "C" union gomp_device_property_value
-GOMP_OFFLOAD_get_property (int n, int prop)
-{
- union gomp_device_property_value nullval = { .val = 0 };
-
- if (n >= num_devices)
- {
- GOMP_PLUGIN_error
- ("Request for a property of a non-existing Intel MIC device %i", n);
- return nullval;
- }
-
- switch (prop)
- {
- case GOMP_DEVICE_PROPERTY_VENDOR:
- return (union gomp_device_property_value) { .ptr = "Intel" };
- default:
- return nullval;
- }
-}
-
static bool
offload (const char *file, uint64_t line, int device, const char *name,
int num_vars, VarDesc *vars, const void **async_data)