From patchwork Wed Nov 5 16:09:24 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Thomas Schwinge X-Patchwork-Id: 407072 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 198F514003E for ; Thu, 6 Nov 2014 03:09:46 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:in-reply-to:references:date:message-id :mime-version:content-type; q=dns; s=default; b=suG37384stkuDbSJ ho43gH5JOcdgpPK5r8yUUSiLZypaKtBdd/85nZe0MCnjym4e8fH52kvR+oU+wTFZ zt1f+YCm2kbFnDmxWH96zprHOUZ48RERAURr1MEWchmRtoFWQ68Gnl1kU08HT/pX RPg1Mbaiy/4Rm0AfQMZLBx0K53I= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:in-reply-to:references:date:message-id :mime-version:content-type; s=default; bh=Tl3gKKHIl8zLhAUGgoJqky T5aSo=; b=My8AryC/dIcRoSqsL9AucdXHjNi3AoOp72yEFNly/GM/tc15f7QAfS Q2KfSC3tgE4mwJBaODrKQo0Elv3OtBZCajEwRj87VduQxWW1NBh7/MKnGhtgcKTw 48W3k6C9vMtXaRqszlA763DDa++EFF0c/AmehLyrKrKJfOTCKTVYY= Received: (qmail 10541 invoked by alias); 5 Nov 2014 16:09:40 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 10529 invoked by uid 89); 5 Nov 2014 16:09:39 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.0 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 X-HELO: relay1.mentorg.com Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 05 Nov 2014 16:09:37 +0000 Received: from nat-ies.mentorg.com ([192.94.31.2] helo=SVR-IES-FEM-01.mgc.mentorg.com) by relay1.mentorg.com with esmtp id 1Xm39J-0001CC-Bp from Thomas_Schwinge@mentor.com ; Wed, 05 Nov 2014 08:09:33 -0800 Received: from feldtkeller.schwinge.homeip.net (137.202.0.76) by SVR-IES-FEM-01.mgc.mentorg.com (137.202.0.104) with Microsoft SMTP Server id 14.3.181.6; Wed, 5 Nov 2014 16:09:32 +0000 From: Thomas Schwinge To: Julian Brown , CC: Jakub Jelinek Subject: Re: [gomp4] Rationalise thread-local variables in libgomp OpenACC support In-Reply-To: <20141029152017.4829ad2f@octopus> References: <20141028111619.25cce856@octopus> <20141029152017.4829ad2f@octopus> User-Agent: Notmuch/0.9-101-g81dad07 (http://notmuchmail.org) Emacs/24.3.1 (i586-pc-linux-gnu) Date: Wed, 5 Nov 2014 17:09:24 +0100 Message-ID: <87tx2deiiz.fsf@kepler.schwinge.homeip.net> MIME-Version: 1.0 Hi! On Wed, 29 Oct 2014 15:20:17 +0000, Julian Brown wrote: > On Tue, 28 Oct 2014 11:16:19 +0000 > Julian Brown 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 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(-) Grüße, Thomas 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 + * 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 *);