Hi PA,

Paul-Antoine Arras wrote:
On 27/12/2024 19:52, Paul-Antoine Arras wrote:
Running adjust-args-10.f90 manually exhibited a bug that no other testcase triggered. So I fixed the bug; then moved adjust-args-10.f90 to the libgomp testsuite, renamed it to dispatch-3.f90 and made it dg-run.
I forgot to mention, I had to comment out the two allocatables in functions f and g, otherwise I would get a segfault upon return. Is that correct?

It works if either offloading is not enabled or the default device is the host.

The problem is that for:

      !$omp target ... map(from: f)
      block
        f = -(iy1+iy2)*23  -127 * (iz1+iz2) - x * 3
      end block

'f' is allocated on assignment on the device, which does not work well.

Change the first line to:

      allocate(f)
      !$omp target is_device_ptr(y1, y2, z1, z2) map(tofrom: f)

Namely, add an 'allocate(f)' before 'omp target' and use 'tofrom' not 'from' 
for 'f'.

* * *

BTW: I think we should add a 'stop 2' to 'g' as it should never be called.

* * *

But there is one thing which looks wrong, namely for:

  !$omp dispatch
    func = f(1,x1,x2,x3,x4)

I would expect that '!$omp dispatch' has no effect as 'f' is not a variant 
function
but I see:

              D.4994 = __builtin_omp_get_mapped_ptr (D.4993, D.4986);
              D.4995 = __builtin_omp_get_mapped_ptr (x1, D.4986);
              D.4856 = f (1, D.4995, D.4994, &D.4992, &D.4989);

Looks as if we need to check that 'f' is a variant function before adding
the .GOMP_DISPATCH ?


Same issue for C/C++, namely:

void h(int *);
void f(int *);
#pragma omp declare variant(f) match(construct={dispatch}) 
adjust_args(need_device_ptr : x)
void g(int *x);

void foo(int *y)
{
  #pragma omp dispatch
    h(y);
  #pragma omp dispatch
    f(y);
  #pragma omp dispatch
    g(y);
}

Here, I see for 'f' and 'g':
  D.2983 = __builtin_omp_get_mapped_ptr (y, D.2982);
  f (D.2983);

but I would expect it only for 'g(y)' and not for 'f(y)'.

Namely, from 6.0: "The dispatch construct may also modify the
semantic requirement set of elements that affect the arguments
of the function variant if variant substitution occurs
(see Section 9.6.2 and Section 9.6.3)."

Note the 'if variant substitution occurs'.

Tobias

Reply via email to