https://gcc.gnu.org/bugzilla/show_bug.cgi?id=126279

            Bug ID: 126279
           Summary: [OpenMP] Fortran & multiple uses_allocators clauses
                    mishandled
           Product: gcc
           Version: 17.0
            Status: UNCONFIRMED
          Keywords: openmp, wrong-code
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: burnus at gcc dot gnu.org
                CC: cltang at gcc dot gnu.org
  Target Milestone: ---

Created attachment 65057
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=65057&action=edit
Patch to fix 'memspace' conversion + extend testcase

The following is with mainline r17-2423-g6f754f345e0621 and the attached patch
applied.

Using:

  !$omp target uses_allocators( &
      traits(t), memspace(omp_high_bw_mem_space) : my; &
      omp_default_mem_alloc,  &  ! predefined allocator (= 0B)
        omp_null_allocator;   &  ! ignored
      my2;  &  ! = default mem space, default traits
      traits(t2) : my3;
      memspace(omp_large_cap_mem_space) : my4)
  block
    type(c_ptr) :: c1, c2, c3, c4
    c1 = omp_alloc (c_sizeof(x), my)
    c2 = omp_alloc (c_sizeof(x), my2)
    c3 = omp_alloc (c_sizeof(x), my3)
    c4 = omp_alloc (c_sizeof(x), my4)

Gives as shown in the debugger the calls

   omp_alloc (size=4, allocator=140737488339600)
   omp_alloc (size=8, allocator=140737488339600)
   omp_alloc (size=12, allocator=140737488339600)
   omp_alloc (size=16, allocator=140737488339600)

That's with
  memspace = omp_large_cap_mem_space
i.e. matches 'my4'.  Accordingly, 'c3' is allocated with
allocator_data->alignment == 8 – instead of with an alignment of 1024,
such that the alignment check fails at runtime!

EXPECTED: 4 different allocators are used - and c3 has an alignment of 1024
bit.


I think the original + gimple dump are okay.

Besides the issue of above, I noticed in the omp-lower dump
the following:

        D.5004 = (unsigned long) &D.5002;
        uses_allocator_descr.49[2] = D.5004;

This one is pretty bad as there is no 'D.5002 = ...' in the code.

Reply via email to