From patchwork Tue Apr 14 14:15:02 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julian Brown X-Patchwork-Id: 461152 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 D57B214027F for ; Wed, 15 Apr 2015 00:15:34 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass reason="1024-bit key; unprotected key" header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=yJvIEHtG; dkim-adsp=none (unprotected policy); dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:in-reply-to:references :mime-version:content-type; q=dns; s=default; b=CBHc+INSmPgzCtaV nZ/uh1ECnG/Jz9O08ErjA3yxw7gxEbeMps+MsAkueerAKQWXPgbZqOezj1J/OJij qr41xO/sIJMpY6ByuXBDg6wRsWxidjf8MxNiOs1FGL26CQLze8P0+UQpej0OTZhI v8QJVE3xkbXpsQjBcTf70ZZmJcU= 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:date :from:to:cc:subject:message-id:in-reply-to:references :mime-version:content-type; s=default; bh=J4a277STCs0/npKl7Aj8fH tMHCc=; b=yJvIEHtGmNAOICYIzC4xGbUlDGwSarkBKGAXIPxxNQxtHqFKSrLZi/ 2tnEnr9pkqRgKSc/r1EWObIhXVszGNIj5rC2gPY1oJwExaAJU8CWA5k6Z8FgCG8F QzZ0mxJVI/Kvr5ON3l8nC/990YpWhPI/3w6jqy6+WOpeWL0feZNNA= Received: (qmail 107398 invoked by alias); 14 Apr 2015 14:15:26 -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 106669 invoked by uid 89); 14 Apr 2015 14:15:25 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.7 required=5.0 tests=AWL, BAYES_00, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=no 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; Tue, 14 Apr 2015 14:15:16 +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 1Yi1cN-00046Y-RD from Julian_Brown@mentor.com ; Tue, 14 Apr 2015 07:15:12 -0700 Received: from octopus (137.202.0.76) by SVR-IES-FEM-01.mgc.mentorg.com (137.202.0.104) with Microsoft SMTP Server id 14.3.224.2; Tue, 14 Apr 2015 15:15:10 +0100 Date: Tue, 14 Apr 2015 15:15:02 +0100 From: Julian Brown To: Ilya Verbin CC: Jakub Jelinek , Thomas Schwinge , , Kirill Yukhin Subject: Re: libgomp nvptx plugin: rework initialisation and support the proposed load/unload hooks (was: Merge current set of OpenACC changes from gomp-4_0-branch) Message-ID: <20150414151502.5ca882a4@octopus> In-Reply-To: <20150408145856.GA19410@msticlxl57.ims.intel.com> References: <20150331125206.GC64930@msticlxl57.ims.intel.com> <20150331130758.GA19273@tucnak.redhat.com> <20150331161036.GA623@msticlxl57.ims.intel.com> <20150331235328.GC623@msticlxl57.ims.intel.com> <20150401052147.GG19273@tucnak.redhat.com> <20150401131405.GD623@msticlxl57.ims.intel.com> <20150401132025.GM19273@tucnak.redhat.com> <20150406124557.GA5541@msticlxl57.ims.intel.com> <20150407152645.GJ19273@tucnak.redhat.com> <20150408153142.128b97b9@octopus> <20150408145856.GA19410@msticlxl57.ims.intel.com> MIME-Version: 1.0 X-IsSubscribed: yes On Wed, 8 Apr 2015 17:58:56 +0300 Ilya Verbin wrote: > On Wed, Apr 08, 2015 at 15:31:42 +0100, Julian Brown wrote: > > This version is mostly the same as the last posted version but has a > > tweak in GOACC_parallel to account for the new splay tree > > arrangement for target functions: > > > > - tgt_fn = (void (*)) tgt_fn_key->tgt->tgt_start; > > + tgt_fn = (void (*)) tgt_fn_key->tgt_offset; > > > > Have there been any other changes I might have missed? > > No. > > > It passes libgomp testing on NVPTX. OK? > > Have you tested it with disabled offloading? > > I see several regressions: > FAIL: libgomp.oacc-c/../libgomp.oacc-c-c++-common/acc_on_device-1.c > -DACC_DEVICE_TYPE_host_nonshm=1 -DACC_MEM_SHARED=0 execution test > FAIL: libgomp.oacc-c/../libgomp.oacc-c-c++-common/if-1.c > -DACC_DEVICE_TYPE_host_nonshm=1 -DACC_MEM_SHARED=0 execution test I think there may be multiple issues here. The attached patch addresses one -- acc_device_type not distinguishing between "offloaded" and host code with the host_nonshm plugin. The other problem is that it appears that the ACC_DEVICE_TYPE environment variable is not getting set properly on the target for (any of) the OpenACC tests: this means a lot of the time the "wrong" plugin is being tested, and means that the above tests (and several others) still fail. That will apparently need some more engineering (on our part). (Not asking for review just yet, JFYI.) Julian ChangeLog libgomp/ * oacc-init.c (acc_on_device): Check whether we're in an offloaded region for host_nonshm plugin. * plugin/plugin-host.c (GOMP_OFFLOAD_openacc_parallel): Set nonshm_exec flag in thread-local data. (GOMP_OFFLOAD_openacc_create_thread_data): Allocate thread-local data for host_nonshm plugin. (+GOMP_OFFLOAD_openacc_destroy_thread_data): Free thread-local data for host_nonshm plugin. * plugin/plugin-host.h: New. Index: libgomp/oacc-init.c =================================================================== --- libgomp/oacc-init.c (revision 221922) +++ libgomp/oacc-init.c (working copy) @@ -29,6 +29,7 @@ #include "libgomp.h" #include "oacc-int.h" #include "openacc.h" +#include "plugin/plugin-host.h" #include #include #include @@ -548,7 +549,14 @@ ialias (acc_set_device_num) int acc_on_device (acc_device_t dev) { - if (acc_get_device_type () == acc_device_host_nonshm) + struct goacc_thread *thr = goacc_thread (); + + /* We only want to appear to be the "host_nonshm" plugin from "offloaded" + code -- i.e. within a parallel region. Test a flag set by the + openacc_parallel hook of the host_nonshm plugin to determine that. */ + if (acc_get_device_type () == acc_device_host_nonshm + && thr && thr->target_tls + && ((struct nonshm_thread *)thr->target_tls)->nonshm_exec) return dev == acc_device_host_nonshm || dev == acc_device_not_host; /* Just rely on the compiler builtin. */ Index: libgomp/plugin/plugin-host.c =================================================================== --- libgomp/plugin/plugin-host.c (revision 221922) +++ libgomp/plugin/plugin-host.c (working copy) @@ -44,6 +44,7 @@ #include #include #include +#include #ifdef HOST_NONSHM_PLUGIN #define STATIC @@ -55,6 +56,10 @@ #define SELF "host: " #endif +#ifdef HOST_NONSHM_PLUGIN +#include "plugin-host.h" +#endif + STATIC const char * GOMP_OFFLOAD_get_name (void) { @@ -174,7 +179,10 @@ GOMP_OFFLOAD_openacc_parallel (void (*fn void *targ_mem_desc __attribute__ ((unused))) { #ifdef HOST_NONSHM_PLUGIN + struct nonshm_thread *thd = GOMP_PLUGIN_acc_thread (); + thd->nonshm_exec = true; fn (devaddrs); + thd->nonshm_exec = false; #else fn (hostaddrs); #endif @@ -232,11 +240,20 @@ STATIC void * GOMP_OFFLOAD_openacc_create_thread_data (int ord __attribute__ ((unused))) { +#ifdef HOST_NONSHM_PLUGIN + struct nonshm_thread *thd + = GOMP_PLUGIN_malloc (sizeof (struct nonshm_thread)); + thd->nonshm_exec = false; + return thd; +#else return NULL; +#endif } STATIC void -GOMP_OFFLOAD_openacc_destroy_thread_data (void *tls_data - __attribute__ ((unused))) +GOMP_OFFLOAD_openacc_destroy_thread_data (void *tls_data) { +#ifdef HOST_NONSHM_PLUGIN + free (tls_data); +#endif } Index: libgomp/plugin/plugin-host.h =================================================================== --- libgomp/plugin/plugin-host.h (revision 0) +++ libgomp/plugin/plugin-host.h (revision 0) @@ -0,0 +1,37 @@ +/* OpenACC Runtime Library: acc_device_host, acc_device_host_nonshm. + + Copyright (C) 2015 Free Software Foundation, Inc. + + Contributed by Mentor Embedded. + + This file is part of the GNU Offloading and Multi Processing Library + (libgomp). + + Libgomp is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3, or (at your option) + any later version. + + Libgomp is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. + + Under Section 7 of GPL version 3, you are granted additional + permissions described in the GCC Runtime Library Exception, version + 3.1, as published by the Free Software Foundation. + + You should have received a copy of the GNU General Public License and + a copy of the GCC Runtime Library Exception along with this program; + see the files COPYING3 and COPYING.RUNTIME respectively. If not, see + . */ + +#ifndef PLUGIN_HOST_H +#define PLUGIN_HOST_H + +struct nonshm_thread +{ + bool nonshm_exec; +}; + +#endif