From patchwork Fri Jul 12 11:35:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kwok Cheung Yeung X-Patchwork-Id: 1131323 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-504994-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="DaB2nhpl"; 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 45lW876k4bz9sBF for ; Fri, 12 Jul 2019 21:35:50 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :subject:from:to:cc:references:message-id:date:mime-version :in-reply-to:content-type:content-transfer-encoding; q=dns; s= default; b=TzeKtdrnqTnc4g0ezwy5BeS/YhqGAo6foqdYrotEHDiw6n3XcPeXV oXTfk2pypUbk+oEZuBpbS8fS3i7jkMJH9Su5skEoQTIvaHwN7PGc7UPRZXis1wVQ HvpTS9Kd0sIXD0iQ7Pi34IIvpkhPJYJGZJhvsNQFbqPPhP/E4afgg0= 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 :subject:from:to:cc:references:message-id:date:mime-version :in-reply-to:content-type:content-transfer-encoding; s=default; bh=02k1MEHe4+Nh3fbCrDX26YwSZus=; b=DaB2nhplVe0BoWIHUnrhkrJaKDn3 qLVvYzyvAeqkG36uzNx0oRG0A270D3Ifjea+SDngG1yZfIeQmWdL1Ul+P+PKh2E7 r+gR9Kac+ZpmfRYkj7spffsJSTNqXo6STAko1ypCYGt3w/tT3Wyc8TP8+094kkyr Zh6FMSLktjlPfnk= Received: (qmail 117995 invoked by alias); 12 Jul 2019 11:35:39 -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 117970 invoked by uid 89); 12 Jul 2019 11:35:38 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-15.4 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy=H*i:sk:6aaaeec, H*f:sk:6aaaeec 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; Fri, 12 Jul 2019 11:35:28 +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 1hltpn-0005Us-99 from Kwok_Yeung@mentor.com ; Fri, 12 Jul 2019 04:35:27 -0700 Received: from [172.30.65.231] (137.202.0.90) by SVR-IES-MBX-04.mgc.mentorg.com (139.181.222.4) with Microsoft SMTP Server (TLS) id 15.0.1320.4; Fri, 12 Jul 2019 12:35:23 +0100 Subject: [PATCH 1/5, OpenACC] Allow NULL as an argument to OpenACC 2.6 directives From: Kwok Cheung Yeung To: , , CC: References: <6aaaeec8-9c6d-9293-5b6c-622d9fcf2664@codesourcery.com> Message-ID: Date: Fri, 12 Jul 2019 12:35:05 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: <6aaaeec8-9c6d-9293-5b6c-622d9fcf2664@codesourcery.com> Fortran pass-by-reference optional arguments behave much like normal Fortran arguments when lowered to GENERIC/GIMPLE, except they can be null (representing a non-present argument). Some parts of libgomp (those dealing with updating mappings) currently do not expect to take a null address and fail. These need to be changed to deal with the null appropriately, by turning the operation into a no-op (as you never need to update a non-present argument). libgomp/ * oacc-mem.c (update_dev_host): Return early if the host address is NULL. (gomp_acc_insert_pointer): Likewise. * testsuite/libgomp.oacc-c-c++-common/lib-43.c: Remove. * testsuite/libgomp.oacc-c-c++-common/lib-47.c: Likewise. --- libgomp/oacc-mem.c | 9 ++++ .../testsuite/libgomp.oacc-c-c++-common/lib-43.c | 51 ---------------------- .../testsuite/libgomp.oacc-c-c++-common/lib-47.c | 49 --------------------- 3 files changed, 9 insertions(+), 100 deletions(-) delete mode 100644 libgomp/testsuite/libgomp.oacc-c-c++-common/lib-43.c delete mode 100644 libgomp/testsuite/libgomp.oacc-c-c++-common/lib-47.c diff --git a/libgomp/oacc-mem.c b/libgomp/oacc-mem.c index 2f27100..8cc5120 100644 --- a/libgomp/oacc-mem.c +++ b/libgomp/oacc-mem.c @@ -831,6 +831,12 @@ update_dev_host (int is_dev, void *h, size_t s, int async) if (acc_dev->capabilities & GOMP_OFFLOAD_CAP_SHARED_MEM) return; + /* Fortran optional arguments that are non-present result in a + null host address here. This can safely be ignored as it is + not possible to 'update' a non-present optional argument. */ + if (h == NULL) + return; + acc_prof_info prof_info; acc_api_info api_info; bool profiling_p = GOACC_PROFILING_SETUP_P (thr, &prof_info, &api_info); @@ -901,6 +907,9 @@ gomp_acc_insert_pointer (size_t mapnum, void **hostaddrs, size_t *sizes, struct goacc_thread *thr = goacc_thread (); struct gomp_device_descr *acc_dev = thr->dev; + if (*hostaddrs == NULL) + return; + if (acc_is_present (*hostaddrs, *sizes)) { splay_tree_key n; diff --git a/libgomp/testsuite/libgomp.oacc-c-c++-common/lib-43.c b/libgomp/testsuite/libgomp.oacc-c-c++-common/lib-43.c deleted file mode 100644 index 5db2912..0000000 --- a/libgomp/testsuite/libgomp.oacc-c-c++-common/lib-43.c +++ /dev/null @@ -1,51 +0,0 @@ -/* Exercise acc_update_device with a NULL data address on nvidia targets. */ - -/* { dg-do run { target openacc_nvidia_accel_selected } } */ - -#include -#include -#include - -int -main (int argc, char **argv) -{ - const int N = 256; - int i; - unsigned char *h; - void *d; - - h = (unsigned char *) malloc (N); - - for (i = 0; i < N; i++) - { - h[i] = i; - } - - d = acc_copyin (h, N); - if (!d) - abort (); - - for (i = 0; i < N; i++) - { - h[i] = 0xab; - } - - fprintf (stderr, "CheCKpOInT\n"); - acc_update_device (0, N); - - acc_copyout (h, N); - - for (i = 0; i < N; i++) - { - if (h[i] != 0xab) - abort (); - } - - free (h); - - return 0; -} - -/* { dg-output "CheCKpOInT(\n|\r\n|\r).*" } */ -/* { dg-output "\\\[\[^\n\r]*,256\\\] is not mapped" } */ -/* { dg-shouldfail "" } */ diff --git a/libgomp/testsuite/libgomp.oacc-c-c++-common/lib-47.c b/libgomp/testsuite/libgomp.oacc-c-c++-common/lib-47.c deleted file mode 100644 index c214042..0000000 --- a/libgomp/testsuite/libgomp.oacc-c-c++-common/lib-47.c +++ /dev/null @@ -1,49 +0,0 @@ -/* Exercise acc_update_self with a NULL data mapping on nvidia targets. */ - -/* { dg-do run { target openacc_nvidia_accel_selected } } */ - -#include -#include -#include -#include - -int -main (int argc, char **argv) -{ - const int N = 256; - int i; - unsigned char *h; - void *d; - - h = (unsigned char *) malloc (N); - - for (i = 0; i < N; i++) - { - h[i] = i; - } - - d = acc_copyin (h, N); - if (!d) - abort (); - - memset (&h[0], 0, N); - - fprintf (stderr, "CheCKpOInT\n"); - acc_update_self (0, N); - - for (i = 0; i < N; i++) - { - if (h[i] != i) - abort (); - } - - acc_delete (h, N); - - free (h); - - return 0; -} - -/* { dg-output "CheCKpOInT(\n|\r\n|\r).*" } */ -/* { dg-output "\\\[\[^\n\r]*,256\\\] is not mapped" } */ -/* { dg-shouldfail "" } */