Improve Isa class
- Use consistent naming in Isa class.
- Remove unused Isa methods.
- Simplify Isa methods.
Change-Id: I7c4045d08fbfe0d94b3181db8ebc5e5ed8c8cc82
[ROCm/ROCR-Runtime commit: 6bbf6b1c9c]
This commit is contained in:
@@ -65,6 +65,7 @@ public:
|
||||
hsa_wavefront_t handle = { reinterpret_cast<uint64_t>(object) };
|
||||
return handle;
|
||||
}
|
||||
|
||||
/// @returns Object equivalent of @p handle.
|
||||
static Wavefront *Object(const hsa_wavefront_t &handle) {
|
||||
Wavefront *object = amd::hsa::common::ObjectAt<Wavefront>(handle.handle);
|
||||
@@ -104,6 +105,7 @@ class Isa final: public amd::hsa::common::Signed<0xB13594F2BD8F212D> {
|
||||
hsa_isa_t isa_handle = { reinterpret_cast<uint64_t>(isa_object) };
|
||||
return isa_handle;
|
||||
}
|
||||
|
||||
/// @returns Object equivalent of @p isa_handle.
|
||||
static Isa *Object(const hsa_isa_t &isa_handle) {
|
||||
Isa *isa_object = amd::hsa::common::ObjectAt<Isa>(isa_handle.handle);
|
||||
@@ -115,19 +117,22 @@ class Isa final: public amd::hsa::common::Signed<0xB13594F2BD8F212D> {
|
||||
static bool IsCompatible(const Isa &code_object_isa, const Isa &agent_isa);
|
||||
|
||||
/// @returns This Isa's version.
|
||||
const Version &version() const {
|
||||
const Version &GetVersion() const {
|
||||
return version_;
|
||||
}
|
||||
|
||||
/// @returns SRAM ECC feature status.
|
||||
const IsaFeature &sramecc() const {
|
||||
IsaFeature GetSramecc() const {
|
||||
return sramecc_;
|
||||
}
|
||||
|
||||
/// @returns XNACK feature status.
|
||||
const IsaFeature &xnack() const {
|
||||
IsaFeature GetXnack() const {
|
||||
return xnack_;
|
||||
}
|
||||
|
||||
/// @returns This Isa's supported wavefront.
|
||||
const Wavefront &wavefront() const {
|
||||
const Wavefront &GetWavefront() const {
|
||||
return wavefront_;
|
||||
}
|
||||
|
||||
@@ -135,43 +140,26 @@ class Isa final: public amd::hsa::common::Signed<0xB13594F2BD8F212D> {
|
||||
bool IsSrameccSupported() const {
|
||||
return sramecc_ != IsaFeature::Unsupported;
|
||||
}
|
||||
|
||||
/// @returns True if XNACK feature is supported, false otherwise.
|
||||
bool IsXnackSupported() const {
|
||||
return xnack_ != IsaFeature::Unsupported;
|
||||
}
|
||||
|
||||
/// @returns This Isa's architecture.
|
||||
std::string GetArchitecture() const {
|
||||
return "amdgcn";
|
||||
}
|
||||
/// @returns This Isa's vendor.
|
||||
std::string GetVendor() const {
|
||||
return "amd";
|
||||
}
|
||||
/// @returns This Isa's OS.
|
||||
std::string GetOS() const {
|
||||
return "amdhsa";
|
||||
}
|
||||
/// @returns This Isa's environment.
|
||||
std::string GetEnvironment() const {
|
||||
return "";
|
||||
}
|
||||
/// @returns This Isa's major version.
|
||||
int32_t GetMajorVersion() const {
|
||||
return std::get<0>(version_);
|
||||
}
|
||||
|
||||
/// @returns This Isa's minor version.
|
||||
int32_t GetMinorVersion() const {
|
||||
return std::get<1>(version_);
|
||||
}
|
||||
|
||||
/// @returns This Isa's stepping.
|
||||
int32_t GetStepping() const {
|
||||
return std::get<2>(version_);
|
||||
}
|
||||
/// @returns Pointer to this Isa's supported wavefront.
|
||||
const Wavefront *GetWavefront() const {
|
||||
return &wavefront_;
|
||||
}
|
||||
|
||||
/// @brief Isa is always in valid state.
|
||||
bool IsValid() const {
|
||||
@@ -179,10 +167,10 @@ class Isa final: public amd::hsa::common::Signed<0xB13594F2BD8F212D> {
|
||||
}
|
||||
|
||||
/// @returns This Isa's processor name.
|
||||
std::string GetName() const;
|
||||
std::string GetProcessorName() const;
|
||||
|
||||
/// @returns This Isa's full target triple and target ID name.
|
||||
std::string GetFullName() const;
|
||||
/// @returns This Isa's name consisting of the target triple and target ID.
|
||||
std::string GetIsaName() const;
|
||||
|
||||
/// @brief Query value of requested @p attribute and record it in @p value.
|
||||
bool GetInfo(const hsa_isa_info_t &attribute, void *value) const;
|
||||
@@ -227,6 +215,7 @@ class IsaRegistry final {
|
||||
public:
|
||||
/// @returns Isa for requested @p full_name, null pointer if not supported.
|
||||
static const Isa *GetIsa(const std::string &full_name);
|
||||
|
||||
/// @returns Isa for requested @p version, null pointer if not supported.
|
||||
static const Isa *GetIsa(const Isa::Version &version,
|
||||
IsaFeature sramecc = IsaFeature::Any,
|
||||
@@ -241,6 +230,7 @@ class IsaRegistry final {
|
||||
|
||||
/// @brief Default constructor - not available.
|
||||
IsaRegistry();
|
||||
|
||||
/// @brief Default destructor - not available.
|
||||
~IsaRegistry();
|
||||
|
||||
|
||||
@@ -146,7 +146,7 @@ hsa_status_t BlitSdma<RingIndexTy, HwIndexMonotonic, SizeToCountOffset, useGCR>:
|
||||
return HSA_STATUS_ERROR;
|
||||
}
|
||||
|
||||
if (agent_->isa()->version() == core::Isa::Version(7, 0, 1)) {
|
||||
if (agent_->isa()->GetVersion() == core::Isa::Version(7, 0, 1)) {
|
||||
platform_atomic_support_ = false;
|
||||
} else {
|
||||
const core::Runtime::LinkInfo& link = core::Runtime::runtime_singleton_->GetLinkInfo(
|
||||
|
||||
@@ -731,7 +731,7 @@ hsa_status_t GpuAgent::GetInfo(hsa_agent_info_t attribute, void* value) const {
|
||||
|
||||
switch (attribute_u) {
|
||||
case HSA_AGENT_INFO_NAME: {
|
||||
std::string name = isa_->GetName();
|
||||
std::string name = isa_->GetProcessorName();
|
||||
assert(name.size() <= hsa_name_size);
|
||||
std::memset(value, 0, hsa_name_size);
|
||||
char* temp = reinterpret_cast<char*>(value);
|
||||
|
||||
@@ -1659,10 +1659,9 @@ hsa_status_t hsa_isa_iterate_wavefronts(
|
||||
const Isa *isa_object = Isa::Object(isa);
|
||||
IS_VALID(isa_object);
|
||||
|
||||
const Wavefront *wavefront_object = isa_object->GetWavefront();
|
||||
assert(wavefront_object);
|
||||
const Wavefront &wavefront_object = isa_object->GetWavefront();
|
||||
|
||||
return callback(Wavefront::Handle(wavefront_object), data);
|
||||
return callback(Wavefront::Handle(&wavefront_object), data);
|
||||
CATCH;
|
||||
}
|
||||
|
||||
|
||||
@@ -72,32 +72,32 @@ bool Wavefront::GetInfo(
|
||||
/* static */
|
||||
bool Isa::IsCompatible(const Isa &code_object_isa,
|
||||
const Isa &agent_isa) {
|
||||
if (code_object_isa.version() != agent_isa.version())
|
||||
if (code_object_isa.GetVersion() != agent_isa.GetVersion())
|
||||
return false;
|
||||
|
||||
assert(code_object_isa.IsSrameccSupported() == agent_isa.IsSrameccSupported() && agent_isa.sramecc() != IsaFeature::Any);
|
||||
if ((code_object_isa.sramecc() == IsaFeature::Enabled ||
|
||||
code_object_isa.sramecc() == IsaFeature::Disabled) &&
|
||||
code_object_isa.sramecc() != agent_isa.sramecc())
|
||||
assert(code_object_isa.IsSrameccSupported() == agent_isa.IsSrameccSupported() && agent_isa.GetSramecc() != IsaFeature::Any);
|
||||
if ((code_object_isa.GetSramecc() == IsaFeature::Enabled ||
|
||||
code_object_isa.GetSramecc() == IsaFeature::Disabled) &&
|
||||
code_object_isa.GetSramecc() != agent_isa.GetSramecc())
|
||||
return false;
|
||||
|
||||
assert(code_object_isa.IsXnackSupported() == agent_isa.IsXnackSupported() && agent_isa.xnack() != IsaFeature::Any);
|
||||
if ((code_object_isa.xnack() == IsaFeature::Enabled ||
|
||||
code_object_isa.xnack() == IsaFeature::Disabled) &&
|
||||
code_object_isa.xnack() != agent_isa.xnack())
|
||||
assert(code_object_isa.IsXnackSupported() == agent_isa.IsXnackSupported() && agent_isa.GetXnack() != IsaFeature::Any);
|
||||
if ((code_object_isa.GetXnack() == IsaFeature::Enabled ||
|
||||
code_object_isa.GetXnack() == IsaFeature::Disabled) &&
|
||||
code_object_isa.GetXnack() != agent_isa.GetXnack())
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string Isa::GetName() const {
|
||||
std::string Isa::GetProcessorName() const {
|
||||
std::string processor(targetid_);
|
||||
return processor.substr(0, processor.find(':'));
|
||||
}
|
||||
|
||||
std::string Isa::GetFullName() const {
|
||||
return GetArchitecture() + '-' + GetVendor() + '-' + GetOS() + '-' + GetEnvironment() + '-' +
|
||||
targetid_;
|
||||
std::string Isa::GetIsaName() const {
|
||||
constexpr char hsa_isa_name_prefix[] = "amdgcn-amd-amdhsa--";
|
||||
return std::string(hsa_isa_name_prefix) + targetid_;
|
||||
}
|
||||
|
||||
bool Isa::GetInfo(const hsa_isa_info_t &attribute, void *value) const {
|
||||
@@ -107,14 +107,14 @@ bool Isa::GetInfo(const hsa_isa_info_t &attribute, void *value) const {
|
||||
|
||||
switch (attribute) {
|
||||
case HSA_ISA_INFO_NAME_LENGTH: {
|
||||
std::string full_name = GetFullName();
|
||||
*((uint32_t*)value) = static_cast<uint32_t>(full_name.size() + 1);
|
||||
std::string isa_name = GetIsaName();
|
||||
*((uint32_t*)value) = static_cast<uint32_t>(isa_name.size() + 1);
|
||||
return true;
|
||||
}
|
||||
case HSA_ISA_INFO_NAME: {
|
||||
std::string full_name = GetFullName();
|
||||
memset(value, 0x0, full_name.size() + 1);
|
||||
memcpy(value, full_name.c_str(), full_name.size());
|
||||
std::string isa_name = GetIsaName();
|
||||
memset(value, 0x0, isa_name.size() + 1);
|
||||
memcpy(value, isa_name.c_str(), isa_name.size());
|
||||
return true;
|
||||
}
|
||||
// deprecated.
|
||||
@@ -139,8 +139,8 @@ bool Isa::GetInfo(const hsa_isa_info_t &attribute, void *value) const {
|
||||
}
|
||||
case HSA_ISA_INFO_PROFILES: {
|
||||
bool profiles[2] = {true, false};
|
||||
if (this->version() == Version(7, 0, 0) ||
|
||||
this->version() == Version(8, 0, 1)) {
|
||||
if (this->GetVersion() == Version(7, 0, 0) ||
|
||||
this->GetVersion() == Version(8, 0, 1)) {
|
||||
profiles[1] = true;
|
||||
}
|
||||
memcpy(value, profiles, sizeof(profiles));
|
||||
@@ -206,8 +206,8 @@ const Isa *IsaRegistry::GetIsa(const std::string &full_name) {
|
||||
const Isa *IsaRegistry::GetIsa(const Isa::Version &version, IsaFeature sramecc, IsaFeature xnack) {
|
||||
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.second.GetVersion() == version && isareg.second.GetSramecc() == sramecc &&
|
||||
isareg.second.GetXnack() == xnack;
|
||||
});
|
||||
return isareg_iter == supported_isas_.end() ? nullptr : &isareg_iter->second;
|
||||
}
|
||||
@@ -229,7 +229,7 @@ constexpr size_t hsa_name_size = 63;
|
||||
amd_amdgpu_##maj##min##stp##_SRAMECC_##sramecc##_XNACK_##xnack.sramecc_ = sramecc; \
|
||||
amd_amdgpu_##maj##min##stp##_SRAMECC_##sramecc##_XNACK_##xnack.xnack_ = xnack; \
|
||||
supported_isas.insert(std::make_pair( \
|
||||
amd_amdgpu_##maj##min##stp##_SRAMECC_##sramecc##_XNACK_##xnack.GetFullName(), \
|
||||
amd_amdgpu_##maj##min##stp##_SRAMECC_##sramecc##_XNACK_##xnack.GetIsaName(), \
|
||||
amd_amdgpu_##maj##min##stp##_SRAMECC_##sramecc##_XNACK_##xnack)); \
|
||||
|
||||
IsaMap supported_isas;
|
||||
|
||||
Reference in New Issue
Block a user