Hi! On Wed, 29 Oct 2014 15:20:17 +0000, Julian Brown <jul...@codesourcery.com> wrote: > On Tue, 28 Oct 2014 11:16:19 +0000 > Julian Brown <jul...@codesourcery.com> wrote: > > This patch rationalises TLS support by moving all thread-local > > variables into a single structure. Because this meant interfering with > > how per-thread/per-device initialisation was done, I took the > > opportunity to tidy up a couple of other bits along the way.
> --- a/libgomp/plugin-nvptx.c > +++ b/libgomp/plugin-nvptx.c > @@ -749,7 +718,12 @@ PTX_get_num_devices (void) > int n; > CUresult r; > > - assert (PTX_inited); > + /* This function will be called before the plugin has been initialized in > + order to enumerate available devices, but CUDA API routines can't be > used > + until cuInit has been called. Just call it now (but don't yet do any > + further initialization). */ > + if (!PTX_inited) > + cuInit (0); > > r = cuDeviceGetCount (&n); > if (r!= CUDA_SUCCESS) > --- a/libgomp/target.c > +++ b/libgomp/target.c > @@ -1172,18 +1184,24 @@ gomp_find_available_plugins (void) > + for (i = 0; i < current_device.get_num_devices_func (); i++) > + { > +[...] Committed to gomp-4_0-branch in r217141: commit af80306c854b504fb0df6ac7d88d2472989ffbb7 Author: tschwinge <tschwinge@138bc75d-0d04-0410-961f-82ee72b054a4> Date: Wed Nov 5 16:07:20 2014 +0000 libgomp plugins: Remove the (OpenACC) avail function. This idea has been to use this to see whether a class of devices is generally available, without determining the exact number of devices that are available. Such a distinction probably doesn't make too much sense; in the following, we'd like to use one device anyway. Inline the few users. libgomp/ * target.h (struct ACC_dispatch_t): Remove avail_func. Update all users. * oacc-host.c (openacc_avail): Likewise. * plugin-nvptx.c (PTX_avail, openacc_avail): Likewise. * libgomp.texi (acc_get_num_devices): Revise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gomp-4_0-branch@217141 138bc75d-0d04-0410-961f-82ee72b054a4 --- libgomp/ChangeLog.gomp | 6 ++++++ libgomp/libgomp.texi | 10 +++++----- libgomp/oacc-host.c | 13 ------------- libgomp/oacc-init.c | 6 +++--- libgomp/plugin-nvptx.c | 20 -------------------- libgomp/target.c | 1 - libgomp/target.h | 3 --- 7 files changed, 14 insertions(+), 45 deletions(-) diff --git libgomp/ChangeLog.gomp libgomp/ChangeLog.gomp index d24ef43..d65ce71 100644 --- libgomp/ChangeLog.gomp +++ libgomp/ChangeLog.gomp @@ -1,5 +1,11 @@ 2014-11-05 Thomas Schwinge <tho...@codesourcery.com> + * target.h (struct ACC_dispatch_t): Remove avail_func. Update all + users. + * oacc-host.c (openacc_avail): Likewise. + * plugin-nvptx.c (PTX_avail, openacc_avail): Likewise. + * libgomp.texi (acc_get_num_devices): Revise. + * testsuite/libgomp.oacc-c/goacc_kernels.c: Remove file. * testsuite/libgomp.oacc-c/goacc_parallel.c: Remove file. diff --git libgomp/libgomp.texi libgomp/libgomp.texi index 9530a2b..66c678f 100644 --- libgomp/libgomp.texi +++ libgomp/libgomp.texi @@ -187,12 +187,12 @@ API routines for target platforms. @node acc_get_num_devices @section @code{acc_get_num_devices} -- Get number of devices for given device type @table @asis -item @emph{Description} -This routine returns a value, between 0 and @emph{n}, indicating the -number of devices available for the given device type. It determines -the number of devices in a @emph{passive} manner. In other words, it +@item @emph{Description} +This routine returns a value indicating the +number of devices available for the given device type. It determines +the number of devices in a @emph{passive} manner. In other words, it does not alter the state within the runtime environment aside from -possibly initializing an uninitialized device. This aspect allows +possibly initializing an uninitialized device. This aspect allows the routine to be called without concern for altering the interaction with an attached accelerator device. diff --git libgomp/oacc-host.c libgomp/oacc-host.c index fc3e77c..f7a9fba 100644 --- libgomp/oacc-host.c +++ libgomp/oacc-host.c @@ -153,16 +153,6 @@ device_get_table (struct mapping_table **table) return 0; } -STATIC bool -openacc_avail (void) -{ -#ifdef DEBUG - fprintf (stderr, SELF "%s:%s\n", __FILE__, __FUNCTION__); -#endif - - return 1; -} - STATIC void * openacc_open_device (int n) { @@ -414,9 +404,6 @@ static struct gomp_device_descr host_dispatch = .get_device_num_func = openacc_get_device_num, .set_device_num_func = openacc_set_device_num, - /* Device available. */ - .avail_func = openacc_avail, - .exec_func = openacc_parallel, .register_async_cleanup_func = openacc_register_async_cleanup, diff --git libgomp/oacc-init.c libgomp/oacc-init.c index 6f72578..0e0fee9 100644 --- libgomp/oacc-init.c +++ libgomp/oacc-init.c @@ -97,7 +97,7 @@ resolve_device (acc_device_t d) while (++d != _ACC_device_hwm) if (dispatchers[d] && !strcasecmp (goacc_device_type, dispatchers[d]->name) - && dispatchers[d]->openacc.avail_func ()) + && dispatchers[d]->device_init_func () > 0) goto found; gomp_fatal ("device type %s not supported", goacc_device_type); @@ -112,7 +112,7 @@ resolve_device (acc_device_t d) case acc_device_not_host: /* Find the first available device after acc_device_not_host. */ while (++d != _ACC_device_hwm) - if (dispatchers[d] && dispatchers[d]->openacc.avail_func ()) + if (dispatchers[d] && dispatchers[d]->device_init_func () > 0) goto found; if (d_arg == acc_device_default) { @@ -150,7 +150,7 @@ _acc_init (acc_device_t d) acc_dev = resolve_device (d); - if (!acc_dev || !acc_dev->openacc.avail_func ()) + if (!acc_dev || acc_dev->device_init_func () <= 0) gomp_fatal ("device %u not supported", (unsigned)d); if (acc_dev->is_initialized) diff --git libgomp/plugin-nvptx.c libgomp/plugin-nvptx.c index 4db2f32..8b78b16 100644 --- libgomp/plugin-nvptx.c +++ libgomp/plugin-nvptx.c @@ -730,17 +730,6 @@ PTX_get_num_devices (void) return n; } -static bool -PTX_avail(void) -{ - bool avail = false; - - if (PTX_init () > 0) - avail = true; - - return avail; -} - static void link_ptx (CUmodule *module, char *ptx_code) { @@ -1729,15 +1718,6 @@ openacc_get_device_num (void) return -1; } -bool -openacc_avail (void) -{ -#ifdef DEBUG - fprintf (stderr, "libgomp plugin: %s:%s\n", __FILE__, __FUNCTION__); -#endif - return PTX_avail (); -} - void openacc_register_async_cleanup (void *targ_mem_desc) { diff --git libgomp/target.c libgomp/target.c index 507488e..6941864 100644 --- libgomp/target.c +++ libgomp/target.c @@ -1045,7 +1045,6 @@ gomp_load_plugin_for_device (struct gomp_device_descr *device, DLSYM_OPT (openacc.close_device, openacc_close_device); DLSYM_OPT (openacc.get_device_num, openacc_get_device_num); DLSYM_OPT (openacc.set_device_num, openacc_set_device_num); - DLSYM_OPT (openacc.avail, openacc_avail); DLSYM_OPT (openacc.register_async_cleanup, openacc_register_async_cleanup); DLSYM_OPT (openacc.async_test, openacc_async_test); diff --git libgomp/target.h libgomp/target.h index d4c1120..b0cd884 100644 --- libgomp/target.h +++ libgomp/target.h @@ -103,9 +103,6 @@ typedef struct ACC_dispatch_t int (*get_device_num_func) (void); void (*set_device_num_func) (int); - /* Availability. */ - bool (*avail_func) (void); - /* Execute. */ void (*exec_func) (void (*) (void *), size_t, void **, void **, size_t *, unsigned short *, int, int, int, int, void *); Grüße, Thomas
pgpmsUPVWs89C.pgp
Description: PGP signature