Extend ROCr to surface UUID of GPU devices that suppport

Change-Id: I478db68d69a01578770403fa695f9e6391637573
This commit is contained in:
Ramesh Errabolu
2020-03-05 13:44:22 -06:00
committato da Sean Keely
parent 241cdfdd01
commit 45958c727d
7 ha cambiato i file con 61 aggiunte e 5 eliminazioni
@@ -357,6 +357,12 @@ hsa_status_t CpuAgent::GetInfo(hsa_agent_info_t attribute, void* value) const {
case HSA_AMD_AGENT_INFO_DOMAIN:
*((uint32_t*)value) = static_cast<uint32_t>(properties_.Domain);
break;
case HSA_AMD_AGENT_INFO_UUID: {
// At this point CPU devices do not support UUID's.
char uuid_tmp[] = "CPU-XX";
snprintf((char*)value, sizeof(uuid_tmp), "%s", uuid_tmp);
break;
}
default:
return HSA_STATUS_ERROR_INVALID_ARGUMENT;
break;
@@ -51,6 +51,7 @@
#include <vector>
#include <memory>
#include <utility>
#include <iomanip>
#include "core/inc/amd_aql_queue.h"
#include "core/inc/amd_blit_kernel.h"
@@ -900,6 +901,25 @@ hsa_status_t GpuAgent::GetInfo(hsa_agent_info_t attribute, void* value) const {
case HSA_AMD_AGENT_INFO_COOPERATIVE_QUEUES:
*((bool*)value) = properties_.NumGws != 0;
break;
case HSA_AMD_AGENT_INFO_UUID: {
uint64_t uuid_value = static_cast<uint64_t>(properties_.UniqueID);
// Either device does not support UUID e.g. a Gfx8 device,
// or runtime is using an older thunk library that does not
// support UUID's
if (uuid_value == 0) {
char uuid_tmp[] = "GPU-XX";
snprintf((char*)value, sizeof(uuid_tmp), "%s", uuid_tmp);
break;
}
// Device supports UUID, build UUID string to return
std::stringstream ss;
ss << "GPU-" << std::setfill('0') << std::setw(sizeof(uint64_t) * 2) << std::hex
<< uuid_value;
snprintf((char*)value, (ss.str().length() + 1), "%s", (char*)ss.str().c_str());
break;
}
default:
return HSA_STATUS_ERROR_INVALID_ARGUMENT;
break;
@@ -84,14 +84,19 @@ static bool PrintUsrGpuMap(std::map<uint32_t, int32_t>& gpu_usr_map) {
* subset of Gpu's are desired to be surfaced. If defined the
* set of Gpu's are captured into a map of Gpu index and
*
* @return true if env is not blank, false otherwise. It is
* possible to have zero devices surfaced even when env is
* not blank.
* @return true if env is defined i.e. has some value including
* empty string, false otherwise. It is possible to have zero
* devices surfaced even when env is not blank.
*/
static bool MapUsrGpuList(int32_t numNodes, std::map<uint32_t, int32_t>& gpu_usr_map) {
bool filter = core::Runtime::runtime_singleton_->flag().filter_visible_gpus();
if (filter == false) {
return false;
}
const std::string& env_value = core::Runtime::runtime_singleton_->flag().visible_gpus();
if (env_value.empty()) {
return false;
return true;
}
// Capture the env value string as a parsable stream
+3
Vedi File
@@ -72,6 +72,7 @@ class Flag {
enable_sdma_ = os::GetEnvVar("HSA_ENABLE_SDMA");
visible_gpus_ = os::GetEnvVar("ROCR_VISIBLE_DEVICES");
filter_visible_gpus_ = os::IsEnvVarSet("ROCR_VISIBLE_DEVICES");
var = os::GetEnvVar("HSA_RUNNING_UNDER_VALGRIND");
running_valgrind_ = (var == "1") ? true : false;
@@ -143,6 +144,7 @@ class Flag {
std::string enable_sdma() const { return enable_sdma_; }
std::string visible_gpus() const { return visible_gpus_; }
bool filter_visible_gpus() const { return filter_visible_gpus_; }
uint32_t max_queues() const { return max_queues_; }
@@ -167,6 +169,7 @@ class Flag {
std::string enable_sdma_;
bool filter_visible_gpus_;
std::string visible_gpus_;
uint32_t max_queues_;
@@ -237,6 +237,12 @@ bool WaitForAllThreads(Thread* threads, uint threadCount) {
return true;
}
bool IsEnvVarSet(std::string env_var_name) {
char* buff = NULL;
buff = getenv(env_var_name.c_str());
return (buff != NULL);
}
void SetEnvVar(std::string env_var_name, std::string env_var_value) {
setenv(env_var_name.c_str(), env_var_value.c_str(), 1);
}
+6
Vedi File
@@ -152,6 +152,12 @@ bool WaitForThread(Thread thread);
/// @return: bool.
bool WaitForAllThreads(Thread* threads, uint thread_count);
/// @brief: Determines if environment key is set.
/// @param: env_var_name(Input), name of the environment value.
/// @return: bool, true for binding any value to environment key,
/// including an empty string. False otherwise
bool IsEnvVarSet(std::string env_var_name);
/// @brief: Sets the environment value.
/// @param: env_var_name(Input), name of the environment value.
/// @param: env_var_value(Input), value of the environment value.s
+11 -1
Vedi File
@@ -163,7 +163,17 @@ typedef enum hsa_amd_agent_info_s {
* Queries for support of cooperative queues. See ::HSA_QUEUE_TYPE_COOPERATIVE.
* The type of this attribute is bool.
*/
HSA_AMD_AGENT_INFO_COOPERATIVE_QUEUES = 0xA010
HSA_AMD_AGENT_INFO_COOPERATIVE_QUEUES = 0xA010,
/**
* Queries UUID of an agent. The value is an Ascii string with a maximum
* of 21 chars including NUL. The string value consists of two parts: header
* and body. The header identifies device type (GPU, CPU, DSP) while body
* encodes UUID as a 16 digit hex string
*
* Agents that do not support UUID will return the string "GPU-XX" or
* "CPU-XX" or "DSP-XX" depending upon their device type ::hsa_device_type_t
*/
HSA_AMD_AGENT_INFO_UUID = 0xA011
} hsa_amd_agent_info_t;
typedef struct hsa_amd_hdp_flush_s {