From patchwork Tue Jan 4 14:12:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Tobias Burnus X-Patchwork-Id: 49527 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 63179385801E for ; Tue, 4 Jan 2022 14:15:54 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from esa3.mentor.iphmx.com (esa3.mentor.iphmx.com [68.232.137.180]) by sourceware.org (Postfix) with ESMTPS id 202C73858410 for ; Tue, 4 Jan 2022 14:13:06 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 202C73858410 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=codesourcery.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=mentor.com IronPort-SDR: nS42pmvYszSro0UbJWOBjMTJCAg54G14qfkYKRb0OmrcWGSUt9WvnRxcuovG8LiebGqw80XqgB C4PNyLTehzZrIBAH7EFHd7zBSqBCa9+vmRmVdadJRvU4sWngb4RcVg4nRMzA9R4wWg+DiFw81J N/THxisXBEH6qaQ4YsrlLb5svm+zf0wB9uH99At7sSZLCq6K2meV4zRdvaCxHk6oDTSD18rzSP 6OD0h8H78+6NOmjqe7xMX2CDnb7kbx31rONM6oBLpRjyjP6b3i+vbie/cXOsfjUJa7RTUMOdEo NIFrldDznrkMGuHNWPFEQjWz X-IronPort-AV: E=Sophos;i="5.88,261,1635235200"; d="diff'?scan'208";a="70227186" Received: from orw-gwy-01-in.mentorg.com ([192.94.38.165]) by esa3.mentor.iphmx.com with ESMTP; 04 Jan 2022 06:13:05 -0800 IronPort-SDR: fNdT0RzAcV85vgHNpDzDUhewPI7yf+bJ9uwQvcM6NKnPmBKx47+YUYDnx+PyDaEmd59FPq7Tjr bGubm/iUwJxm8EtJ1REFcfZ4ROJRfUwPAxwHKqHqrd8pQODzWJsec76P/RazQRnMgAjMGVg4Ja 72j42JiHw+hCM+jHbAaWktrrsnmI/OP5dYINqdolKh1jR1Xv+RlTbfH8wOra1+b2xY3Nsyns3o LGpM0Pir7iziCmSykpoMiMrM9+JKslRQbr9jBLNrc8MGkBZ533wfaW11i76vCsV/kohLQ5x/QE rA0= Message-ID: <77fb4ef2-f2e8-5b79-aca4-085311d33a8b@codesourcery.com> Date: Tue, 4 Jan 2022 15:12:58 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.4.0 Subject: [committed] libgomp/testsuite: Improve omp_get_device_num() tests (was: Re: [PATCH, OpenMP, libgomp, committed] Fix GOMP_DEVICE_NUM_VAR stringification error) Content-Language: en-US To: Chung-Lin Tang , gcc-patches , Jakub Jelinek , Thomas Schwinge , Andrew Stubbs , "Vollweiler, Marcel (DI SW CAS EPS STS)" References: <268addd8-4c4f-6284-bf5c-df07e752811f@codesourcery.com> From: Tobias Burnus In-Reply-To: <268addd8-4c4f-6284-bf5c-df07e752811f@codesourcery.com> X-Originating-IP: [137.202.0.90] X-ClientProxiedBy: svr-ies-mbx-05.mgc.mentorg.com (139.181.222.5) To svr-ies-mbx-01.mgc.mentorg.com (139.181.222.1) X-Spam-Status: No, score=-11.5 required=5.0 tests=BAYES_00, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, KAM_MANYTO, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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: , Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" On 04.01.22 10:28, Chung-Lin Tang wrote: > In the patch that implemented omp_get_device_num(), there was an error > where > the stringification of GOMP_DEVICE_NUM_VAR, ... ... which caused that omp_get_device() == 0 (always) on nvptx/gcn. That's fine if there is only a single non-host device (as often the case), but not if there are multiples. This commit r12-6209 now makes the testcases iterate over all devices (including the initial/host device). Hence, with multiple non-host devices and this test, the error had been found before ... ;-) Tobias ----------------- Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201, 80634 München; Gesellschaft mit beschränkter Haftung; Geschäftsführer: Thomas Heurung, Frank Thürauf; Sitz der Gesellschaft: München; Registergericht München, HRB 106955 commit be661959a6b6d8f9c3c8608a746789e7b2ec3ca4 Author: Tobias Burnus Date: Tue Jan 4 14:58:06 2022 +0100 libgomp/testsuite: Improve omp_get_device_num() tests Related to r12-6208-gebc853deb7cc0487de9ef6e891a007ba853d1933 "libgomp: Fix GOMP_DEVICE_NUM_VAR stringification during offload image load" That commit fixed an issue with omp_get_device_num() on gcn/nvptx that resulted in having always the value 0. This commit modifies the tests to iterate over all devices such that on a multi-nonhost-device system it had detected that always-zero issue. libgomp/ChangeLog: * testsuite/libgomp.c-c++-common/target-45.c: Iterate over all devices. * testsuite/libgomp.fortran/target10.f90: Likewise. diff --git a/libgomp/testsuite/libgomp.c-c++-common/target-45.c b/libgomp/testsuite/libgomp.c-c++-common/target-45.c index 81acee81064..837503996d7 100644 --- a/libgomp/testsuite/libgomp.c-c++-common/target-45.c +++ b/libgomp/testsuite/libgomp.c-c++-common/target-45.c @@ -14,17 +14,23 @@ int main (void) int device_num; int initial_device; - #pragma omp target map(from: device_num, initial_device) - { - initial_device = omp_is_initial_device (); - device_num = omp_get_device_num (); - } - - if (initial_device && host_device_num != device_num) - abort (); - - if (!initial_device && host_device_num == device_num) - abort (); + for (int i = 0; i <= omp_get_num_devices (); i++) + { + #pragma omp target map(from: device_num, initial_device) device(i) + { + initial_device = omp_is_initial_device (); + device_num = omp_get_device_num (); + } + + if (i != device_num) + abort (); + + if (initial_device && host_device_num != device_num) + abort (); + + if (!initial_device && host_device_num == device_num) + abort (); + } return 0; } diff --git a/libgomp/testsuite/libgomp.fortran/target10.f90 b/libgomp/testsuite/libgomp.fortran/target10.f90 index f41a726de75..f6951fc9057 100644 --- a/libgomp/testsuite/libgomp.fortran/target10.f90 +++ b/libgomp/testsuite/libgomp.fortran/target10.f90 @@ -4,18 +4,20 @@ program main use omp_lib implicit none - integer :: device_num, host_device_num + integer :: device_num, host_device_num, i logical :: initial_device host_device_num = omp_get_device_num () if (host_device_num .ne. omp_get_initial_device ()) stop 1 - !$omp target map(from: device_num, initial_device) - initial_device = omp_is_initial_device () - device_num = omp_get_device_num () - !$omp end target - - if (initial_device .and. (host_device_num .ne. device_num)) stop 2 - if ((.not. initial_device) .and. (host_device_num .eq. device_num)) stop 3 + do i = 0, omp_get_num_devices () + !$omp target map(from: device_num, initial_device) device(i) + initial_device = omp_is_initial_device () + device_num = omp_get_device_num () + !$omp end target + if (i /= device_num) stop 2 + if (initial_device .and. (host_device_num .ne. device_num)) stop 3 + if ((.not. initial_device) .and. (host_device_num .eq. device_num)) stop 4 + end do end program main