Sandra Loosemore wrote:

maybe this one is simple
enough that I can make more progress on it.  It's probably something
being added to the wrong gimple_seq somewhere.

Good luck!

* * *

I played around without fully checking the the validity. I found
an unrelated ICE - but also was puzzled by "‘i’ is used uninitialized"
warnings.

* * *

iter-test2.c:14:11: internal compiler error: base pointer cycle detected
   14 |   #pragma omp target map(to: x[:4]) map(iterator(i=low:high:stride), 
to: x[i].ptr)
      |           ^~~
0x27fb3af internal_error(char const*, ...)
        gcc/diagnostic-global-context.cc:787
0xec1444 omp_tsort_mapping_groups_1
        gcc/gimplify.cc:11438

--------<cut>-------------
struct array_ptr
{
  int *ptr;
};

void
f (struct array_ptr *x, int low, int high, int stride)
{
  #pragma omp target map(to: x[:4]) map(iterator(i=low:high:stride), to: 
x[i].ptr)
  {
    __builtin_printf ("f: dev  %p / %p\n", x[0].ptr, x[2].ptr);
  }
}
--------<cut>-------------

It works if I add 'x'  [namely: 'map(to: x, x[:4])'] - but doing so gives with 
-Wall:

iter-test2.c:14:11: warning: ‘<anonymous>’ is used uninitialized 
[-Wuninitialized]
   14 |   #pragma omp target map(to: x, x[:4]) map(iterator(i=low:high:stride), 
to: x[i].ptr)
      |           ^~~
iter-test2.c:14:78: note: ‘<anonymous>’ was declared here
   14 |   #pragma omp target map(to: x, x[:4]) map(iterator(i=low:high:stride), 
to: x[i].ptr)
      |                                                                         
     ^


Or when doing:

void
f (struct array_ptr *x, int low, int high, int stride)
{
  #pragma omp target map(to: x) map(iterator(i=low:high:stride), to: 
x[i].ptr[:2])


iter-test.c: In function ‘f’:
iter-test.c:15:71: warning: ‘i’ is used uninitialized [-Wuninitialized]
   15 |   #pragma omp target map(to: x) map(iterator(i=low:high:stride), to: 
x[i].ptr[:2])
      |                                                                       ^
iter-test.c:15:46: note: ‘i’ was declared here
   15 |   #pragma omp target map(to: x) map(iterator(i=low:high:stride), to: 
x[i].ptr[:2])

* * *

However, the original issue is independent as the following is unrelated to
iterator and also gives the ICE:

  #pragma omp target map(to: x[:4]) map(to: x[0].ptr[:2], x[2].ptr[:2])

Still, the 'i' is uninitialized is unexpected :-/

* * *

I had expected that the following works, but it fails at runtime with:

void
g (struct array_ptr *x)
{
  __builtin_printf ("g: host %p / %p\n", x[0].ptr, x[2].ptr);
  #pragma omp target map(to: x, x[:4], x[0].ptr[:2], x[2].ptr[:2])
     __builtin_printf ("g: dev  %p / %p\n", x[0].ptr, x[2].ptr);
}

but gives
 g: host 0x7ffc79878128 / 0x7ffc79878118
 libgomp: Trying to map into device [0x7ffc798780f0..0x7ffc79878110) object 
when [0x7ffc79878100..0x7ffc79878108) is already mapped


for

main ()
{
  int x1[] = {1, 2};
  int x2[] = {11, 22};
  int x3[] = {111, 222};
  int x4[] = {1111, 2222};
  struct array_ptr var[4];

  var[0].ptr = x1;
  var[1].ptr = x2;
  var[2].ptr = x3;
  var[3].ptr = x4;

  g(var);
}

Tobias

PS: Just to dump the findings; I am too tired to analyse this this evening
and to decide what's valid OpenMP and what's not.

Reply via email to