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

--- Comment #1 from Tobias Burnus <burnus at gcc dot gnu.org> ---
The issue with having the same allocator on the host should be fixed by:

--- a/libgomp/target.c
+++ b/libgomp/target.c
@@ -3284,2 +3284,3 @@ copy_firstprivate_data (char *tgt, size_t mapnum,
        hostaddrs[i] = (void *) allocator;
+       tgt_size += tgt_size + gomp_omp_allocator_data_size;
       }


With that change, the following C program works as expected - running in the
debugger on the host + looking on the host and device at the alignment output
that looks like:
  0, 336 - 0, 0
which matches expectations.

On the Fortran side it is insufficient; there more goes wrong ...
-------------
#include <omp.h>

int main() {
  const omp_alloctrait_t traits1[] = { { omp_atk_alignment, 16 } };
  const omp_alloctrait_t traits2[] = { { omp_atk_alignment, 1024 } };
  omp_allocator_handle_t alloc1, alloc2;

#pragma omp target uses_allocators(memspace(omp_high_bw_mem_space),
traits(traits1) : alloc1 ; memspace(omp_large_cap_mem_space), traits(traits2) :
alloc2)
  {
    void* ptr1 = omp_alloc(8, alloc1);
    void* ptr2 = omp_alloc(16, alloc2);
__builtin_printf ("%lu, %lu - %lu, %lu\n",
                  (omp_uintptr_t) ptr1 % 16, (omp_uintptr_t) ptr1 % 1024, 
                  (omp_uintptr_t) ptr2 % 16, (omp_uintptr_t) ptr2 % 1024);
  }
}

Reply via email to