From patchwork Sat Nov 10 17:11:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julian Brown X-Patchwork-Id: 995936 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-489621-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=codesourcery.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="ybpKEzH2"; dkim-atps=neutral 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 42sk8M6bhCz9s9G for ; Sun, 11 Nov 2018 04:11: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:date:message-id:mime-version:content-type; q=dns; s=default; b=NAqGJl28a56KhoPWRIR+9kuUabdNRSx9TW9TrkbDT81RtCPYy8 eMRWcgjzh/XVfWtN6qB6PSEyCYahmm1YPSZU9rYYZHXFC19rZDYQXkyPup4HXo/q KfN39LIqyvw5SOO8BAIJ6rAa935oaeM0hhABvejmeyntmgCsUjRVfaTvw= 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:date:message-id:mime-version:content-type; s= default; bh=UJMDj+qP0dgbYHYgTuuIm3fUQUg=; b=ybpKEzH2doL0VdWU0mi7 6b1PGVrRpWJs/yQBqfPiAsE98xVwQ2yNQXIs+PZVSMzi2RQKd6baaBwxLQx+FAeG spPINOjnSShADda7Y7V6ds+ubs35Dvr/Lybaphsvbkdty0lPZQo9gkp8egdiFuqa EGbj3o8dEH0H7rHYPvfvFR8= Received: (qmail 100053 invoked by alias); 10 Nov 2018 17:11:38 -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 100030 invoked by uid 89); 10 Nov 2018 17:11:37 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-11.9 required=5.0 tests=BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=Attach, Factor, emails 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; Sat, 10 Nov 2018 17:11:36 +0000 Received: from nat-ies.mentorg.com ([192.94.31.2] helo=SVR-IES-MBX-04.mgc.mentorg.com) by relay1.mentorg.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-SHA384:256) id 1gLWnF-0005ba-2h from Julian_Brown@mentor.com ; Sat, 10 Nov 2018 09:11:33 -0800 Received: from localhost.localdomain (147.34.91.1) by SVR-IES-MBX-04.mgc.mentorg.com (139.181.222.4) with Microsoft SMTP Server (TLS) id 15.0.1320.4; Sat, 10 Nov 2018 17:11:28 +0000 From: Julian Brown To: CC: , , , Subject: [PATCH 0/3] OpenACC 2.6 manual deep copy support (attach/detach) Date: Sat, 10 Nov 2018 09:11:17 -0800 Message-ID: MIME-Version: 1.0 X-IsSubscribed: yes Hi, This patch series adds support for OpenACC 2.6's "manual deep copy" feature. This consists of three main parts: * Variable lists in data clauses can specify members of structs (in C/C++) or derived types (in Fortran). In C/C++ we allow either "." or "->" to be used to select members of structs or pointers-to-structs respectively. Fortran uses "%", as in the base language. * Struct and derived type members that are pointers trigger new "attach" and "detach" operations. The typical supported case is for a struct to be copied verbatim to the target initially. Subsequently, attach operations can be used to rewrite pointers to host memory contained in the struct to point to device memory instead. In this way, structs (and derived types) can be used fairly naturally in offloaded code. The detach operation restores pointers to point to host memory, i.e. before the whole struct is copied verbatim back to the host again. * There are new explicit attach/detach clauses in all three supported languages, as well as new behaviour for existing clauses (copy/copyin/copyout, etc.) implementing the semantics described above. For more details, see the OpenACC 2.6 spec, or the Deep Copy Attach and Detach Technical Report (TR-16-1) on the OpenACC site. The patches are split into three parts, the first two of which are tangentially-related cleanups, and the third of which contains the bulk of the changes. I'll write more about those in their respective emails. This patch series relies on the libgomp async implementation rework done by Chung-Lin, posted previously: https://gcc.gnu.org/ml/gcc-patches/2018-09/msg01424.html Julian Brown (3): Host-to-device transfer coalescing & magic offset value self-documentation Factor out duplicate code in gimplify_scan_omp_clauses OpenACC 2.6 manual deep copy support (attach/detach) gcc/c-family/c-pragma.h | 2 + gcc/c/c-parser.c | 34 +- gcc/c/c-typeck.c | 59 +++- gcc/cp/parser.c | 38 +- gcc/cp/semantics.c | 75 +++- gcc/fortran/gfortran.h | 2 + gcc/fortran/openmp.c | 145 +++++--- gcc/fortran/trans-openmp.c | 78 ++++- gcc/gimplify.c | 390 +++++++++++++-------- gcc/omp-low.c | 3 + gcc/testsuite/c-c++-common/goacc/mdc-1.c | 54 +++ gcc/testsuite/c-c++-common/goacc/mdc-2.c | 62 ++++ gcc/testsuite/g++.dg/goacc/mdc.C | 68 ++++ gcc/testsuite/gfortran.dg/goacc/data-clauses.f95 | 38 +- gcc/testsuite/gfortran.dg/goacc/derived-types.f90 | 77 ++++ .../gfortran.dg/goacc/enter-exit-data.f95 | 24 +- gcc/tree-pretty-print.c | 9 + include/gomp-constants.h | 8 + libgomp/libgomp.h | 23 +- libgomp/libgomp.map | 10 + libgomp/oacc-async.c | 4 +- libgomp/oacc-int.h | 2 +- libgomp/oacc-mem.c | 86 ++++- libgomp/oacc-parallel.c | 220 +++++++++--- libgomp/openacc.h | 6 + libgomp/target.c | 292 ++++++++++++--- .../libgomp.oacc-c-c++-common/deep-copy-1.c | 24 ++ .../libgomp.oacc-c-c++-common/deep-copy-2.c | 29 ++ .../libgomp.oacc-c-c++-common/deep-copy-3.c | 34 ++ .../libgomp.oacc-c-c++-common/deep-copy-4.c | 87 +++++ .../libgomp.oacc-c-c++-common/deep-copy-5.c | 81 +++++ .../testsuite/libgomp.oacc-fortran/deep-copy-1.f90 | 35 ++ .../testsuite/libgomp.oacc-fortran/deep-copy-2.f90 | 33 ++ .../testsuite/libgomp.oacc-fortran/deep-copy-3.f90 | 34 ++ .../testsuite/libgomp.oacc-fortran/deep-copy-4.f90 | 49 +++ .../testsuite/libgomp.oacc-fortran/deep-copy-5.f90 | 57 +++ .../testsuite/libgomp.oacc-fortran/deep-copy-6.f90 | 61 ++++ .../testsuite/libgomp.oacc-fortran/deep-copy-7.f90 | 89 +++++ .../testsuite/libgomp.oacc-fortran/deep-copy-8.f90 | 41 +++ .../libgomp.oacc-fortran/derived-type-1.f90 | 28 ++ .../testsuite/libgomp.oacc-fortran/update-2.f90 | 284 +++++++++++++++ 41 files changed, 2406 insertions(+), 369 deletions(-) create mode 100644 gcc/testsuite/c-c++-common/goacc/mdc-1.c create mode 100644 gcc/testsuite/c-c++-common/goacc/mdc-2.c create mode 100644 gcc/testsuite/g++.dg/goacc/mdc.C create mode 100644 gcc/testsuite/gfortran.dg/goacc/derived-types.f90 create mode 100644 libgomp/testsuite/libgomp.oacc-c-c++-common/deep-copy-1.c create mode 100644 libgomp/testsuite/libgomp.oacc-c-c++-common/deep-copy-2.c create mode 100644 libgomp/testsuite/libgomp.oacc-c-c++-common/deep-copy-3.c create mode 100644 libgomp/testsuite/libgomp.oacc-c-c++-common/deep-copy-4.c create mode 100644 libgomp/testsuite/libgomp.oacc-c-c++-common/deep-copy-5.c create mode 100644 libgomp/testsuite/libgomp.oacc-fortran/deep-copy-1.f90 create mode 100644 libgomp/testsuite/libgomp.oacc-fortran/deep-copy-2.f90 create mode 100644 libgomp/testsuite/libgomp.oacc-fortran/deep-copy-3.f90 create mode 100644 libgomp/testsuite/libgomp.oacc-fortran/deep-copy-4.f90 create mode 100644 libgomp/testsuite/libgomp.oacc-fortran/deep-copy-5.f90 create mode 100644 libgomp/testsuite/libgomp.oacc-fortran/deep-copy-6.f90 create mode 100644 libgomp/testsuite/libgomp.oacc-fortran/deep-copy-7.f90 create mode 100644 libgomp/testsuite/libgomp.oacc-fortran/deep-copy-8.f90 create mode 100644 libgomp/testsuite/libgomp.oacc-fortran/derived-type-1.f90 create mode 100644 libgomp/testsuite/libgomp.oacc-fortran/update-2.f90