From 48cb2f5a9eb66195606283dda6017ad717744e57 Mon Sep 17 00:00:00 2001 From: David Yat Sin Date: Tue, 19 Sep 2023 00:25:30 +0000 Subject: [PATCH] Add query for Xnack enabled Add system query for whether Xnack is enabled on a system. Change-Id: I2832110e4f33f6a951d13acd06636442debf27ae [ROCm/ROCR-Runtime commit: 22becfb1e8e9098c313e8cce0bb57c755e538d0d] --- projects/rocr-runtime/runtime/hsa-runtime/core/inc/runtime.h | 3 +++ .../runtime/hsa-runtime/core/runtime/amd_topology.cpp | 1 + .../runtime/hsa-runtime/core/runtime/runtime.cpp | 4 ++++ projects/rocr-runtime/runtime/hsa-runtime/inc/hsa.h | 5 +++++ 4 files changed, 13 insertions(+) diff --git a/projects/rocr-runtime/runtime/hsa-runtime/core/inc/runtime.h b/projects/rocr-runtime/runtime/hsa-runtime/core/inc/runtime.h index 15f45371cc..ee766bfc9c 100644 --- a/projects/rocr-runtime/runtime/hsa-runtime/core/inc/runtime.h +++ b/projects/rocr-runtime/runtime/hsa-runtime/core/inc/runtime.h @@ -455,6 +455,8 @@ class Runtime { KfdVersion_t KfdVersion() const { return kfd_version; } bool VirtualMemApiSupported() const { return virtual_mem_api_supported_; } + bool XnackEnabled() const { return xnack_enabled_; } + void XnackEnabled(bool enable) { xnack_enabled_ = enable; } protected: static void AsyncEventsLoop(void*); @@ -708,6 +710,7 @@ class Runtime { int GetAmdgpuDeviceArgs(Agent* agent, amdgpu_bo_handle bo, int* drm_fd, uint64_t* cpu_addr); bool virtual_mem_api_supported_; + bool xnack_enabled_; typedef void* ThunkHandle; diff --git a/projects/rocr-runtime/runtime/hsa-runtime/core/runtime/amd_topology.cpp b/projects/rocr-runtime/runtime/hsa-runtime/core/runtime/amd_topology.cpp index d8cf5e2130..fc0d98ca9e 100644 --- a/projects/rocr-runtime/runtime/hsa-runtime/core/runtime/amd_topology.cpp +++ b/projects/rocr-runtime/runtime/hsa-runtime/core/runtime/amd_topology.cpp @@ -351,6 +351,7 @@ void BuildTopology() { // Determine the Xnack mode to be bound for system bool xnack_mode = BindXnackMode(); + core::Runtime::runtime_singleton_->XnackEnabled(xnack_mode); // Instantiate ROCr objects to encapsulate Gpu devices SurfaceGpuList(gpu_usr_list, xnack_mode, true); diff --git a/projects/rocr-runtime/runtime/hsa-runtime/core/runtime/runtime.cpp b/projects/rocr-runtime/runtime/hsa-runtime/core/runtime/runtime.cpp index ed3ab60d92..8d7b133957 100644 --- a/projects/rocr-runtime/runtime/hsa-runtime/core/runtime/runtime.cpp +++ b/projects/rocr-runtime/runtime/hsa-runtime/core/runtime/runtime.cpp @@ -709,6 +709,10 @@ hsa_status_t Runtime::GetSystemInfo(hsa_system_info_t attribute, void* value) { *((bool*)value) = core::Runtime::runtime_singleton_->VirtualMemApiSupported(); break; } + case HSA_AMD_SYSTEM_INFO_XNACK_ENABLED: { + *((bool*)value) = core::Runtime::runtime_singleton_->XnackEnabled(); + break; + } default: return HSA_STATUS_ERROR_INVALID_ARGUMENT; } diff --git a/projects/rocr-runtime/runtime/hsa-runtime/inc/hsa.h b/projects/rocr-runtime/runtime/hsa-runtime/inc/hsa.h index 2ba25df2d1..bd0ee1e698 100644 --- a/projects/rocr-runtime/runtime/hsa-runtime/inc/hsa.h +++ b/projects/rocr-runtime/runtime/hsa-runtime/inc/hsa.h @@ -514,6 +514,11 @@ typedef enum { * this attribute is bool. */ HSA_AMD_SYSTEM_INFO_VIRTUAL_MEM_API_SUPPORTED = 0x205, + /** + * Returns true if XNACK is enabled on this system. The type of + * this attribute is bool. + */ + HSA_AMD_SYSTEM_INFO_XNACK_ENABLED = 0x206, } hsa_system_info_t; /**