[NFC] Cosmetic improvements:
- Doxygenify comments - Match order of implementation with order of declaration Change-Id: I3c7e486c4dd3616f4b10b2f3e69532a4b5fb9e8e
This commit is contained in:
@@ -52,113 +52,115 @@
|
||||
|
||||
namespace core {
|
||||
|
||||
// @class Isa
|
||||
// @brief Instruction Set Architecture
|
||||
/// @class Isa.
|
||||
/// @brief Instruction Set Architecture.
|
||||
class Isa final: public amd::hsa::common::Signed<0xB13594F2BD8F212D> {
|
||||
public:
|
||||
// @brief Isa's version type
|
||||
/// @brief Isa's version type.
|
||||
typedef std::tuple<int32_t, int32_t, int32_t> Version;
|
||||
|
||||
// @brief Default destructor
|
||||
/// @brief Default destructor.
|
||||
~Isa() {}
|
||||
|
||||
// @returns Handle equivalent of @p isa_object
|
||||
/// @returns Handle equivalent of @p isa_object.
|
||||
static hsa_isa_t Handle(const Isa *isa_object) {
|
||||
hsa_isa_t isa_handle = { reinterpret_cast<uint64_t>(isa_object) };
|
||||
return isa_handle;
|
||||
}
|
||||
// @returns Object equivalend of @p isa_handle
|
||||
/// @returns Object equivalend of @p isa_handle.
|
||||
static Isa *Object(const hsa_isa_t &isa_handle) {
|
||||
Isa *isa_object = amd::hsa::common::ObjectAt<Isa>(isa_handle.handle);
|
||||
return isa_object;
|
||||
}
|
||||
|
||||
// @returns This Isa's version
|
||||
/// @returns This Isa's version.
|
||||
const Version &version() const {
|
||||
return version_;
|
||||
}
|
||||
|
||||
// @returns This Isa's vendor
|
||||
/// @returns This Isa's vendor.
|
||||
std::string GetVendor() const {
|
||||
return "AMD";
|
||||
}
|
||||
// @returns This Isa's architecture
|
||||
/// @returns This Isa's architecture.
|
||||
std::string GetArchitecture() const {
|
||||
return "AMDGPU";
|
||||
}
|
||||
// @returns This Isa's major version
|
||||
/// @returns This Isa's major version.
|
||||
int32_t GetMajorVersion() const {
|
||||
return std::get<0>(version_);
|
||||
}
|
||||
// @returns This Isa's minor version
|
||||
/// @returns This Isa's minor version.
|
||||
int32_t GetMinorVersion() const {
|
||||
return std::get<1>(version_);
|
||||
}
|
||||
// @returns This Isa's stepping
|
||||
/// @returns This Isa's stepping.
|
||||
int32_t GetStepping() const {
|
||||
return std::get<2>(version_);
|
||||
}
|
||||
|
||||
// @returns True if this Isa is compatible with @p isa_object, false otherwise
|
||||
/// @returns True if this Isa is compatible with @p isa_object, false
|
||||
/// otherwise.
|
||||
bool IsCompatible(const Isa *isa_object) const {
|
||||
assert(isa_object);
|
||||
return version_ == isa_object->version_;
|
||||
}
|
||||
// @returns True if this Isa is compatible with @p isa_handle, false otherwise
|
||||
/// @returns True if this Isa is compatible with @p isa_handle, false
|
||||
/// otherwise.
|
||||
bool IsCompatible(const hsa_isa_t &isa_handle) const {
|
||||
assert(isa_handle.handle);
|
||||
return IsCompatible(Object(isa_handle));
|
||||
}
|
||||
// @brief Isa is always in valid state
|
||||
/// @brief Isa is always in valid state.
|
||||
bool IsValid() const {
|
||||
return true;
|
||||
}
|
||||
|
||||
// @returns This Isa's full name
|
||||
/// @returns This Isa's full name.
|
||||
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.
|
||||
bool GetInfo(const hsa_isa_info_t &attribute, void *value) const;
|
||||
|
||||
private:
|
||||
// @brief Default constructor
|
||||
/// @brief Default constructor.
|
||||
Isa(): version_(Version(-1, -1, -1)) {}
|
||||
|
||||
// @brief Construct from @p version
|
||||
/// @brief Construct from @p version.
|
||||
Isa(const Version &version): version_(version) {}
|
||||
|
||||
// @brief Isa's version
|
||||
/// @brief Isa's version.
|
||||
Version version_;
|
||||
|
||||
// @brief Isa's friends
|
||||
/// @brief Isa's friends.
|
||||
friend class IsaRegistry;
|
||||
}; // class Isa
|
||||
}; // class Isa
|
||||
|
||||
// @class IsaRegistry
|
||||
// @brief Instruction Set Architecture Registry
|
||||
/// @class IsaRegistry.
|
||||
/// @brief Instruction Set Architecture Registry.
|
||||
class IsaRegistry final {
|
||||
public:
|
||||
// @returns Isa for requested @p full_name, null pointer if not supported
|
||||
/// @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
|
||||
/// @returns Isa for requested @p version, null pointer if not supported.
|
||||
static const Isa *GetIsa(const Isa::Version &version);
|
||||
|
||||
private:
|
||||
// @brief IsaRegistry's map type
|
||||
/// @brief IsaRegistry's map type.
|
||||
typedef std::unordered_map<std::string, Isa> IsaMap;
|
||||
|
||||
// @brief Supported instruction set architectures
|
||||
/// @brief Supported instruction set architectures.
|
||||
static const IsaMap supported_isas_;
|
||||
|
||||
// @brief Default constructor - not available
|
||||
/// @brief Default constructor - not available.
|
||||
IsaRegistry();
|
||||
// @brief Default destructor - not available
|
||||
/// @brief Default destructor - not available.
|
||||
~IsaRegistry();
|
||||
|
||||
// @returns Supported instruction set architectures
|
||||
/// @returns Supported instruction set architectures.
|
||||
static const IsaMap GetSupportedIsas();
|
||||
}; // class IsaRegistry
|
||||
}; // class IsaRegistry
|
||||
|
||||
} // namespace core
|
||||
} // namespace core
|
||||
|
||||
#endif // HSA_RUNTIME_CORE_ISA_HPP_
|
||||
#endif // HSA_RUNTIME_CORE_ISA_HPP_
|
||||
|
||||
@@ -47,41 +47,6 @@
|
||||
|
||||
namespace core {
|
||||
|
||||
const IsaRegistry::IsaMap IsaRegistry::supported_isas_ =
|
||||
IsaRegistry::GetSupportedIsas();
|
||||
|
||||
const Isa *IsaRegistry::GetIsa(const std::string &full_name) {
|
||||
auto isareg_iter = supported_isas_.find(full_name);
|
||||
return isareg_iter == supported_isas_.end() ? nullptr : &isareg_iter->second;
|
||||
}
|
||||
|
||||
const Isa *IsaRegistry::GetIsa(const Isa::Version &version) {
|
||||
auto isareg_iter = supported_isas_.find(Isa(version).GetFullName());
|
||||
return isareg_iter == supported_isas_.end() ? nullptr : &isareg_iter->second;
|
||||
}
|
||||
|
||||
const IsaRegistry::IsaMap IsaRegistry::GetSupportedIsas() {
|
||||
#define ISAREG_ENTRY_GEN(maj, min, stp) \
|
||||
Isa amd_amdgpu_##maj##min##stp; \
|
||||
amd_amdgpu_##maj##min##stp.version_ = Isa::Version(maj, min, stp); \
|
||||
supported_isas.insert( \
|
||||
std::make_pair( \
|
||||
amd_amdgpu_##maj##min##stp.GetFullName(), amd_amdgpu_##maj##min##stp)); \
|
||||
|
||||
IsaMap supported_isas;
|
||||
|
||||
ISAREG_ENTRY_GEN(7, 0, 0)
|
||||
ISAREG_ENTRY_GEN(7, 0, 1)
|
||||
ISAREG_ENTRY_GEN(8, 0, 0)
|
||||
ISAREG_ENTRY_GEN(8, 0, 1)
|
||||
ISAREG_ENTRY_GEN(8, 0, 2)
|
||||
ISAREG_ENTRY_GEN(8, 0, 3)
|
||||
ISAREG_ENTRY_GEN(8, 1, 0)
|
||||
ISAREG_ENTRY_GEN(9, 0, 0)
|
||||
|
||||
return supported_isas;
|
||||
}
|
||||
|
||||
std::string Isa::GetFullName() const {
|
||||
std::stringstream full_name;
|
||||
full_name << GetVendor() << ":" << GetArchitecture() << ":"
|
||||
@@ -106,17 +71,17 @@ bool Isa::GetInfo(const hsa_isa_info_t &attribute, void *value) const {
|
||||
memcpy(value, full_name.c_str(), full_name.size());
|
||||
return true;
|
||||
}
|
||||
// @todo: following case needs to be removed
|
||||
// @todo: following case needs to be removed.
|
||||
case HSA_ISA_INFO_CALL_CONVENTION_COUNT: {
|
||||
*((uint32_t *)value) = 1;
|
||||
return true;
|
||||
}
|
||||
// @todo: following case needs to be removed
|
||||
// @todo: following case needs to be removed.
|
||||
case HSA_ISA_INFO_CALL_CONVENTION_INFO_WAVEFRONT_SIZE: {
|
||||
*((uint32_t *)value) = 64;
|
||||
return true;
|
||||
}
|
||||
// @todo: following needs to be removed
|
||||
// @todo: following needs to be removed.
|
||||
case HSA_ISA_INFO_CALL_CONVENTION_INFO_WAVEFRONTS_PER_COMPUTE_UNIT: {
|
||||
*((uint32_t *)value) = 40;
|
||||
return true;
|
||||
@@ -127,4 +92,39 @@ bool Isa::GetInfo(const hsa_isa_info_t &attribute, void *value) const {
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace core
|
||||
const Isa *IsaRegistry::GetIsa(const std::string &full_name) {
|
||||
auto isareg_iter = supported_isas_.find(full_name);
|
||||
return isareg_iter == supported_isas_.end() ? nullptr : &isareg_iter->second;
|
||||
}
|
||||
|
||||
const Isa *IsaRegistry::GetIsa(const Isa::Version &version) {
|
||||
auto isareg_iter = supported_isas_.find(Isa(version).GetFullName());
|
||||
return isareg_iter == supported_isas_.end() ? nullptr : &isareg_iter->second;
|
||||
}
|
||||
|
||||
const IsaRegistry::IsaMap IsaRegistry::supported_isas_ =
|
||||
IsaRegistry::GetSupportedIsas();
|
||||
|
||||
const IsaRegistry::IsaMap IsaRegistry::GetSupportedIsas() {
|
||||
#define ISAREG_ENTRY_GEN(maj, min, stp) \
|
||||
Isa amd_amdgpu_##maj##min##stp; \
|
||||
amd_amdgpu_##maj##min##stp.version_ = Isa::Version(maj, min, stp); \
|
||||
supported_isas.insert( \
|
||||
std::make_pair( \
|
||||
amd_amdgpu_##maj##min##stp.GetFullName(), amd_amdgpu_##maj##min##stp)); \
|
||||
|
||||
IsaMap supported_isas;
|
||||
|
||||
ISAREG_ENTRY_GEN(7, 0, 0)
|
||||
ISAREG_ENTRY_GEN(7, 0, 1)
|
||||
ISAREG_ENTRY_GEN(8, 0, 0)
|
||||
ISAREG_ENTRY_GEN(8, 0, 1)
|
||||
ISAREG_ENTRY_GEN(8, 0, 2)
|
||||
ISAREG_ENTRY_GEN(8, 0, 3)
|
||||
ISAREG_ENTRY_GEN(8, 1, 0)
|
||||
ISAREG_ENTRY_GEN(9, 0, 0)
|
||||
|
||||
return supported_isas;
|
||||
}
|
||||
|
||||
} // namespace core
|
||||
|
||||
Reference in New Issue
Block a user