Store target ID in isa registry
Store target ID string in isa registry and use for returning agent and
isa name.
Change-Id: I72a20d8ff963c73d86392158aff3853e4c9bfdbd
[ROCm/ROCR-Runtime commit: 853ccc762e]
This commit is contained in:
@@ -178,7 +178,10 @@ class Isa final: public amd::hsa::common::Signed<0xB13594F2BD8F212D> {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @returns This Isa's full name.
|
/// @returns This Isa's processor name.
|
||||||
|
std::string GetName() const;
|
||||||
|
|
||||||
|
/// @returns This Isa's full target triple and target ID name.
|
||||||
std::string GetFullName() const;
|
std::string GetFullName() const;
|
||||||
|
|
||||||
/// @brief Query value of requested @p attribute and record it in @p value.
|
/// @brief Query value of requested @p attribute and record it in @p value.
|
||||||
@@ -194,23 +197,13 @@ class Isa final: public amd::hsa::common::Signed<0xB13594F2BD8F212D> {
|
|||||||
private:
|
private:
|
||||||
/// @brief Default constructor.
|
/// @brief Default constructor.
|
||||||
Isa()
|
Isa()
|
||||||
: version_(Version(-1, -1, -1)),
|
: targetid_(nullptr),
|
||||||
|
version_(Version(-1, -1, -1)),
|
||||||
sramecc_(IsaFeature::Unsupported),
|
sramecc_(IsaFeature::Unsupported),
|
||||||
xnack_(IsaFeature::Unsupported) {}
|
xnack_(IsaFeature::Unsupported) {}
|
||||||
|
|
||||||
/// @brief Construct from @p version.
|
// @brief Isa's target ID name.
|
||||||
Isa(const Version &version)
|
const char* targetid_;
|
||||||
: version_(version),
|
|
||||||
sramecc_(IsaFeature::Unsupported),
|
|
||||||
xnack_(IsaFeature::Unsupported) {}
|
|
||||||
|
|
||||||
/// @brief Construct from @p version.
|
|
||||||
Isa(const Version &version,
|
|
||||||
IsaFeature sramecc,
|
|
||||||
IsaFeature xnack)
|
|
||||||
: version_(version),
|
|
||||||
sramecc_(sramecc),
|
|
||||||
xnack_(xnack) {}
|
|
||||||
|
|
||||||
/// @brief Isa's version.
|
/// @brief Isa's version.
|
||||||
Version version_;
|
Version version_;
|
||||||
|
|||||||
@@ -726,21 +726,20 @@ hsa_status_t GpuAgent::EnableDmaProfiling(bool enable) {
|
|||||||
hsa_status_t GpuAgent::GetInfo(hsa_agent_info_t attribute, void* value) const {
|
hsa_status_t GpuAgent::GetInfo(hsa_agent_info_t attribute, void* value) const {
|
||||||
// agent, and vendor name size limit
|
// agent, and vendor name size limit
|
||||||
const size_t attribute_u = static_cast<size_t>(attribute);
|
const size_t attribute_u = static_cast<size_t>(attribute);
|
||||||
|
// agent, and vendor name length limit excluding terminating nul character.
|
||||||
|
constexpr size_t hsa_name_size = 63;
|
||||||
|
|
||||||
switch (attribute_u) {
|
switch (attribute_u) {
|
||||||
// Build agent name by concatenating the Major, Minor and Stepping Ids
|
|
||||||
// of devices compute capability with a prefix of "gfx"
|
|
||||||
case HSA_AGENT_INFO_NAME: {
|
case HSA_AGENT_INFO_NAME: {
|
||||||
std::stringstream name;
|
std::string name = isa_->GetName();
|
||||||
std::memset(value, 0, HSA_PUBLIC_NAME_SIZE);
|
assert(name.size() <= hsa_name_size);
|
||||||
|
std::memset(value, 0, hsa_name_size);
|
||||||
char* temp = reinterpret_cast<char*>(value);
|
char* temp = reinterpret_cast<char*>(value);
|
||||||
name << "gfx" << isa_->GetMajorVersion() << std::hex << isa_->GetMinorVersion()
|
std::strcpy(temp, name.c_str());
|
||||||
<< isa_->GetStepping();
|
|
||||||
std::strcpy(temp, name.str().c_str());
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case HSA_AGENT_INFO_VENDOR_NAME:
|
case HSA_AGENT_INFO_VENDOR_NAME:
|
||||||
std::memset(value, 0, HSA_PUBLIC_NAME_SIZE);
|
std::memset(value, 0, hsa_name_size);
|
||||||
std::memcpy(value, "AMD", sizeof("AMD"));
|
std::memcpy(value, "AMD", sizeof("AMD"));
|
||||||
break;
|
break;
|
||||||
case HSA_AGENT_INFO_FEATURE:
|
case HSA_AGENT_INFO_FEATURE:
|
||||||
|
|||||||
@@ -42,7 +42,9 @@
|
|||||||
|
|
||||||
#include "core/inc/isa.h"
|
#include "core/inc/isa.h"
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
#include <iostream>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
@@ -88,37 +90,14 @@ bool Isa::IsCompatible(const Isa &code_object_isa,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string Isa::GetName() const {
|
||||||
|
std::string processor(targetid_);
|
||||||
|
return processor.substr(0, processor.find(':'));
|
||||||
|
}
|
||||||
|
|
||||||
std::string Isa::GetFullName() const {
|
std::string Isa::GetFullName() const {
|
||||||
std::stringstream full_name;
|
return GetArchitecture() + '-' + GetVendor() + '-' + GetOS() + '-' + GetEnvironment() + '-' +
|
||||||
auto fmt = full_name.flags();
|
targetid_;
|
||||||
full_name << GetArchitecture() << "-" << GetVendor() << "-" << GetOS() << "-"
|
|
||||||
<< GetEnvironment() << "-gfx" << GetMajorVersion()
|
|
||||||
<< std::hex << GetMinorVersion() << GetStepping();
|
|
||||||
full_name.flags(fmt);
|
|
||||||
|
|
||||||
switch (sramecc_) {
|
|
||||||
case IsaFeature::Disabled:
|
|
||||||
full_name << ":sramecc-";
|
|
||||||
break;
|
|
||||||
case IsaFeature::Enabled:
|
|
||||||
full_name << ":sramecc+";
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (xnack_) {
|
|
||||||
case IsaFeature::Disabled:
|
|
||||||
full_name << ":xnack-";
|
|
||||||
break;
|
|
||||||
case IsaFeature::Enabled:
|
|
||||||
full_name << ":xnack+";
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return full_name.str();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Isa::GetInfo(const hsa_isa_info_t &attribute, void *value) const {
|
bool Isa::GetInfo(const hsa_isa_info_t &attribute, void *value) const {
|
||||||
@@ -225,7 +204,11 @@ const Isa *IsaRegistry::GetIsa(const std::string &full_name) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const Isa *IsaRegistry::GetIsa(const Isa::Version &version, IsaFeature sramecc, IsaFeature xnack) {
|
const Isa *IsaRegistry::GetIsa(const Isa::Version &version, IsaFeature sramecc, IsaFeature xnack) {
|
||||||
auto isareg_iter = supported_isas_.find(Isa(version, sramecc, xnack).GetFullName());
|
auto isareg_iter = std::find_if(
|
||||||
|
supported_isas_.begin(), supported_isas_.end(), [&](const IsaMap::value_type& isareg) {
|
||||||
|
return isareg.second.version() == version && isareg.second.sramecc() == sramecc &&
|
||||||
|
isareg.second.xnack() == xnack;
|
||||||
|
});
|
||||||
return isareg_iter == supported_isas_.end() ? nullptr : &isareg_iter->second;
|
return isareg_iter == supported_isas_.end() ? nullptr : &isareg_iter->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -233,8 +216,15 @@ const IsaRegistry::IsaMap IsaRegistry::supported_isas_ =
|
|||||||
IsaRegistry::GetSupportedIsas();
|
IsaRegistry::GetSupportedIsas();
|
||||||
|
|
||||||
const IsaRegistry::IsaMap IsaRegistry::GetSupportedIsas() {
|
const IsaRegistry::IsaMap IsaRegistry::GetSupportedIsas() {
|
||||||
|
|
||||||
|
// agent, and vendor name length limit excluding terminating nul character.
|
||||||
|
constexpr size_t hsa_name_size = 63;
|
||||||
|
|
||||||
|
// FIXME: Use static_assert when C++17 used.
|
||||||
#define ISAREG_ENTRY_GEN(name, maj, min, stp, sramecc, xnack) \
|
#define ISAREG_ENTRY_GEN(name, maj, min, stp, sramecc, xnack) \
|
||||||
|
assert(std::char_traits<char>::length(name) <= hsa_name_size); \
|
||||||
Isa amd_amdgpu_##maj##min##stp##_SRAMECC_##sramecc##_XNACK_##xnack; \
|
Isa amd_amdgpu_##maj##min##stp##_SRAMECC_##sramecc##_XNACK_##xnack; \
|
||||||
|
amd_amdgpu_##maj##min##stp##_SRAMECC_##sramecc##_XNACK_##xnack.targetid_ = name; \
|
||||||
amd_amdgpu_##maj##min##stp##_SRAMECC_##sramecc##_XNACK_##xnack.version_ = Isa::Version(maj, min, stp); \
|
amd_amdgpu_##maj##min##stp##_SRAMECC_##sramecc##_XNACK_##xnack.version_ = Isa::Version(maj, min, stp); \
|
||||||
amd_amdgpu_##maj##min##stp##_SRAMECC_##sramecc##_XNACK_##xnack.sramecc_ = sramecc; \
|
amd_amdgpu_##maj##min##stp##_SRAMECC_##sramecc##_XNACK_##xnack.sramecc_ = sramecc; \
|
||||||
amd_amdgpu_##maj##min##stp##_SRAMECC_##sramecc##_XNACK_##xnack.xnack_ = xnack; \
|
amd_amdgpu_##maj##min##stp##_SRAMECC_##sramecc##_XNACK_##xnack.xnack_ = xnack; \
|
||||||
|
|||||||
Reference in New Issue
Block a user