public inbox for fortran@gcc.gnu.org
 help / color / mirror / Atom feed
From: Thomas Schwinge <thomas@codesourcery.com>
To: Tobias Burnus <tobias@codesourcery.com>
Cc: <gcc-patches@gcc.gnu.org>, <fortran@gcc.gnu.org>,
	Jakub Jelinek <jakub@redhat.com>
Subject: Re: [Patch] OpenMP/Fortran: Use firstprivat not alloc for ptr attach for arrays
Date: Sat, 12 Nov 2022 10:19:59 +0100	[thread overview]
Message-ID: <87iljk4ji8.fsf@euler.schwinge.homeip.net> (raw)
In-Reply-To: <Yn6ZE3dD1/ONNzb6@tucnak>

Hi Tobias!

On 2022-05-13T19:44:51+0200, Jakub Jelinek via Fortran <fortran@gcc.gnu.org> wrote:
> On Fri, May 13, 2022 at 07:21:02PM +0200, Tobias Burnus wrote:
>> gcc/fortran/ChangeLog:
>>
>>      * trans-openmp.cc (gfc_trans_omp_clauses): When mapping nondescriptor
>>      array sections, use GOMP_MAP_FIRSTPRIVATE_POINTER instead of
>>      GOMP_MAP_POINTER for the pointer attachment.
>>
>> libgomp/ChangeLog:
>>
>>      * testsuite/libgomp.fortran/target-nowait-array-section.f90: New test.
>
> Not 100% sure if we want to add such a testcase into the testsuite given
> that it is not valid OpenMP, but perhaps it is ok as we are testing a QoI.

For non-offloading x86_64-pc-linux-gnu '-m32', I'm occasionally (but very
rarely!) seeing this test case FAIL its execution test.  Similar can also
be seen on occasional reports via <gcc-testresults@gcc.gnu.org>,
<gcc-regression@gcc.gnu.org>.


Grüße
 Thomas


'libgomp.fortran/target-nowait-array-section.f90':

| ! Runs the the target region asynchrolously and checks for it
| !
| ! Note that  map(alloc: work(:, i)) + nowait  should be safe
| ! given that a nondescriptor array is used. However, it still
| ! violates a map clause restriction, added in OpenMP 5.1 [354:10-13].
|
| PROGRAM test_target_teams_distribute_nowait
|   USE ISO_Fortran_env, only: INT64
|   implicit none
|     INTEGER, parameter :: N = 1024, N_TASKS = 16
|     INTEGER :: i, j, k, my_ticket
|     INTEGER :: order(n_tasks)
|     INTEGER(INT64) :: work(n, n_tasks)
|     INTEGER :: ticket
|     logical :: async
|
|     ticket = 0
|
|     !$omp target enter data map(to: ticket, order)
|
|     !$omp parallel do num_threads(n_tasks)
|     DO i = 1, n_tasks
|        !$omp target map(alloc: work(:, i), ticket) private(my_ticket) nowait
|        !!$omp target teams distribute map(alloc: work(:, i), ticket) private(my_ticket) nowait
|        DO j = 1, n
|           ! Waste cyles
| !          work(j, i) = 0
| !          DO k = 1, n*(n_tasks - i)
| !             work(j, i) = work(j, i) + i*j*k
| !          END DO
|           my_ticket = 0
|           !$omp atomic capture
|           ticket = ticket + 1
|           my_ticket = ticket
|           !$omp end atomic
|           !$omp atomic write
|           order(i) = my_ticket
|        END DO
|        !$omp end target !teams distribute
|     END DO
|     !$omp end parallel do
|
|     !$omp target exit data map(from:ticket, order)
|
|     IF (ticket .ne. n_tasks*n) stop 1
|     if (maxval(order) /= n_tasks*n) stop 2
|     ! order(i) == n*i if synchronous and between n and n*n_tasks if run concurrently
|     do i = 1, n_tasks
|       if (order(i) < n .or. order(i) > n*n_tasks) stop 3
|     end do
|     async = .false.
|     do i = 1, n_tasks
|       if (order(i) /= n*i) async = .true.
|     end do
|     if (.not. async) stop 4 ! Did not run asynchronously
| end
-----------------
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

      reply	other threads:[~2022-11-12  9:20 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-13 17:21 Tobias Burnus
2022-05-13 17:44 ` Jakub Jelinek
2022-11-12  9:19   ` Thomas Schwinge [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87iljk4ji8.fsf@euler.schwinge.homeip.net \
    --to=thomas@codesourcery.com \
    --cc=fortran@gcc.gnu.org \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jakub@redhat.com \
    --cc=tobias@codesourcery.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).