https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115279
Bug ID: 115279 Summary: [OpenMP] Fix USM/unified-shared memory handling of 'declare target enter(global_var)' Product: gcc Version: 15.0 Status: UNCONFIRMED Keywords: openmp Severity: normal Priority: P3 Component: middle-end Assignee: unassigned at gcc dot gnu.org Reporter: burnus at gcc dot gnu.org Target Milestone: --- Created attachment 58309 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=58309&action=edit C testcase using USM + a static declare-target variable For 'omp requires unified_shared_memory', OpenMP is a bit unclear but for 'omp required self_maps' OpenMP is rather clear: it should just work. (Note: The 'enter' clause is (only) permitted for 'declare target') OpenMP pre-TR13 states: "If required evaluates to true, the 'self_maps' clause implies the unified_shared_memory clause, inheriting all of its behaviors. Additionally, map-entering clauses in the compilation unit behave as if all resulting mapping operations are self maps, and" Now it comes: "all corresponding list items created by the enter clauses specified by declare target directives in the compilation unit share storage with the original list items." In my understanding, the attached program is therefore valid. It seems as if the way to handle is to generate different code with 'unified_shared_address' and 'self', namely, to replace the variable by a pointer to the real variable (indirection) – similar to the link clause – and then associate the device side link-clause pointer with the host pointer.