From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mout.gmx.net (mout.gmx.net [212.227.17.22]) by sourceware.org (Postfix) with ESMTPS id B7EDD3857C6F for ; Wed, 31 Mar 2021 19:50:11 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org B7EDD3857C6F X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from [93.207.87.97] ([93.207.87.97]) by web-mail.gmx.net (3c-app-gmx-bap42.server.lan [172.19.172.112]) (via HTTP); Wed, 31 Mar 2021 21:50:10 +0200 MIME-Version: 1.0 Message-ID: From: Harald Anlauf To: fortran Subject: OpenMP target (offloading) question Content-Type: multipart/mixed; boundary=abmob-819e5de5-c161-4fd4-8c7b-762a93d8661e Date: Wed, 31 Mar 2021 21:50:10 +0200 Importance: normal Sensitivity: Normal X-Priority: 3 X-Provags-ID: V03:K1:2HZJVqI10DlYLzb/IvqIFQrtZCbChxLWWipf4xF9rBnjDk8Gi1/c8yNMUEcl2AqbPYtuO Ezntl/B3hXk8ZWo05xn9jfvZKnEFWoxrdWMkVIDYKJi89LJGrn/7gfUBwMUJ1whOZyBY57bF1d4g BmvWDw8WZmMEJWYak8sUYyE+n3ENguz7McdpVMl8rSm+dDrdV7DhtimlKlmtKy97QDSJuFPurW/W RS/AwQ4mcPPYjNSC3qy6Svdn0RAFNo4V5tlT6HMpmL885EKZ1pESY4xp6xTPSb8vLTcCqZJlp53W Cg= X-UI-Out-Filterresults: notjunk:1;V03:K0:uIfMtnk+MF8=:ULE7Y+hp89IaZmgs3qxpPo VGt/tYAU7kaWp3ol5NewUG55ORkVb3AI4MVknr1fqOIV1sI+FRaHl4GNQNH692dxpaU8ByJhu o5e4leC6AD4ofNiYOU1XvE1EKOnSXiNBGA3Ci7eemCd9tQSUtzjTCVpqN3bfKDK8ZX03ZVJUl 3oKPdjcdZrgjM0CEtW+G7AdvmBNxPJlvRsslaDlQLj5PNdz2umDX0xdhbM9l8lTMoV/2r/D5O jJa1TphBfGD3Q05TAD6GQ4feU1FKts93QKFBO27jLpvepOcjcGAb49akDZUDBtFxAUQYjJfgY W6YZhAYSUyOKUFMDqCVe2V3PytIhEGojnxOFwuIJbVduf94nclWq4F7GV/jGIzbRHHKLGf6Gx ypeVY4mpMKnGQSciLF3jrgBnjfcBIq06zGV8LErfNyK5MJQ6DrSE4GAW22jk6LBmKIoxXz4fH 8pGgxw4WDOlMXzbtcSpdWA+j9DJ+MyEXMKVBZIFEWnrFT++6+9XHpnlC2jbbq3tUE1v33+ws+ UqRC6Ll05pohCTljiZsdKlZjsqE1I4c9L/J6xcfxWzgh1d5V+L4rsrg8OqCAc1z556V/u8SeH 9R5oN8LMpEvscPivHGART1DUCJ3dU3QR50OMYsE5My2gKFLPL/lIpoWqLHOW1qCwtCqPZRMxp bt3vIawp28PBMtSC2DT/12pEQodtYARMjr+TcxOZsvYhXdTmCRtb4nXOw36LUZI9n61L8+NOP hKMErxAydb81HlxZ6Tv9uwHEN6HPZBzLX6gcM1qp7cCMyxlZX8BqIazQox1Oy+ensxz/9AWK+ RT2KSivK6STj699BP9fIRwSlXyAOd/kmBiWO2WxjbdENb342RPpcqFScfAZrgDPOe47svHo5z CI2yJnnPK4fg+sHjyqxqE3dEOUPo6YKONy2RevgMQPzNjYKuvdxNmfJWWATgQj X-Spam-Status: No, score=-4.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham 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: Wed, 31 Mar 2021 19:50:13 -0000 --abmob-819e5de5-c161-4fd4-8c7b-762a93d8661e Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 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-1= 0 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.f9= 0": 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 necessar= y, but the result seems to tell me that either I am wrong (and gfortran is ri= ght), or nvfortran is wrong. With OpenACC this seems to be different; at least a simple example I tried 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 th= e OpenMP standard), or should I open a PR? Thanks Harald --abmob-819e5de5-c161-4fd4-8c7b-762a93d8661e Content-Type: text/x-fortran Content-Disposition: attachment; filename=offload-test.f90 program p5 implicit none integer :: i, n = 1000 real :: s real, allocatable :: a(:) allocate (a(n)) do i = 1, n a(i) = 2*i end do print *, a(1),a(n) call s1 () print *, "s1:", s call s2 () print *, "s2:", s contains subroutine s1 () integer :: i s = 0. !$omp target data map(a,s) !$omp target teams reduction(+:s) map(s) do i = 1, n s = s + a(i) end do !$omp end target teams !$omp end target data end subroutine s1 !---------------- subroutine s2 () integer :: i s = 0. !$omp target data map(a,s) !$omp target teams reduction(+:s) do i = 1, n s = s + a(i) end do !$omp end target teams !$omp end target data end subroutine s2 end program --abmob-819e5de5-c161-4fd4-8c7b-762a93d8661e--