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

--- Comment #2 from Tobias Burnus <burnus at gcc dot gnu.org> ---
(In reply to Thomas Schwinge from comment #1)
> See also "Allow the accelerator to have more offloaded functions than the 
> host".

Which was:

-  if (num_target_entries != num_funcs + num_vars)
+  if (num_target_entries < num_funcs + num_vars)

I think this approach only works if functions are missing "at the end".
The code does:

gomp_load_image_to_device (..., const void *host_table,
                                const void *target_data, ...)
...
  void **host_func_table = ((void ***) host_table)[0];
  void **host_funcs_end  = ((void ***) host_table)[1];
  int num_funcs = host_funcs_end - host_func_table;
...
  num_target_entries
    = devicep->load_image_func (devicep->target_id, version,
                                target_data, &target_table,
...
      k->host_start = (uintptr_t) host_func_table[i];
...
      k->tgt_offset = target_table[i].start;

Thus, it strictly depends on the order. That is: If some function "in the
middle" is not linked in / part of 'host_table' alias '__OFFLOAD_TABLE__', all
remaining host<->device function and/or variable assignments are messed up.

Reply via email to