From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 24D1E3858D37 for ; Fri, 27 Jan 2023 09:25:35 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 24D1E3858D37 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1674811534; h=from:from:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references; bh=15YG4YhlascN09VJiFwGZtdXG9x0DcwEik04cosMuds=; b=ZbXJQkQSudRU/0EuxXuAzk5WzP2RiQcVQB5krxTLWQjDwdJxKB8U7VFSL5GywueCPAyiiT MaSM0Ala7hEoTKcSwd8mgevRBbBHA4jj5hSQhPMHR94ZAk2rhDvytTd5ZR4zqYrzHiRyx/ bEkv9FQzMddoH1LEmfYSdWLhi5ocfVc= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-140-VINISWJ6P5a6Mfy9Z9gXQQ-1; Fri, 27 Jan 2023 04:25:31 -0500 X-MC-Unique: VINISWJ6P5a6Mfy9Z9gXQQ-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 3CBCE3C22748; Fri, 27 Jan 2023 09:25:31 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.192.223]) by smtp.corp.redhat.com (Postfix) with ESMTPS id EAA12492B01; Fri, 27 Jan 2023 09:25:30 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.17.1/8.17.1) with ESMTPS id 30R9PSHW681955 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Fri, 27 Jan 2023 10:25:28 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 30R9PRnL681952; Fri, 27 Jan 2023 10:25:27 +0100 Date: Fri, 27 Jan 2023 10:25:26 +0100 From: Jakub Jelinek To: Tobias Burnus Cc: gcc-patches , fortran Subject: Re: [Patch] OpenMP/Fortran: Fix has_device_addr clause splitting [PR108558] Message-ID: Reply-To: Jakub Jelinek References: MIME-Version: 1.0 In-Reply-To: X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-9.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Fri, Jan 27, 2023 at 10:19:42AM +0100, Tobias Burnus wrote: > Rather obvious fix. Hence, I intent to commit it later as obvious, > unless there are any comments. Yeah, this is obviously correct. Have you checked the function if we don't miss other clauses in there (e.g. compared to the C implementation)? > OpenMP/Fortran: Fix has_device_addr clause splitting [PR108558] > > gcc/fortran/ChangeLog: > > PR fortran/108558 > * trans-openmp.cc (gfc_split_omp_clauses): Handle has_device_addr. > > libgomp/ChangeLog: > > PR fortran/108558 > * testsuite/libgomp.fortran/has_device_addr.f90: New test. > > gcc/fortran/trans-openmp.cc | 2 + > .../testsuite/libgomp.fortran/has_device_addr.f90 | 59 ++++++++++++++++++++++ > 2 files changed, 61 insertions(+) > > diff --git a/gcc/fortran/trans-openmp.cc b/gcc/fortran/trans-openmp.cc > index 87213de0918..5283d0ce5f3 100644 > --- a/gcc/fortran/trans-openmp.cc > +++ b/gcc/fortran/trans-openmp.cc > @@ -6205,6 +6205,8 @@ gfc_split_omp_clauses (gfc_code *code, > = code->ext.omp_clauses->lists[OMP_LIST_MAP]; > clausesa[GFC_OMP_SPLIT_TARGET].lists[OMP_LIST_IS_DEVICE_PTR] > = code->ext.omp_clauses->lists[OMP_LIST_IS_DEVICE_PTR]; > + clausesa[GFC_OMP_SPLIT_TARGET].lists[OMP_LIST_HAS_DEVICE_ADDR] > + = code->ext.omp_clauses->lists[OMP_LIST_HAS_DEVICE_ADDR]; > clausesa[GFC_OMP_SPLIT_TARGET].device > = code->ext.omp_clauses->device; > clausesa[GFC_OMP_SPLIT_TARGET].thread_limit > diff --git a/libgomp/testsuite/libgomp.fortran/has_device_addr.f90 b/libgomp/testsuite/libgomp.fortran/has_device_addr.f90 > new file mode 100644 > index 00000000000..95cc7788f2d > --- /dev/null > +++ b/libgomp/testsuite/libgomp.fortran/has_device_addr.f90 > @@ -0,0 +1,59 @@ > +! { dg-additional-options "-fdump-tree-original" } > + > +! > +! PR fortran/108558 > +! > + > +! { dg-final { scan-tree-dump-times "#pragma omp target has_device_addr\\(x\\) has_device_addr\\(y\\)" 2 "original" } } > +! { dg-final { scan-tree-dump-times "#pragma omp target data map\\(tofrom:x\\) map\\(tofrom:y\\)" 2 "original" } } > +! { dg-final { scan-tree-dump-times "#pragma omp target data use_device_addr\\(x\\) use_device_addr\\(y\\)" 1 "original" } } > +! { dg-final { scan-tree-dump-times "#pragma omp target update from\\(y\\)" 1 "original" } } > +! { dg-final { scan-tree-dump-times "#pragma omp target data map\\(tofrom:x\\) map\\(tofrom:y\\) use_device_addr\\(x\\) use_device_addr\\(y\\)" 1 "original" } } > +! { dg-final { scan-tree-dump-times "#pragma omp teams" 2 "original" } } > +! { dg-final { scan-tree-dump-times "#pragma omp distribute" 2 "original" } } > +! { dg-final { scan-tree-dump-times "#pragma omp parallel" 2 "original" } } > +! { dg-final { scan-tree-dump-times "#pragma omp for nowait" 2 "original" } } > + > +module m > +contains > +subroutine vectorAdd(x, y, N) > + implicit none > + integer :: N > + integer(4) :: x(N), y(N) > + integer :: i > + > + !$omp target teams distribute parallel do has_device_addr(x, y) > + do i = 1, N > + y(i) = x(i) + y(i) > + end do > +end subroutine vectorAdd > +end module m > + > +program main > + use m > + implicit none > + integer, parameter :: N = 9876 > + integer(4) :: x(N), y(N) > + integer :: i > + > + x(:) = 1 > + y(:) = 2 > + > + !$omp target data map(x, y) > + !$omp target data use_device_addr(x, y) > + call vectorAdd(x, y, N) > + !$omp end target data > + !$omp target update from(y) > + if (any (y /= 3)) error stop > + !$omp end target data > + > + x = 1 > + y = 2 > + !$omp target data map(x, y) use_device_addr(x, y) > + !$omp target teams distribute parallel do has_device_addr(x, y) > + do i = 1, N > + y(i) = x(i) + y(i) > + end do > + !$omp end target data > + if (any (y /= 3)) error stop > +end program Jakub