]> git.ipfire.org Git - thirdparty/gcc.git/commit
amdgcn, openmp: Auto-detect USM mode and set HSA_XNACK
authorAndrew Stubbs <ams@codesourcery.com>
Fri, 17 Jun 2022 12:07:11 +0000 (13:07 +0100)
committerKwok Cheung Yeung <kcy@codesourcery.com>
Fri, 1 Jul 2022 16:31:33 +0000 (17:31 +0100)
commit687640af27af0d2a5bd92a5de44a9a7d33526052
tree6f26cd4012e80c3fcc2ff359ab611e5ff2da8c90
parentcbc3dd01de8788587a2b641efcb838058303b5ab
amdgcn, openmp: Auto-detect USM mode and set HSA_XNACK

The AMD GCN runtime must be set to the correct mode for Unified Shared Memory
to work, but this is not always clear at compile and link time due to the split
nature of the offload compilation pipeline.

This patch sets a new attribute on OpenMP offload functions to ensure that the
information is passed all the way to the backend.  The backend then places a
marker in the assembler code for mkoffload to find. Finally mkoffload places a
constructor function into the final program to ensure that the HSA_XNACK
environment variable passes the correct mode to the GPU.

The HSA_XNACK variable must be set before the HSA runtime is even loaded, so
it makes more sense to have this set within the constructor than at some point
later within libgomp or the GCN plugin.

gcc/ChangeLog:

* config/gcn/gcn.c (unified_shared_memory_enabled): New variable.
(gcn_init_cumulative_args): Handle attribute "omp unified memory".
(gcn_hsa_declare_function_name): Emit "MKOFFLOAD OPTIONS: USM+".
* config/gcn/mkoffload.c (TEST_XNACK_OFF): New macro.
(process_asm): Detect "MKOFFLOAD OPTIONS: USM+".
Emit configure_xnack constructor, as required.
* omp-low.c (create_omp_child_function): Add attribute "omp unified
memory".
gcc/ChangeLog.omp
gcc/config/gcn/gcn.cc
gcc/config/gcn/mkoffload.cc
gcc/omp-low.cc