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

--- Comment #1 from Tobias Burnus <burnus at gcc dot gnu.org> ---
The fail is for the assert:
  gcc_assert ((n->value & GOVD_SEEN) == 0 | ...

as n == NULL.

If one at this location invokes 'return', the program finishes with the (valid)
message:

error: OpenMP constructs other than ‘ordered simd’, ‘simd’, ‘loop’ or ‘atomic’
may not be nested inside ‘simd’ region
   16 |       #pragma omp interop init(target : intop)

Still, the question is: why does the code assume that the symbol can be found
(n != NULL) why does this now fail?

* * *

The following variant fails with:

#0  scan_sharing_clauses (clauses=0x7ffff720d828, ctx=0x357f590) at
../../../repos/gcc/gcc/omp-low.cc:1217
1217              gcc_assert (is_taskreg_ctx (ctx));
#1  0x0000000001040db8 in scan_omp_target (stmt=0x7ffff73e6cb8, outer_ctx=0x0)
at ../../../repos/gcc/gcc/omp-low.cc:3151
#2  0x0000000001041f89 in scan_omp_1_stmt (gsi=0x7fffffffc860,
handled_ops_p=0x7fffffffc82f, wi=0x7fffffffc9d0) at
../../../repos/gcc/gcc/omp-low.cc:4272

as is_taskreg_ctx (ctx) == false with:
  is_taskreg_ctx (omp_context *ctx)
  { 
    return is_parallel_ctx (ctx) || is_task_ctx (ctx) || is_host_teams_ctx
(ctx);

with scan_omp_target's (gdb) p debug(stmt)

#pragma omp target num_teams(-2) thread_limit(0) shared(intop) shared(cnt)
shared(n) map(tofrom:cnt [len: 4]) [child fn: f._omp_fn.0 (???)]
  {
    #pragma omp parallel firstprivate(x) firstprivate(i) shared(cnt) shared(n)

WHY ARE THERE SHARED clauses on TARGET?

// ...
#pragma omp target map(tofrom: cnt) //, intop)
#pragma omp parallel
for (int i = 1; i < n; i++)
{
  int x = 1;
  if (omp_is_initial_device())
    {
   intop = omp_interop_nonequit
      #pragma omp interop init(target : intop)
    }
// ...


Presumably, INTEROP causes that the context gets messed up?

Reply via email to