diff options
author | Tobias Burnus <tburnus@baylibre.com> | 2024-05-29 15:29:06 +0200 |
---|---|---|
committer | Tobias Burnus <tburnus@baylibre.com> | 2024-05-29 15:29:06 +0200 |
commit | 18f477980c8597fe3dca2c2e8bd533c0c2b17aa6 (patch) | |
tree | 5d0dcb61f7e305df3994ac6250b906373f8937ff /libgomp/plugin | |
parent | 4ccb3366ade6ec9493f8ca20ab73b0da4b9816db (diff) |
libgomp: Enable USM for AMD APUs and MI200 devices
If HSA_AMD_SYSTEM_INFO_SVM_ACCESSIBLE_BY_DEFAULT is true,
all GPUs on the system support unified shared memory. That's
the case for APUs and MI200 devices when XNACK is enabled.
XNACK can be enabled by setting HSA_XNACK=1 as env var for
supported devices; otherwise, if disable, USM code will
use host fallback.
gcc/ChangeLog:
* config/gcn/gcn-hsa.h (gcn_local_sym_hash): Fix typo.
include/ChangeLog:
* hsa.h (HSA_AMD_SYSTEM_INFO_SVM_ACCESSIBLE_BY_DEFAULT): Add
enum value.
libgomp/ChangeLog:
* libgomp.texi (gcn): Update USM handling
* plugin/plugin-gcn.c (GOMP_OFFLOAD_get_num_devices): Handle
USM if HSA_AMD_SYSTEM_INFO_SVM_ACCESSIBLE_BY_DEFAULT is true.
Diffstat (limited to 'libgomp/plugin')
-rw-r--r-- | libgomp/plugin/plugin-gcn.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/libgomp/plugin/plugin-gcn.c b/libgomp/plugin/plugin-gcn.c index 3cdc7ba929f..3d882b5ab63 100644 --- a/libgomp/plugin/plugin-gcn.c +++ b/libgomp/plugin/plugin-gcn.c @@ -3355,8 +3355,25 @@ GOMP_OFFLOAD_get_num_devices (unsigned int omp_requires_mask) if (hsa_context.agent_count > 0 && ((omp_requires_mask & ~(GOMP_REQUIRES_UNIFIED_ADDRESS + | GOMP_REQUIRES_UNIFIED_SHARED_MEMORY | GOMP_REQUIRES_REVERSE_OFFLOAD)) != 0)) return -1; + /* Check whether host page access is supported; this is per system level + (all GPUs supported by HSA). While intrinsically true for APUs, it + requires XNACK support for discrete GPUs. */ + if (hsa_context.agent_count > 0 + && (omp_requires_mask & GOMP_REQUIRES_UNIFIED_SHARED_MEMORY)) + { + bool b; + hsa_system_info_t type = HSA_AMD_SYSTEM_INFO_SVM_ACCESSIBLE_BY_DEFAULT; + hsa_status_t status = hsa_fns.hsa_system_get_info_fn (type, &b); + if (status != HSA_STATUS_SUCCESS) + GOMP_PLUGIN_error ("HSA_AMD_SYSTEM_INFO_SVM_ACCESSIBLE_BY_DEFAULT " + "failed"); + if (!b) + return -1; + } + return hsa_context.agent_count; } |