From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from esa4.mentor.iphmx.com (esa4.mentor.iphmx.com [68.232.137.252]) by sourceware.org (Postfix) with ESMTPS id D6B6F3858034 for ; Tue, 6 Apr 2021 08:41:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org D6B6F3858034 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=codesourcery.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=Tobias_Burnus@mentor.com IronPort-SDR: 784gCp4Ds/DsFTbhvc97Uv1bravaz9duv7CtSpaN+eDBUVFl/kjJwSHfgBkt3gA08ezmYUMLSL up9X6/PwJY1AQOKUTsPuslsgn15vRjwsF1cH/XX4XTBwHiDRXJ3zpl7pmloQH+H2QPjGdsQ1h8 QqFoaU/ffNBWCZ30YOVvMQT3eWs+3NZ2YNLoK0jn6UxCMLCz9fV4o1JLlJ/4rw58BkcGDaPItO FpE15K3BMDOOBdJ26xbIGAxaRqv4YhMmg+u7WE6A6wIjEHGdDzVKa0mlYTZFZXTvzIrdw8rF9g 2eM= X-IronPort-AV: E=Sophos;i="5.81,308,1610438400"; d="scan'208";a="59964334" Received: from orw-gwy-01-in.mentorg.com ([192.94.38.165]) by esa4.mentor.iphmx.com with ESMTP; 06 Apr 2021 00:41:28 -0800 IronPort-SDR: IWmxeKDH1ZWDtO98LUyE9Xuk7a/aqdA8F8F2/B3WUqegW5SGg6aYJOt0jcuiXCtW5e6GpOoRaG FuhRoVoL1/TxNQyngUgfGPkfzQaGnR+D+b8vH9t0fs74Fnr5eYLXCYyI2xdG9Jh3mFlU11qyhv 6hUdrJv2eiKvjVkwagwEJ4qFNpuMvQv+e62eBJp7DHEC28diKDQDcdwfbWLnSkuh/ijASsTNEd G3ASgz+NVcYUANIDhjWy2VQOyTEAnhauzX6/j1Q2xn49DBtYeC1pHAdLdzpELNlv+lmhx/rAWL +84= Subject: Re: OpenMP target (offloading) question To: Harald Anlauf , fortran References: From: Tobias Burnus Message-ID: Date: Tue, 6 Apr 2021 10:41:22 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.9.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: quoted-printable Content-Language: en-US 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=-6.0 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, KAM_SHORT, NICE_REPLY_A, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=no autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: fortran@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Fortran mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 06 Apr 2021 08:41:31 -0000 Hi Harald, interesting code; in any case for !$omp target s =3D 5 's' is a scalar which is mapped by default as 'firstprivate', i.e. it is not copied back. However, OpenMP 5.1 states: "If a list item appears in a reduction, lastprivate or linear clause on a combined target construct then it is treated as if it also appears in a map clause with a map-type of tofrom." (2.21.7) Your code uses: omp target teams reduction(+:s) =E2=86=92 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D99928 Tobias On 31.03.21 21:50, Harald Anlauf via Fortran wrote: > Dear experts, > > sorry if this is a stupid question, but I was playing with offloading for > the nvptx-none target and found different behavior between e.g. gfortran-= 10 > on OpenSuse and the Nvidia compiler (nvfortran) for the attached code. > > With "nvfortran -mp=3Dmulticore offload-test.f90" the code prints: > > 2.000000 2000.000 > s1: 1001000. > s2: 1001000. > > With "/usr/bin/gfortran-10 -fopenmp -foffload=3Dnvptx-none offload-test.f= 90": > > 2.00000000 2000.00000 > s1: 1001000.00 > s2: 0.00000000 > > The core difference between the evaluations s1 and s2 is: > > s1: > > !$omp target data map(a,s) > !$omp target teams reduction(+:s) map(s) > do i =3D 1, n > s =3D s + a(i) > end do > !$omp end target teams > !$omp end target data > > s2: > > !$omp target data map(a,s) > !$omp target teams reduction(+:s) > do i =3D 1, n > s =3D s + a(i) > end do > !$omp end target teams > !$omp end target data > > I was assuming that the map clause in the reduction should not be necessa= ry, > but the result seems to tell me that either I am wrong (and gfortran is r= ight), > or nvfortran is wrong. > > With OpenACC this seems to be different; at least a simple example I trie= d > with the reduction within an !$acc data ... !$acc end data did not show > unexpected behavior. > > Can anybody tell me that I am wrong (and point me to the right place in t= he > OpenMP standard), or should I open a PR? > > Thanks > Harald ----------------- Mentor Graphics (Deutschland) GmbH, Arnulfstrasse 201, 80634 M=C3=BCnchen R= egistergericht M=C3=BCnchen HRB 106955, Gesch=C3=A4ftsf=C3=BChrer: Thomas H= eurung, Frank Th=C3=BCrauf