From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12808 invoked by alias); 22 Dec 2014 18:33:40 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 12788 invoked by uid 89); 22 Dec 2014 18:33:40 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_NONE,SPF_PASS 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; Mon, 22 Dec 2014 18:33:38 +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 1Y37nS-00067U-JM from Thomas_Schwinge@mentor.com ; Mon, 22 Dec 2014 10:33:35 -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; Mon, 22 Dec 2014 18:33:32 +0000 From: Thomas Schwinge To: , Jakub Jelinek CC: Julian Brown Subject: Re: [PATCH 1/5] OpenACC 2.0 support for libgomp - OpenACC runtime, NVidia PTX/CUDA plugin (repost) In-Reply-To: <20141111135323.29e0f27b@octopus> References: <20140923191931.2177e60f@octopus> <20141111135323.29e0f27b@octopus> User-Agent: Notmuch/0.9-101-g81dad07 (http://notmuchmail.org) Emacs/24.4.1 (i586-pc-linux-gnu) Date: Mon, 22 Dec 2014 18:55:00 -0000 Message-ID: <87egrry1on.fsf@kepler.schwinge.homeip.net> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha1; protocol="application/pgp-signature" X-SW-Source: 2014-12/txt/msg01800.txt.bz2 --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Content-length: 6517 Hi! On Tue, 11 Nov 2014 13:53:23 +0000, Julian Brown = wrote: > On Tue, 23 Sep 2014 19:19:31 +0100 > Julian Brown wrote: >=20 > > This patch contains the bulk of the OpenACC 2.0 runtime support, > > building around, or on top of, the OpenMP 4.0 support (as previously > > posted or already extant upstream) where we could. [...] >=20 > Here is a new version of the OpenACC support patch for libgomp, [...] > --- a/libgomp/target.c > +++ b/libgomp/target.c > @@ -920,6 +1111,43 @@ gomp_target_init (void) > } > while (next); >=20=20 > + /* Prefer a device with TARGET_CAP_OPENMP_400 for ICV default-device-v= ar. */ > + if (num_devices > 1) > + { > + int d =3D gomp_icv (false)->default_device_var; > + > + if (!(devices[d].capabilities & TARGET_CAP_OPENMP_400)) > + { > + for (i =3D 0; i < num_devices; i++) > + { > + if (devices[i].capabilities & TARGET_CAP_OPENMP_400) > + { > + struct gomp_device_descr device_tmp =3D devices[d]; > + devices[d] =3D devices[i]; > + devices[d].id =3D d + 1; > + devices[i] =3D device_tmp; > + devices[i].id =3D i + 1; > + > + break; > + } > + } > + } > + } A thinko of mine; committed to gomp-4_0-branch in r219029: commit 806b4f5eed613a43bf52082816469268df0ed9a5 Author: tschwinge Date: Mon Dec 22 18:31:42 2014 +0000 libgomp: For OpenMP offloading, only publicize GOMP_OFFLOAD_CAP_OPENMP_= 400 devices. =20=20=20=20 libgomp/ * target.c (num_devices_openmp): New variable. (gomp_get_num_devices): Use it. (gomp_target_init): Initialize it, and sort the devices array appropriately. =20=20=20=20 With Intel MIC offloading (emulation), this fixes: =20=20=20=20 FAIL: libgomp.c/examples-4/e.57.2.c execution test FAIL: libgomp.fortran/examples-4/e.57.2.f90 -O0 execution test FAIL: libgomp.fortran/examples-4/e.57.2.f90 -O1 execution test FAIL: libgomp.fortran/examples-4/e.57.2.f90 -O2 execution test FAIL: libgomp.fortran/examples-4/e.57.2.f90 -O3 -fomit-frame-poin= ter execution test FAIL: libgomp.fortran/examples-4/e.57.2.f90 -O3 -fomit-frame-poin= ter -funroll-loops execution test FAIL: libgomp.fortran/examples-4/e.57.2.f90 -O3 -fomit-frame-poin= ter -funroll-all-loops -finline-functions execution test FAIL: libgomp.fortran/examples-4/e.57.2.f90 -O3 -g execution test FAIL: libgomp.fortran/examples-4/e.57.2.f90 -Os execution test =20=20=20=20 git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gomp-4_0-branch@2190= 29 138bc75d-0d04-0410-961f-82ee72b054a4 --- libgomp/ChangeLog.gomp | 5 +++++ libgomp/target.c | 52 ++++++++++++++++++++++++++++------------------= ---- 2 files changed, 34 insertions(+), 23 deletions(-) diff --git libgomp/ChangeLog.gomp libgomp/ChangeLog.gomp index eabf737..b9bd024 100644 --- libgomp/ChangeLog.gomp +++ libgomp/ChangeLog.gomp @@ -1,5 +1,10 @@ 2014-12-22 Thomas Schwinge =20 + * target.c (num_devices_openmp): New variable. + (gomp_get_num_devices): Use it. + (gomp_target_init): Initialize it, and sort the devices array + appropriately. + * libgomp.h (struct gomp_device_descr): Remove id member. Update all users. =20 diff --git libgomp/target.c libgomp/target.c index 226b95b..bf6edd2 100644 --- libgomp/target.c +++ libgomp/target.c @@ -67,6 +67,9 @@ static struct gomp_device_descr *devices; /* Total number of available devices. */ static int num_devices; =20 +/* Number of GOMP_OFFLOAD_CAP_OPENMP_400 devices. */ +static int num_devices_openmp; + /* The comparison function. */ =20 attribute_hidden int @@ -94,7 +97,7 @@ attribute_hidden int gomp_get_num_devices (void) { gomp_init_targets_once (); - return num_devices; + return num_devices_openmp; } =20 static struct gomp_device_descr * @@ -1048,9 +1051,11 @@ gomp_register_image_for_device (struct gomp_device_d= escr *device, } =20 /* This function initializes the runtime needed for offloading. - It parses the list of offload targets and tries to load the plugins for= these - targets. Result of the function is properly initialized variable NUM_D= EVICES - and array DEVICES, containing descriptors for corresponding devices. */ + It parses the list of offload targets and tries to load the plugins for + these targets. On return, the variables NUM_DEVICES and NUM_DEVICES_OP= ENMP + will be set, and the array DEVICES initialized, containing descriptors = for + corresponding devices, first the GOMP_OFFLOAD_CAP_OPENMP_400 ones, foll= ows + by the others. */ =20 static void gomp_target_init (void) @@ -1089,6 +1094,8 @@ gomp_target_init (void) new_num_devices =3D current_device.get_num_devices_func (); if (new_num_devices >=3D 1) { + /* Augment DEVICES and NUM_DEVICES. */ + devices =3D realloc (devices, (num_devices + new_num_devices) * sizeof (struct gomp_device_descr)); if (!devices) @@ -1121,27 +1128,26 @@ gomp_target_init (void) } while (next); =20 - /* Prefer a device with GOMP_OFFLOAD_CAP_OPENMP_400 for ICV - default-device-var. */ - if (num_devices > 1) + /* In DEVICES, sort the GOMP_OFFLOAD_CAP_OPENMP_400 ones first, and set + NUM_DEVICES_OPENMP. */ + struct gomp_device_descr *devices_s + =3D malloc (num_devices * sizeof (struct gomp_device_descr)); + if (!devices_s) { - int d =3D gomp_icv (false)->default_device_var; - - if (!(devices[d].capabilities & GOMP_OFFLOAD_CAP_OPENMP_400)) - { - for (i =3D 0; i < num_devices; i++) - { - if (devices[i].capabilities & GOMP_OFFLOAD_CAP_OPENMP_400) - { - struct gomp_device_descr device_tmp =3D devices[d]; - devices[d] =3D devices[i]; - devices[i] =3D device_tmp; - - break; - } - } - } + num_devices =3D 0; + free (devices); + devices =3D NULL; } + num_devices_openmp =3D 0; + for (i =3D 0; i < num_devices; i++) + if (devices[i].capabilities & GOMP_OFFLOAD_CAP_OPENMP_400) + devices_s[num_devices_openmp++] =3D devices[i]; + int num_devices_after_openmp =3D num_devices_openmp; + for (i =3D 0; i < num_devices; i++) + if (!(devices[i].capabilities & GOMP_OFFLOAD_CAP_OPENMP_400)) + devices_s[num_devices_after_openmp++] =3D devices[i]; + free (devices); + devices =3D devices_s; =20 for (i =3D 0; i < num_devices; i++) { Gr=C3=BC=C3=9Fe, Thomas --=-=-= Content-Type: application/pgp-signature; name="signature.asc" Content-length: 472 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQEcBAEBAgAGBQJUmGP5AAoJEK3/DN1sMFFtGM8IAIAE9aCMbqNc9lsUIZUXpsEc PWWprC3cmps/Ktn0Z2aWJuDv7mbqd0asQdx3oNOiyEL2MfhnYJ2i2rzaqZzMv5HF UXcJeMZjBsLYv3tG4I/2FDEgdFkYpnIgiQTk67FnvJwmiLJJzJmic8nn3XLlc5xX SeAZN+pSIOSP/qQ5NzP33cjnF2Lo5h/80g+PiXr3oiSr+G53cQcQW5moSE6Zrdpz TTc/qLkIkGfXDA2UPHIkvs8Uh9MXlcwPwU7M7Ajj8S+fOQBbpN5Si2eSPTLLYPxm X5EatsdcPGjTCRStXvKp5DYXP6F2kq4gz9G0REwdZHhqHK4Zp0Gb/I3MaxtxA0Y= =QlNB -----END PGP SIGNATURE----- --=-=-=--