From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 49941 invoked by alias); 10 Jan 2020 22:52:30 -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 49931 invoked by uid 89); 10 Jan 2020 22:52:29 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-19.6 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3 autolearn=ham version=3.3.1 spammy=prop, Device, Harwath, frederik@codesourcery.com X-HELO: esa4.mentor.iphmx.com Received: from esa4.mentor.iphmx.com (HELO esa4.mentor.iphmx.com) (68.232.137.252) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 10 Jan 2020 22:52:26 +0000 IronPort-SDR: M+bP1h74WHv5WNQlsSOPXLaEetltTHRvQdggzmUUH/aKztyXAJJRfk7ADy1+SyQ1HR+AzjsENI W3J8Z4Xtm3wwWmAaTzJh5lFgVDFORPGUrM5q4aErOoa0EcvOcTs/bxWPquvKJNyq9ybdjtgobX Pj3dOjoYlAJsFN2ynJy2nJLf7V7cDb7IYlvQIZVo4L5+7DUmoKv7NrU2eGucbnoLqWv2ZnkSbj Is0XrLkaAi3YaU+rPkUxEq1QfkSKRqYQYV1OusMkNwqyWo99rkF5SFZwBvIh9ZCz3v+8mUcGdh vj0= Received: from orw-gwy-01-in.mentorg.com ([192.94.38.165]) by esa4.mentor.iphmx.com with ESMTP; 10 Jan 2020 14:52:21 -0800 IronPort-SDR: fPZ5LxsOcqOgW2sj64ipdWIlxC9JNyKG9cErt4hYzHhIqaYouveQs0fe4gRHZiuDgRzOivZ0RT lSfxmwXCJMKuA89OqhyL1V4mMNiP9F0h+b0/y1DjMPisB6PHplsg+w9qATB050IhWzMzx8cR06 f8MU7Y18ZlFIhzNjQ5j8stv2AgQRttMrbte3QaFc7ygV+M0KNCM6emzsx9t1GOh3H98b5nImns 6+MNC6N5eUNzkIFUDjf/bQ8angyU9t6L3/C+P4Fzqj7kWBHMYHJBCyc4B63hhBuSXTgXOkkW2+ XM4= From: Thomas Schwinge To: Frederik Harwath , CC: , , Andrew Stubbs , Julian Brown , Tobias Burnus , Jakub Jelinek Subject: Re: [PATCH] Add OpenACC 2.6 `acc_get_property' support In-Reply-To: <87bls1wd4x.fsf@euler.schwinge.homeip.net> References: <20191113153215.17750-1-frederik@codesourcery.com> <87imp01jr3.fsf@euler.schwinge.homeip.net> <20191114153531.7493-1-frederik@codesourcery.com> <87v9qfyiyz.fsf@euler.schwinge.homeip.net> <1c2e2d57-31ce-8e4d-c8b9-c2fbc7091e86@codesourcery.com> <87bls1wd4x.fsf@euler.schwinge.homeip.net> User-Agent: Notmuch/0.29.1+93~g67ed7df (https://notmuchmail.org) Emacs/26.1 (x86_64-pc-linux-gnu) Date: Fri, 10 Jan 2020 23:44:00 -0000 Message-ID: <87muauvs9w.fsf@euler.schwinge.homeip.net> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="==-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" Return-Path: tschwing@mentor.com X-SW-Source: 2020-01/txt/msg00648.txt.bz2 --==-=-= Content-Type: multipart/mixed; boundary="=-=-=" --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Content-length: 2772 Hi! On 2019-12-21T23:02:38+0100, I wrote: > On 2019-12-20T17:46:57+0100, "Harwath, Frederik" wrote: >>> > --- a/include/gomp-constants.h >>> > +++ b/include/gomp-constants.h >>> > +#define GOMP_DEVICE_CURRENT -3 >>> Should this actually get value '-1' instead of '-3'? Or, is the OpenACC >>> 'acc_device_t' code already paying special attention to negative values >>> '-1', '-2'? (I don't think so.) >>> | Also, 'acc_device_current' is a libgomp-internal thing (doesn't inter= face >>> | with the compiler proper), so strictly speaking 'GOMP_DEVICE_CURRENT' >>> | isn't needed in 'include/gomp-constants.h'. But probably still a good >>> | idea to list it there, in this canonical place, to keep the several l= ists >>> | of device types coherent. >>> I still wonder about that... ;-) > I still think that 'GOMP_DEVICE_CURENT' should get value '-1' (and > probably be rename 'GOACC_DEVICE_CURRENT' to make more obvious that it's > not related to the 'GOMP_DEVICE_*' ones), but we shall have a look at > that later (before GCC 10 release); that's libgomp/OpenACC-internal, > doesn't affect anything else. That's still pending. Recently, "Missing definition for acc_device_current" got filed; let's (also/first) watch/wait what comes out of that. Also pending is the 'libgomp/plugin/plugin-gcn.c' update; Frederik is working on that. A few other (minor) open issue we shall discuss at some later point in time. >>> | Before Frederik starts working on integrating this into GCC trunk, do= you >>> | (Jakub) agree with the libgomp plugin interface changes as implemente= d by >>> | Maciej? For example, top-level 'GOMP_OFFLOAD_get_property' function = in >>> | 'struct gomp_device_descr' instead of stuffing this into its >>> | 'acc_dispatch_t openacc'. (I never understood why the OpenACC functi= ons >>> | need to be segregated like they are.) >>> >>> Jakub didn't answer, but I now myself decided that we should group this >>> with the other OpenACC libgomp-plugin functions, as this interface is >>> defined in terms of OpenACC-specific stuff such as 'acc_device_t'. Done. This also means that we don't anymore need (stub) implementations in the libgomp plugins that don't implement OpenACC support. >>> Maybe [stuff] should move from 'include/gomp-constants.h' to >>> 'libgomp/oacc-int.h'. I'll think about that again, when I'm awake again >>> tomorrow. ;-) >> >> Have you made up your mind yet? :-) > > Still sleepy. ;-) Done. In the end, 'libgomp/libgomp-plugin.h' is the place to be, as that defines, well, the libgomp plugin interface. ;-) See attached "OpenACC 'acc_get_property' cleanup"; committed to trunk in r280150. Gr=C3=BC=C3=9Fe Thomas --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-OpenACC-acc_get_property-cleanup.trunk.patch Content-Transfer-Encoding: quoted-printable Content-length: 21296 =46rom f98381a87233ddef09bf7d3a0d47807215930063 Mon Sep 17 00:00:00 2001 From: tschwinge Date: Fri, 10 Jan 2020 22:24:36 +0000 Subject: [PATCH] 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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@280150 138bc75d-0d04-0410-9= 61f-82ee72b054a4 --- include/ChangeLog | 4 + include/gomp-constants.h | 15 -- libgomp/ChangeLog | 9 ++ libgomp/libgomp-plugin.h | 36 ++++- libgomp/libgomp.h | 3 +- libgomp/oacc-host.c | 47 +++--- libgomp/oacc-init.c | 10 +- libgomp/openacc.f90 | 2 +- libgomp/openacc.h | 3 +- libgomp/plugin/plugin-gcn.c | 22 +-- libgomp/plugin/plugin-hsa.c | 26 ---- libgomp/plugin/plugin-nvptx.c | 138 +++++++++--------- libgomp/target.c | 4 +- liboffloadmic/ChangeLog | 5 + .../plugin/libgomp-plugin-intelmic.cpp | 21 --- 15 files changed, 163 insertions(+), 182 deletions(-) diff --git a/include/ChangeLog b/include/ChangeLog index 0069df3c5c6..8a2feb911cb 100644 --- a/include/ChangeLog +++ b/include/ChangeLog @@ -1,3 +1,7 @@ +2020-01-10 Thomas Schwinge + + * gomp-constants.h (enum gomp_device_property): Remove. + 2020-01-01 Jakub Jelinek =20 Update copyright years. diff --git a/include/gomp-constants.h b/include/gomp-constants.h index 5a7cc2c3f01..1587e4d2ba2 100644 --- a/include/gomp-constants.h +++ b/include/gomp-constants.h @@ -199,21 +199,6 @@ enum gomp_map_kind #define GOMP_DEVICE_ICV -1 #define GOMP_DEVICE_HOST_FALLBACK -2 =20 -/* 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 =3D 1, - GOMP_DEVICE_PROPERTY_FREE_MEMORY =3D 2, - GOMP_DEVICE_PROPERTY_NAME =3D 0x10001, - GOMP_DEVICE_PROPERTY_VENDOR =3D 0x10002, - GOMP_DEVICE_PROPERTY_DRIVER =3D 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) diff --git a/libgomp/ChangeLog b/libgomp/ChangeLog index 81d0c164a3a..de286ddac7c 100644 --- a/libgomp/ChangeLog +++ b/libgomp/ChangeLog @@ -1,5 +1,14 @@ 2020-01-10 Thomas Schwinge =20 + * 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) : Clean up/elaborate code paths. diff --git a/libgomp/libgomp-plugin.h b/libgomp/libgomp-plugin.h index 2559ce0ea3a..64f138d3821 100644 --- a/libgomp/libgomp-plugin.h +++ b/libgomp/libgomp-plugin.h @@ -54,13 +54,6 @@ enum offload_target_type OFFLOAD_TARGET_TYPE_GCN =3D 8 }; =20 -/* 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; @@ -75,6 +68,32 @@ struct goacc_asyncqueue_list typedef struct goacc_asyncqueue *goacc_aq; typedef struct goacc_asyncqueue_list *goacc_aq_list; =20 + +/* 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 =3D 1, + GOACC_PROPERTY_FREE_MEMORY =3D 2, + GOACC_PROPERTY_NAME =3D GOACC_PROPERTY_STRING_MASK | 1, + GOACC_PROPERTY_VENDOR =3D GOACC_PROPERTY_STRING_MASK | 2, + GOACC_PROPERTY_DRIVER =3D 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 @@ -101,7 +120,6 @@ extern const char *GOMP_OFFLOAD_get_name (void); 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, in= t); extern bool GOMP_OFFLOAD_init_device (int); extern bool GOMP_OFFLOAD_fini_device (int); extern unsigned GOMP_OFFLOAD_version (void); @@ -141,6 +159,8 @@ extern void *GOMP_OFFLOAD_openacc_cuda_get_current_cont= ext (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); =20 #ifdef __cplusplus } diff --git a/libgomp/libgomp.h b/libgomp/libgomp.h index 44703aaae6a..f5415bb156c 100644 --- a/libgomp/libgomp.h +++ b/libgomp/libgomp.h @@ -1068,6 +1068,8 @@ typedef struct acc_dispatch_t __typeof (GOMP_OFFLOAD_openacc_async_host2dev) *host2dev_func; } async; =20 + __typeof (GOMP_OFFLOAD_openacc_get_property) *get_property_func; + /* NVIDIA target specific routines. */ struct { __typeof (GOMP_OFFLOAD_openacc_cuda_get_current_device) @@ -1113,7 +1115,6 @@ struct gomp_device_descr __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; diff --git a/libgomp/oacc-host.c b/libgomp/oacc-host.c index 22c18942752..46387897b13 100644 --- a/libgomp/oacc-host.c +++ b/libgomp/oacc-host.c @@ -59,27 +59,6 @@ host_get_num_devices (void) return 1; } =20 -static union gomp_device_property_value -host_get_property (int n, int prop) -{ - union gomp_device_property_value nullval =3D { .val =3D 0 }; - - if (n >=3D host_get_num_devices ()) - return nullval; - - switch (prop) - { - case GOMP_DEVICE_PROPERTY_NAME: - return (union gomp_device_property_value) { .ptr =3D "GOMP" }; - case GOMP_DEVICE_PROPERTY_VENDOR: - return (union gomp_device_property_value) { .ptr =3D "GNU" }; - case GOMP_DEVICE_PROPERTY_DRIVER: - return (union gomp_device_property_value) { .ptr =3D VERSION }; - default: - return nullval; - } -} - static bool host_init_device (int n __attribute__ ((unused))) { @@ -245,6 +224,29 @@ host_openacc_async_destruct (struct goacc_asyncqueue *= aq return true; } =20 +static union goacc_property_value +host_openacc_get_property (int n, enum goacc_property prop) +{ + union goacc_property_value nullval =3D { .val =3D 0 }; + + if (n >=3D host_get_num_devices ()) + return nullval; + + switch (prop) + { + case GOACC_PROPERTY_NAME: + return (union goacc_property_value) { .ptr =3D "GOMP" }; + case GOACC_PROPERTY_VENDOR: + return (union goacc_property_value) { .ptr =3D "GNU" }; + case GOACC_PROPERTY_DRIVER: + return (union goacc_property_value) { .ptr =3D VERSION }; + case GOACC_PROPERTY_MEMORY: + case GOACC_PROPERTY_FREE_MEMORY: + default: + return nullval; + } +} + static void * host_openacc_create_thread_data (int ord __attribute__ ((unused))) { @@ -269,7 +271,6 @@ static struct gomp_device_descr host_dispatch =3D .get_caps_func =3D host_get_caps, .get_type_func =3D host_get_type, .get_num_devices_func =3D host_get_num_devices, - .get_property_func =3D host_get_property, .init_device_func =3D host_init_device, .fini_device_func =3D host_fini_device, .version_func =3D host_version, @@ -303,6 +304,8 @@ static struct gomp_device_descr host_dispatch =3D .host2dev_func =3D host_openacc_async_host2dev, }, =20 + .get_property_func =3D host_openacc_get_property, + .cuda =3D { .get_current_device_func =3D NULL, .get_current_context_func =3D NULL, diff --git a/libgomp/oacc-init.c b/libgomp/oacc-init.c index d15f08f7e18..89a30b3e716 100644 --- a/libgomp/oacc-init.c +++ b/libgomp/oacc-init.c @@ -760,14 +760,14 @@ acc_set_device_num (int ord, acc_device_t d) =20 ialias (acc_set_device_num) =20 -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 =3D goacc_thread (); =20 if (d =3D=3D 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); =20 gomp_mutex_lock (&acc_device_lock); =20 @@ -789,7 +789,7 @@ get_property_any (int ord, acc_device_t d, acc_device_p= roperty_t prop) =20 assert (dev); =20 - return dev->get_property_func (dev->target_id, prop); + return dev->openacc.get_property_func (dev->target_id, prop); } =20 size_t @@ -798,7 +798,7 @@ acc_get_property (int ord, acc_device_t d, acc_device_p= roperty_t prop) if (!known_device_type_p (d)) unknown_device_type_error(d); =20 - if (prop & GOMP_DEVICE_PROPERTY_STRING_MASK) + if (prop & GOACC_PROPERTY_STRING_MASK) return 0; else return get_property_any (ord, d, prop).val; @@ -812,7 +812,7 @@ acc_get_property_string (int ord, acc_device_t d, acc_d= evice_property_t prop) if (!known_device_type_p (d)) unknown_device_type_error(d); =20 - if (prop & GOMP_DEVICE_PROPERTY_STRING_MASK) + if (prop & GOACC_PROPERTY_STRING_MASK) return get_property_any (ord, d, prop).ptr; else return NULL; diff --git a/libgomp/openacc.f90 b/libgomp/openacc.f90 index a3083168a3a..6c92c7c12c9 100644 --- a/libgomp/openacc.f90 +++ b/libgomp/openacc.f90 @@ -53,7 +53,7 @@ module openacc_kinds =20 integer, parameter :: acc_device_property =3D c_size_t =20 - ! 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 =3D 1 integer (acc_device_property), parameter :: acc_property_free_memory =3D= 2 integer (acc_device_property), parameter :: acc_property_name =3D int(Z'= 10001') diff --git a/libgomp/openacc.h b/libgomp/openacc.h index 66786d7521f..62b2b0ea559 100644 --- a/libgomp/openacc.h +++ b/libgomp/openacc.h @@ -64,8 +64,7 @@ typedef enum acc_device_t { } acc_device_t; =20 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 =3D 1, acc_property_free_memory =3D 2, acc_property_name =3D 0x10001, 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; } =20 -union gomp_device_property_value -GOMP_OFFLOAD_get_property (int device, int prop) -{ - /* Stub. Check device and return default value for unsupported propertie= s. */ - /* TODO: Implement this function. */ - get_agent_info (device); - - union gomp_device_property_value nullval =3D { .val =3D 0 }; - return nullval; -} - /* Initialize device (agent) number N so that it can be used for computati= on. Return TRUE on success. */ =20 @@ -3999,6 +3988,17 @@ GOMP_OFFLOAD_openacc_async_dev2host (int device, voi= d *dst, const void *src, return true; } =20 +union goacc_property_value +GOMP_OFFLOAD_openacc_get_property (int device, enum goacc_property prop) +{ + /* Stub. Check device and return default value for unsupported propertie= s. */ + /* TODO: Implement this function. */ + get_agent_info (device); + + union goacc_property_value nullval =3D { .val =3D 0 }; + return nullval; +} + /* Set up plugin-specific thread-local-data (host-side). */ =20 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; } =20 -/* 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 =3D { .val =3D 0 }; - - if (!init_hsa_context ()) - return nullval; - if (n >=3D 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 =3D "HSA" }; - default: - return nullval; - } -} - /* Part of the libgomp plugin interface. Initialize agent number N so tha= t it can be used for computation. Return TRUE on success. */ =20 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 (); } =20 -union gomp_device_property_value -GOMP_OFFLOAD_get_property (int n, int prop) -{ - union gomp_device_property_value propval =3D { .val =3D 0 }; - - pthread_mutex_lock (&ptx_dev_lock); - - if (n >=3D nvptx_get_num_devices () || n < 0 || ptx_devices[n] =3D=3D NU= LL) - { - pthread_mutex_unlock (&ptx_dev_lock); - return propval; - } - - struct ptx_device *ptx_dev =3D 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 =3D 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 =3D=3D 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 =3D free_mem; - } - break; - case GOMP_DEVICE_PROPERTY_NAME: - propval.ptr =3D ptx_dev->name; - break; - case GOMP_DEVICE_PROPERTY_VENDOR: - propval.ptr =3D "Nvidia"; - break; - case GOMP_DEVICE_PROPERTY_DRIVER: - propval.ptr =3D 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; } =20 +union goacc_property_value +GOMP_OFFLOAD_openacc_get_property (int n, enum goacc_property prop) +{ + union goacc_property_value propval =3D { .val =3D 0 }; + + pthread_mutex_lock (&ptx_dev_lock); + + if (n >=3D nvptx_get_num_devices () || n < 0 || ptx_devices[n] =3D=3D NU= LL) + { + pthread_mutex_unlock (&ptx_dev_lock); + return propval; + } + + struct ptx_device *ptx_dev =3D 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 =3D 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 =3D=3D 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 =3D free_mem; + } + break; + case GOACC_PROPERTY_NAME: + propval.ptr =3D ptx_dev->name; + break; + case GOACC_PROPERTY_VENDOR: + propval.ptr =3D "Nvidia"; + break; + case GOACC_PROPERTY_DRIVER: + propval.ptr =3D 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 war= ps and ensure that number of warps does not exceed CUDA limits as well as = GCC's own limits. */ diff --git a/libgomp/target.c b/libgomp/target.c index 38de1c0cf92..3df007283f4 100644 --- a/libgomp/target.c +++ b/libgomp/target.c @@ -3028,7 +3028,6 @@ gomp_load_plugin_for_device (struct gomp_device_descr= *device, DLSYM (get_caps); DLSYM (get_type); DLSYM (get_num_devices); - DLSYM (get_property); DLSYM (init_device); DLSYM (fini_device); DLSYM (load_image); @@ -3061,7 +3060,8 @@ gomp_load_plugin_for_device (struct gomp_device_descr= *device, 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. */ diff --git a/liboffloadmic/ChangeLog b/liboffloadmic/ChangeLog index b5fae878e9d..eba51003627 100644 --- a/liboffloadmic/ChangeLog +++ b/liboffloadmic/ChangeLog @@ -1,3 +1,8 @@ +2020-01-10 Thomas Schwinge + + * plugin/libgomp-plugin-intelmic.cpp (GOMP_OFFLOAD_get_property): + Remove. + 2019-12-22 Maciej W. Rozycki Frederik Harwath Thomas Schwinge diff --git a/liboffloadmic/plugin/libgomp-plugin-intelmic.cpp b/liboffloadm= ic/plugin/libgomp-plugin-intelmic.cpp index 40d97702b87..d1678d0514e 100644 --- a/liboffloadmic/plugin/libgomp-plugin-intelmic.cpp +++ b/liboffloadmic/plugin/libgomp-plugin-intelmic.cpp @@ -174,27 +174,6 @@ GOMP_OFFLOAD_get_num_devices (void) return num_devices; } =20 -extern "C" union gomp_device_property_value -GOMP_OFFLOAD_get_property (int n, int prop) -{ - union gomp_device_property_value nullval =3D { .val =3D 0 }; - - if (n >=3D 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 =3D "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) --=20 2.17.1 --=-=-=-- --==-=-= Content-Type: application/pgp-signature; name="signature.asc" Content-length: 658 -----BEGIN PGP SIGNATURE----- iQGzBAEBCgAdFiEEU9WEfWKGQazCmycCAKI7+41Q4XkFAl4ZABsACgkQAKI7+41Q 4Xk7uQv/b7liaTZ6YB1tGH+yvc9dtL2fI4mgLAjgQ/4YpQ6POj+KVF2xTR4r7vdg BRWG1f9U4Dl8qo0AiW2zPPhSLj2HclAZkNb2OGoIW34HDqiexpOtA20m11I0qDxx VMJEaVsqjhZ8gIA0HdVjjZ3VpBYMIgs7kD/GCKxpJaotLnJoQEuED1AJhd1JDP5U Hv2BK5w3jUzEFQ/JYRFt4lBqIMSJUYnTtcB0Gx3oLlsQ6WfZUbcmFngeKex+tv64 kEEndtX7hIKC2mek/oRps/5SpBSV3UQFOLBBj0sDQariu+C7ThhNRwr1lGSLRCuz +YrnF9zLfsVGwS4ZyyJGE7oS1FFx1qoSjcnWwaEIE/HHr4ifJ9oFeS0i+z33ldDp 2CVqpApiAVbNgG8ftpDX9uHRsSIlzg6kN2Koe3pmn/iouNPV8LfsZkqBMuIXgWV9 gzyWV4JrortCt6Zvu+Jfc7WrV+fuf04rUiDGVOntNJ7jTgDyiC5kPMkK2+MuAlqZ Lkecz8dv =Jvq0 -----END PGP SIGNATURE----- --==-=-=--