From patchwork Mon Dec 22 16:47:47 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Thomas Schwinge X-Patchwork-Id: 423433 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 DE5231400B7 for ; Tue, 23 Dec 2014 03:48:13 +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=s/Pc+0DQY2laTe4+ mIWh1eCNyItbujoWlkFOF7fuivlq9ZOUVymEg8p5bPYn4EjSPX01SOz6jXURF9ja DE4PQ4o3ZJ9OdI6ffmfRxzkNO8DZYcc7OrUk0rq4G1CHpEqHnmvC7i/RQEIdJ6eQ NKCn8sxvF0/o27HTQmSO6m4hxPk= 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=Pyra3F0twO6Xh0IbNTIBZ+ R9LFs=; b=aOWzewauYfEA1TOt/LRYAmjwCQYBBtPQiOs0J5neRgQS9O4ffwu1no pryM2S77dK3M/w9+lVlzdfKTgoGZ8ukbYWmArujlHuI0HSGbUJfJasrYY3fXmMDi q4V+KFbwLOvtVi4ULTZ64FPXMbOT/HKucY2/bay2tMn96OT5DqVTI= Received: (qmail 8908 invoked by alias); 22 Dec 2014 16:48:05 -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 8863 invoked by uid 89); 22 Dec 2014 16:48:03 -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 16:48:01 +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 1Y369E-0006jb-LT from Thomas_Schwinge@mentor.com ; Mon, 22 Dec 2014 08:47:57 -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 16:47:54 +0000 From: Thomas Schwinge To: Jakub Jelinek , CC: Julian Brown Subject: Re: [gomp4] libgomp updates In-Reply-To: <87h9wtucv7.fsf@schwinge.name> References: <87oar1ud7y.fsf@schwinge.name> <87h9wtucv7.fsf@schwinge.name> User-Agent: Notmuch/0.9-101-g81dad07 (http://notmuchmail.org) Emacs/24.3.1 (x86_64-pc-linux-gnu) Date: Mon, 22 Dec 2014 17:47:47 +0100 Message-ID: <87sig7y6ks.fsf@schwinge.name> MIME-Version: 1.0 Hi! On Wed, 17 Dec 2014 23:31:56 +0100, I wrote: > On Wed, 17 Dec 2014 23:24:17 +0100, I wrote: > > Committed to gomp-4_0-branch in r218839: > > > > commit 1c4f05a68c6d0d5b6137bb6d85a293d16727b389 > > Author: tschwinge > > Date: Wed Dec 17 22:23:02 2014 +0000 > > > > libgomp updates. > > This has broken libgomp/libgomp_target.h usage from liboffloadmic/plugin. > Committed to gomp-4_0-branch in r218841: > > commit db16ceabfcaaa6c9e41c01e289201e6a9fbe3b26 > Author: tschwinge > Date: Wed Dec 17 22:30:30 2014 +0000 > > libgomp: Again make libgomp_target.h safe to use "from outside". > > libgomp/ > * libgomp_g.h: Move internal stuff from here... > * libgomp_target.h: ..., and here... > * libgomp.h: ... into here. > --- libgomp/libgomp.h > +++ libgomp/libgomp.h > +#define TARGET_CAP_SHARED_MEM 1 > +#define TARGET_CAP_NATIVE_EXEC 2 > +#define TARGET_CAP_OPENMP_400 4 > +#define TARGET_CAP_OPENACC_200 8 > --- libgomp/libgomp_target.h > +++ libgomp/libgomp_target.h > -#define TARGET_CAP_SHARED_MEM 1 > -#define TARGET_CAP_NATIVE_EXEC 2 > -#define TARGET_CAP_OPENMP_400 4 > -#define TARGET_CAP_OPENACC_200 8 Those are actually part of the libgomp/plugin interface; committed to gomp-4_0-branch in r219020: commit 5932be162d00a1a8c27ec612255c01a57327a942 Author: tschwinge Date: Mon Dec 22 16:47:08 2014 +0000 libgomp: GOMP_OFFLOAD_* are part of the libgomp/plugin interface. libgomp/ * libgomp.h (TARGET_CAP_SHARED_MEM, TARGET_CAP_NATIVE_EXEC) (TARGET_CAP_OPENMP_400, TARGET_CAP_OPENACC_200): Remove, and instead... * libgomp_target.h (GOMP_OFFLOAD_CAP_SHARED_MEM) (GOMP_OFFLOAD_CAP_NATIVE_EXEC, GOMP_OFFLOAD_CAP_OPENMP_400) (GOMP_OFFLOAD_CAP_OPENACC_200): ... add these new definitions. Change all users. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gomp-4_0-branch@219020 138bc75d-0d04-0410-961f-82ee72b054a4 --- libgomp/ChangeLog.gomp | 8 ++++++++ libgomp/libgomp.h | 5 ----- libgomp/libgomp_target.h | 6 ++++++ libgomp/oacc-host.c | 5 +++-- libgomp/oacc-mem.c | 2 +- libgomp/oacc-parallel.c | 8 ++++---- libgomp/plugin/plugin-host.c | 25 +++++++++++++------------ libgomp/plugin/plugin-nvptx.c | 25 ++++++++++++------------- libgomp/target.c | 26 +++++++++++++++----------- 9 files changed, 62 insertions(+), 48 deletions(-) Grüße, Thomas diff --git libgomp/ChangeLog.gomp libgomp/ChangeLog.gomp index a36ec1f..898040d 100644 --- libgomp/ChangeLog.gomp +++ libgomp/ChangeLog.gomp @@ -1,5 +1,13 @@ 2014-12-22 Thomas Schwinge + * libgomp.h (TARGET_CAP_SHARED_MEM, TARGET_CAP_NATIVE_EXEC) + (TARGET_CAP_OPENMP_400, TARGET_CAP_OPENACC_200): Remove, and + instead... + * libgomp_target.h (GOMP_OFFLOAD_CAP_SHARED_MEM) + (GOMP_OFFLOAD_CAP_NATIVE_EXEC, GOMP_OFFLOAD_CAP_OPENMP_400) + (GOMP_OFFLOAD_CAP_OPENACC_200): ... add these new definitions. + Change all users. + * plugin/plugin-nvptx.c (GOMP_OFFLOAD_get_name): Return "nvptx". * oacc-init.c (resolve_device): Update for that using... (get_openacc_name): ... this new function. diff --git libgomp/libgomp.h libgomp/libgomp.h index 78de0b4..866f6ca 100644 --- libgomp/libgomp.h +++ libgomp/libgomp.h @@ -662,11 +662,6 @@ struct target_mem_desc { splay_tree_key list[]; }; -#define TARGET_CAP_SHARED_MEM 1 -#define TARGET_CAP_NATIVE_EXEC 2 -#define TARGET_CAP_OPENMP_400 4 -#define TARGET_CAP_OPENACC_200 8 - /* Information about mapped memory regions (per device/context). */ struct gomp_memory_mapping diff --git libgomp/libgomp_target.h libgomp/libgomp_target.h index b6723fe..63083f3 100644 --- libgomp/libgomp_target.h +++ libgomp/libgomp_target.h @@ -25,6 +25,12 @@ #ifndef LIBGOMP_TARGET_H #define LIBGOMP_TARGET_H 1 +/* Capabilities of offloading devices. */ +#define GOMP_OFFLOAD_CAP_SHARED_MEM (1 << 0) +#define GOMP_OFFLOAD_CAP_NATIVE_EXEC (1 << 1) +#define GOMP_OFFLOAD_CAP_OPENMP_400 (1 << 2) +#define GOMP_OFFLOAD_CAP_OPENACC_200 (1 << 3) + /* Type of offload target device. Keep in sync with include/gomp-constants.h. */ enum offload_target_type { diff --git libgomp/oacc-host.c libgomp/oacc-host.c index f1ec426..3b90259 100644 --- libgomp/oacc-host.c +++ libgomp/oacc-host.c @@ -35,8 +35,9 @@ static struct gomp_device_descr host_dispatch = .name = "host", .type = OFFLOAD_TARGET_TYPE_HOST, - .capabilities = TARGET_CAP_OPENACC_200 | TARGET_CAP_NATIVE_EXEC - | TARGET_CAP_SHARED_MEM, + .capabilities = (GOMP_OFFLOAD_CAP_OPENACC_200 + | GOMP_OFFLOAD_CAP_NATIVE_EXEC + | GOMP_OFFLOAD_CAP_SHARED_MEM), .id = 0, .is_initialized = false, diff --git libgomp/oacc-mem.c libgomp/oacc-mem.c index 7453020..8f7868e 100644 --- libgomp/oacc-mem.c +++ libgomp/oacc-mem.c @@ -259,7 +259,7 @@ acc_map_data (void *h, void *d, size_t s) struct goacc_thread *thr = goacc_thread (); struct gomp_device_descr *acc_dev = thr->dev; - if (acc_dev->capabilities & TARGET_CAP_SHARED_MEM) + if (acc_dev->capabilities & GOMP_OFFLOAD_CAP_SHARED_MEM) { if (d != h) gomp_fatal ("cannot map data on shared-memory system"); diff --git libgomp/oacc-parallel.c libgomp/oacc-parallel.c index 888f20d..d430eb4 100644 --- libgomp/oacc-parallel.c +++ libgomp/oacc-parallel.c @@ -131,7 +131,7 @@ GOACC_parallel (int device, void (*fn) (void *), const void *offload_table, acc_dev->openacc.async_set_async_func (async); - if (!(acc_dev->capabilities & TARGET_CAP_NATIVE_EXEC)) + if (!(acc_dev->capabilities & GOMP_OFFLOAD_CAP_NATIVE_EXEC)) { k.host_start = (uintptr_t) fn; k.host_end = k.host_start + 1; @@ -187,7 +187,7 @@ GOACC_data_start (int device, const void *offload_table, size_t mapnum, struct gomp_device_descr *acc_dev = thr->dev; /* Host fallback or 'do nothing'. */ - if ((acc_dev->capabilities & TARGET_CAP_SHARED_MEM) + if ((acc_dev->capabilities & GOMP_OFFLOAD_CAP_SHARED_MEM) || host_fallback) { tgt = gomp_map_vars (NULL, 0, NULL, NULL, NULL, NULL, true, false); @@ -233,7 +233,7 @@ GOACC_enter_exit_data (int device, const void *offload_table, size_t mapnum, thr = goacc_thread (); acc_dev = thr->dev; - if ((acc_dev->capabilities & TARGET_CAP_SHARED_MEM) + if ((acc_dev->capabilities & GOMP_OFFLOAD_CAP_SHARED_MEM) || host_fallback) return; @@ -445,7 +445,7 @@ GOACC_update (int device, const void *offload_table, size_t mapnum, struct goacc_thread *thr = goacc_thread (); struct gomp_device_descr *acc_dev = thr->dev; - if ((acc_dev->capabilities & TARGET_CAP_SHARED_MEM) + if ((acc_dev->capabilities & GOMP_OFFLOAD_CAP_SHARED_MEM) || host_fallback) return; diff --git libgomp/plugin/plugin-host.c libgomp/plugin/plugin-host.c index 8bca998..324e71b 100644 --- libgomp/plugin/plugin-host.c +++ libgomp/plugin/plugin-host.c @@ -70,29 +70,30 @@ GOMP_OFFLOAD_get_name (void) #endif } -STATIC int -GOMP_OFFLOAD_get_type (void) -{ -#ifdef HOST_NONSHM_PLUGIN - return OFFLOAD_TARGET_TYPE_HOST_NONSHM; -#else - return OFFLOAD_TARGET_TYPE_HOST; -#endif -} - STATIC unsigned int GOMP_OFFLOAD_get_caps (void) { - unsigned int caps = TARGET_CAP_OPENACC_200 | TARGET_CAP_NATIVE_EXEC; + unsigned int caps = (GOMP_OFFLOAD_CAP_OPENACC_200 + | GOMP_OFFLOAD_CAP_NATIVE_EXEC); #ifndef HOST_NONSHM_PLUGIN - caps |= TARGET_CAP_SHARED_MEM; + caps |= GOMP_OFFLOAD_CAP_SHARED_MEM; #endif return caps; } STATIC int +GOMP_OFFLOAD_get_type (void) +{ +#ifdef HOST_NONSHM_PLUGIN + return OFFLOAD_TARGET_TYPE_HOST_NONSHM; +#else + return OFFLOAD_TARGET_TYPE_HOST; +#endif +} + +STATIC int GOMP_OFFLOAD_get_num_devices (void) { return 1; diff --git libgomp/plugin/plugin-nvptx.c libgomp/plugin/plugin-nvptx.c index d423d3a..aaed04b 100644 --- libgomp/plugin/plugin-nvptx.c +++ libgomp/plugin/plugin-nvptx.c @@ -1483,25 +1483,24 @@ nvptx_set_cuda_stream (int async, void *stream) /* Plugin entry points. */ - -int -GOMP_OFFLOAD_get_type (void) -{ - return OFFLOAD_TARGET_TYPE_NVIDIA_PTX; -} - -unsigned int -GOMP_OFFLOAD_get_caps (void) -{ - return TARGET_CAP_OPENACC_200; -} - const char * GOMP_OFFLOAD_get_name (void) { return "nvptx"; } +unsigned int +GOMP_OFFLOAD_get_caps (void) +{ + return GOMP_OFFLOAD_CAP_OPENACC_200; +} + +int +GOMP_OFFLOAD_get_type (void) +{ + return OFFLOAD_TARGET_TYPE_NVIDIA_PTX; +} + int GOMP_OFFLOAD_get_num_devices (void) { diff --git libgomp/target.c libgomp/target.c index bdfec67..dadcc03 100644 --- libgomp/target.c +++ libgomp/target.c @@ -844,7 +844,8 @@ GOMP_target (int device, void (*fn) (void *), const void *offload_table, if (devicep != NULL && !devicep->is_initialized) gomp_init_dev_tables (devicep); - if (devicep == NULL || !(devicep->capabilities & TARGET_CAP_OPENMP_400)) + if (devicep == NULL + || !(devicep->capabilities & GOMP_OFFLOAD_CAP_OPENMP_400)) { /* Host fallback. */ struct gomp_thread old_thr, *thr = gomp_thread (); @@ -863,7 +864,7 @@ GOMP_target (int device, void (*fn) (void *), const void *offload_table, void *fn_addr; - if (devicep->capabilities & TARGET_CAP_NATIVE_EXEC) + if (devicep->capabilities & GOMP_OFFLOAD_CAP_NATIVE_EXEC) fn_addr = (void *) fn; else { @@ -909,7 +910,8 @@ GOMP_target_data (int device, const void *offload_table, size_t mapnum, if (devicep != NULL && !devicep->is_initialized) gomp_init_dev_tables (devicep); - if (devicep == NULL || !(devicep->capabilities & TARGET_CAP_OPENMP_400)) + if (devicep == NULL + || !(devicep->capabilities & GOMP_OFFLOAD_CAP_OPENMP_400)) { /* Host fallback. */ struct gomp_task_icv *icv = gomp_icv (false); @@ -968,7 +970,7 @@ GOMP_target_update (int device, const void *offload_table, size_t mapnum, gomp_init_device (devicep); gomp_mutex_unlock (&mm->lock); - if (!(devicep->capabilities & TARGET_CAP_OPENMP_400)) + if (!(devicep->capabilities & GOMP_OFFLOAD_CAP_OPENMP_400)) return; gomp_update (devicep, &devicep->mem_map, mapnum, hostaddrs, sizes, kinds, @@ -1050,9 +1052,9 @@ gomp_load_plugin_for_device (struct gomp_device_descr *device, DLSYM (dev2host); DLSYM (host2dev); device->capabilities = device->get_caps_func (); - if (device->capabilities & TARGET_CAP_OPENMP_400) + if (device->capabilities & GOMP_OFFLOAD_CAP_OPENMP_400) DLSYM (run); - if (device->capabilities & TARGET_CAP_OPENACC_200) + if (device->capabilities & GOMP_OFFLOAD_CAP_OPENACC_200) { optional_present = optional_total = 0; DLSYM_OPT (openacc.exec, openacc_parallel); @@ -1071,7 +1073,8 @@ gomp_load_plugin_for_device (struct gomp_device_descr *device, DLSYM_OPT (openacc.async_set_async, openacc_async_set_async); DLSYM_OPT (openacc.create_thread_data, openacc_create_thread_data); DLSYM_OPT (openacc.destroy_thread_data, openacc_destroy_thread_data); - /* Require all the OpenACC handlers if we have TARGET_CAP_OPENACC_200. */ + /* Require all the OpenACC handlers if we have + GOMP_OFFLOAD_CAP_OPENACC_200. */ if (optional_present != optional_total) { err = "plugin missing OpenACC handler function"; @@ -1197,16 +1200,17 @@ gomp_target_init (void) } while (next); - /* Prefer a device with TARGET_CAP_OPENMP_400 for ICV default-device-var. */ + /* Prefer a device with GOMP_OFFLOAD_CAP_OPENMP_400 for ICV + default-device-var. */ if (num_devices > 1) { int d = gomp_icv (false)->default_device_var; - if (!(devices[d].capabilities & TARGET_CAP_OPENMP_400)) + if (!(devices[d].capabilities & GOMP_OFFLOAD_CAP_OPENMP_400)) { for (i = 0; i < num_devices; i++) { - if (devices[i].capabilities & TARGET_CAP_OPENMP_400) + if (devices[i].capabilities & GOMP_OFFLOAD_CAP_OPENMP_400) { struct gomp_device_descr device_tmp = devices[d]; devices[d] = devices[i]; @@ -1230,7 +1234,7 @@ gomp_target_init (void) /* The 'devices' array can be moved (by the realloc call) until we have found all the plugins, so registering with the OpenACC runtime (which takes a copy of the pointer argument) must be delayed until now. */ - if (devices[i].capabilities & TARGET_CAP_OPENACC_200) + if (devices[i].capabilities & GOMP_OFFLOAD_CAP_OPENACC_200) goacc_register (&devices[i]); }