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 E83F338582B4 for ; Wed, 15 Jun 2022 08:46:41 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org E83F338582B4 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-638-mvPIGgIZMay9y0QineLFLQ-1; Wed, 15 Jun 2022 04:46:34 -0400 X-MC-Unique: mvPIGgIZMay9y0QineLFLQ-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 1BCB785A580; Wed, 15 Jun 2022 08:46:34 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.192.11]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D0ACF492CA5; Wed, 15 Jun 2022 08:46:33 +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 25F8kUSK1116574 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Wed, 15 Jun 2022 10:46:31 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 25F8kU9F1116573; Wed, 15 Jun 2022 10:46:30 +0200 Date: Wed, 15 Jun 2022 10:46:30 +0200 From: Jakub Jelinek To: Thomas Schwinge Cc: gcc-patches@gcc.gnu.org, Tobias Burnus , Marcel Vollweiler Subject: Re: [committed] openmp: Conforming device numbers and omp_{initial,invalid}_device Message-ID: Reply-To: Jakub Jelinek References: <87r13ri4e6.fsf@dem-tschwing-1.ger.mentorg.com> MIME-Version: 1.0 In-Reply-To: <87r13ri4e6.fsf@dem-tschwing-1.ger.mentorg.com> X-Scanned-By: MIMEDefang 2.85 on 10.11.54.9 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=-4.5 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 15 Jun 2022 08:46:43 -0000 On Tue, Jun 14, 2022 at 06:41:37PM +0200, Thomas Schwinge wrote: > Hi Jakub! > > On 2022-06-13T14:06:39+0200, Jakub Jelinek via Gcc-patches wrote: > > OpenMP 5.2 changed once more what device numbers are allowed. > > > libgomp/ > > > * testsuite/libgomp.c-c++-common/target-is-accessible-1.c (main): Add > > test with omp_initial_device. Use -5 instead of -1 for negative value > > test. > > * testsuite/libgomp.fortran/target-is-accessible-1.f90 (main): > > Likewise. Reorder stop numbers. > > In an offloading configuration, I'm seeing: > > PASS: libgomp.fortran/get-mapped-ptr-1.f90 -O (test for excess errors) > [-PASS:-]{+FAIL:+} libgomp.fortran/get-mapped-ptr-1.f90 -O execution test > > Does that one need similar treatment? I assume not just that but libgomp.c-c++-common/get-mapped-ptr-1.c too? It both needs the same treatment, and in the get-mapped-ptr-1.c case there is even UB, while the Fortran version was using c_loc (q) as the host pointer, in C/C++ it was using q which was value of uninitialized pointer. Tested on x86_64-linux, committed to trunk. 2022-06-15 Jakub Jelinek * testsuite/libgomp.c-c++-common/get-mapped-ptr-1.c (main): Initialize q to ddress of an automatic variable. Use -5 instead of -1 in omp_get_mapped_ptr call. Add test with omp_initial_device. * testsuite/libgomp.fortran/get-mapped-ptr-1.f90 (main): Use -5 instead of -1 in omp_get_mapped_ptr call. Add test with omp_initial_device. Renumber stop arguments afterwards. --- libgomp/testsuite/libgomp.c-c++-common/get-mapped-ptr-1.c.jj 2022-05-09 09:09:20.963464303 +0200 +++ libgomp/testsuite/libgomp.c-c++-common/get-mapped-ptr-1.c 2022-06-15 09:39:17.518746512 +0200 @@ -6,7 +6,10 @@ main () { int d = omp_get_default_device (); int id = omp_get_initial_device (); - void *p , *q; + int x; + void *p, *q; + + q = (void *) &x; if (d < 0 || d >= omp_get_num_devices ()) d = id; @@ -18,7 +21,7 @@ main () if (omp_target_associate_ptr (q, p, sizeof (int), 0, d) != 0) return 0; - if (omp_get_mapped_ptr (q, -1) != NULL) + if (omp_get_mapped_ptr (q, -5) != NULL) abort (); if (omp_get_mapped_ptr (q, omp_get_num_devices () + 1) != NULL) @@ -27,6 +30,9 @@ main () if (omp_get_mapped_ptr (q, id) != q) abort (); + if (omp_get_mapped_ptr (q, omp_initial_device) != q) + abort (); + if (omp_get_mapped_ptr (q, d) != p) abort (); --- libgomp/testsuite/libgomp.fortran/get-mapped-ptr-1.f90.jj 2022-05-09 09:09:20.963464303 +0200 +++ libgomp/testsuite/libgomp.fortran/get-mapped-ptr-1.f90 2022-06-15 09:43:11.632338293 +0200 @@ -19,7 +19,7 @@ program main if (omp_target_associate_ptr (c_loc (q), p, c_sizeof (q), & 0_c_size_t, d) == 0) then - if(c_associated (omp_get_mapped_ptr (c_loc (q), -1))) & + if(c_associated (omp_get_mapped_ptr (c_loc (q), -5))) & stop 1 if(c_associated (omp_get_mapped_ptr (c_loc (q), & @@ -29,14 +29,18 @@ program main if(.not. c_associated (omp_get_mapped_ptr (c_loc (q), id), c_loc (q))) & stop 3 - if(.not. c_associated (omp_get_mapped_ptr (c_loc (q), d), p)) & + if(.not. c_associated (omp_get_mapped_ptr (c_loc (q), omp_initial_device), & + c_loc (q))) & stop 4 - if (omp_target_disassociate_ptr (c_loc (q), d) /= 0) & + if(.not. c_associated (omp_get_mapped_ptr (c_loc (q), d), p)) & stop 5 - if(c_associated (omp_get_mapped_ptr (c_loc (q), d))) & + if (omp_target_disassociate_ptr (c_loc (q), d) /= 0) & stop 6 + + if(c_associated (omp_get_mapped_ptr (c_loc (q), d))) & + stop 7 end if call omp_target_free (p, d) Jakub