The test case does the following: igot = 1
!$acc parallel loop copy (igot, itmp) do i = 1, N !$acc atomic capture iarr(i) = igot igot = max (igot, i) !$acc end atomic end do !$acc end parallel loop And then checks that "all(iarr < N)". That works fine as long as no other code accesses "igot" after the i=N thread has set it. Otherwise, all later accesses to igot will be N – and thus some iarr(i) will be N, causing FAILs. Or in other words: The current code either works if i=N is run last (e.g. serial code) or when all concurrent accesses access "igot" early enough such that none (or at least not i=N) has modified it. While serial ("host") and Nvidia work (PASS), AMDGCN runs did fail before this patch. The OG9 commit by Julian already fixed this but it was never put on the GCC trunk = 10.0, cf. 868d3ad10f2dfd532a494bfe1513200eb361a6de on devel/omp/gcc-9. While Julian's patch modified much more (also a C test case), I have committed a minimal version which only fixes the issue mentioned above for MIN and for MAX. Committed as r10-7252-g26cbcfe5fce57b090b0f2336aad27d84b725f760 Cheers, Tobias ----------------- Mentor Graphics (Deutschland) GmbH, Arnulfstraße 201, 80634 München / Germany Registergericht München HRB 106955, Geschäftsführer: Thomas Heurung, Alexander Walter
commit 26cbcfe5fce57b090b0f2336aad27d84b725f760 Author: Tobias Burnus <tob...@codesourcery.com> Date: Wed Mar 18 16:28:08 2020 +0100 Fix libgomp.oacc-fortran/atomic_capture-1.f90 2020-03-18 Julian Brown <jul...@codesourcery.com> Tobias Burnus <tob...@codesourcery.com> * testsuite/libgomp.oacc-fortran/atomic_capture-1.f90: Really make it work concurrently. diff --git a/libgomp/ChangeLog b/libgomp/ChangeLog index 3dbe94bc982..9a1065fef4e 100644 --- a/libgomp/ChangeLog +++ b/libgomp/ChangeLog @@ -1,3 +1,9 @@ +2020-03-18 Julian Brown <jul...@codesourcery.com> + Tobias Burnus <tob...@codesourcery.com> + + * testsuite/libgomp.oacc-fortran/atomic_capture-1.f90: Really make + it work concurrently. + 2020-03-18 Tobias Burnus <tob...@codesourcery.com> * testsuite/libgomp.oacc-c++/firstprivate-mappings-1.C: Add diff --git a/libgomp/testsuite/libgomp.oacc-fortran/atomic_capture-1.f90 b/libgomp/testsuite/libgomp.oacc-fortran/atomic_capture-1.f90 index 5a4a1e03f64..536b3f0030c 100644 --- a/libgomp/testsuite/libgomp.oacc-fortran/atomic_capture-1.f90 +++ b/libgomp/testsuite/libgomp.oacc-fortran/atomic_capture-1.f90 @@ -275,8 +275,9 @@ program main if (ltmp .neqv. .not. lexp) STOP 33 if (lgot .neqv. lexp) STOP 34 - igot = 1 + igot = 0 iexp = N + iarr = -42 !$acc parallel loop copy (igot, itmp) do i = 1, N @@ -287,13 +288,24 @@ program main end do !$acc end parallel loop + if (igot /= N) stop 107 + itmp = 0 + do i = 1, N + if (iarr(i) == 0) then + itmp = i + exit + end if + end do + ! At most one iarr element can be 0. do i = 1, N - if (.not. (1 <= iarr(i) .and. iarr(i) < iexp)) STOP 35 + if ((iarr(i) == 0 .and. i /= itmp) & + .or. iarr(i) < 0 .or. iarr(i) >= N) STOP 35 end do if (igot /= iexp) STOP 36 - igot = N + igot = N + 1 iexp = 1 + iarr = -42 !$acc parallel loop copy (igot, itmp) do i = 1, N @@ -304,8 +316,18 @@ program main end do !$acc end parallel loop + if (igot /= 1) stop 108 + itmp = N + 1 + ! At most one iarr element can be N+1. + do i = 1, N + if (iarr(i) == N + 1) then + itmp = i + exit + end if + end do do i = 1, N - if (.not. (iarr(i) == 1 .or. iarr(i) == N)) STOP 37 + if ((iarr(i) == N + 1 .and. i /= itmp) & + .or. iarr(i) <= 0 .or. iarr(i) > N + 1) STOP 37 end do if (igot /= iexp) STOP 38