summaryrefslogtreecommitdiff
path: root/libgomp/plugin
diff options
context:
space:
mode:
authorThomas Schwinge <thomas@codesourcery.com>2020-01-10 23:24:36 +0100
committerThomas Schwinge <tschwinge@gcc.gnu.org>2020-01-10 23:24:36 +0100
commit6fc0385c0ce39470e137eab27dee8955b3f98258 (patch)
tree0a95a071bafad5393c048a74bec3cdb005499f3d /libgomp/plugin
parentb3b75e664a619dae98571a0b3ac8034f5fa7c2be (diff)
OpenACC 'acc_get_property' cleanup
include/ * gomp-constants.h (enum gomp_device_property): Remove. libgomp/ * 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. liboffloadmic/ * plugin/libgomp-plugin-intelmic.cpp (GOMP_OFFLOAD_get_property): Remove. From-SVN: r280150
Diffstat (limited to 'libgomp/plugin')
-rw-r--r--libgomp/plugin/plugin-gcn.c22
-rw-r--r--libgomp/plugin/plugin-hsa.c26
-rw-r--r--libgomp/plugin/plugin-nvptx.c138
3 files changed, 81 insertions, 105 deletions
diff --git a/libgomp/plugin/plugin-gcn.c b/libgomp/plugin/plugin-gcn.c
index b5ca7c1b4bd..16ce251f3a5 100644
--- a/libgomp/plugin/plugin-gcn.c
+++ b/libgomp/plugin/plugin-gcn.c
@@ -3236,17 +3236,6 @@ GOMP_OFFLOAD_get_num_devices (void)
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. */
@@ -3999,6 +3988,17 @@ GOMP_OFFLOAD_openacc_async_dev2host (int device, void *dst, const void *src,
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 *
diff --git a/libgomp/plugin/plugin-hsa.c b/libgomp/plugin/plugin-hsa.c
index b04923b1920..abd3bc64163 100644
--- a/libgomp/plugin/plugin-hsa.c
+++ b/libgomp/plugin/plugin-hsa.c
@@ -699,32 +699,6 @@ GOMP_OFFLOAD_get_num_devices (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. */
diff --git a/libgomp/plugin/plugin-nvptx.c b/libgomp/plugin/plugin-nvptx.c
index e867b4cdedb..6033c71a9db 100644
--- a/libgomp/plugin/plugin-nvptx.c
+++ b/libgomp/plugin/plugin-nvptx.c
@@ -1121,74 +1121,6 @@ GOMP_OFFLOAD_get_num_devices (void)
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)
{
@@ -1818,6 +1750,76 @@ GOMP_OFFLOAD_openacc_async_dev2host (int ord, void *dst, const void *src,
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. */