rocr: Generic ISA targets support

Change-Id: I6a0341ec9c1ec1e710143676b80a8a3c1a78f725


[ROCm/ROCR-Runtime commit: 0c18ff22e1]
This commit is contained in:
Chris Freehill
2024-10-17 16:36:40 -05:00
parent dd037425ed
commit 8fe7c40390
17 changed files with 369 additions and 203 deletions
@@ -236,6 +236,18 @@ class Agent : public Checked<0xF6BC25EB17E6F917> {
hsa_status_t (*callback)(hsa_region_t region, void* data),
void* data) const = 0;
// @brief Invoke the user provided callback for each isa supported by
// this agent.
//
// @param [in] callback User provided callback function.
// @param [in] data User provided pointer as input for @p callback.
//
// @retval ::HSA_STATUS_SUCCESS if the callback function for each traversed
// isa returns ::HSA_STATUS_SUCCESS.
virtual hsa_status_t IterateSupportedIsas(
hsa_status_t (*callback)(hsa_isa_t isa, void* data),
void* data) const = 0;
// @brief Invoke the callback for each cache useable by this agent.
virtual hsa_status_t IterateCache(hsa_status_t (*callback)(hsa_cache_t cache, void* data),
void* data) const = 0;
@@ -278,8 +290,11 @@ class Agent : public Checked<0xF6BC25EB17E6F917> {
// @brief Returns an array of regions owned by the agent.
virtual const std::vector<const core::MemoryRegion*>& regions() const = 0;
// @details Returns the agent's instruction set architecture.
virtual const Isa* isa() const = 0;
// @brief Returns the ISA's supported by the agent.
// @details The returned vector is a list of pointers to the supported ISA,
// ordered from most specific (and performant) to most generic. For CPU
// and AIE agents, this list will be empty.
virtual const std::vector<const core::Isa *>& supported_isas() const = 0;
virtual uint64_t HiveId() const { return 0; }
@@ -343,6 +358,7 @@ protected:
}
hsa_agent_t public_handle_;
std::vector<const core::Isa *> supported_isas_;
private:
// @brief Node id.
@@ -72,6 +72,10 @@ public:
void *data),
void *value) const override;
hsa_status_t IterateSupportedIsas(
hsa_status_t (*callback)(hsa_isa_t isa, void* data),
void* data) const override;
hsa_status_t GetInfo(hsa_agent_info_t attribute, void *value) const override;
hsa_status_t QueueCreate(size_t size, hsa_queue_type32_t queue_type,
@@ -80,7 +84,10 @@ public:
uint32_t group_segment_size,
core::Queue **queue) override;
const core::Isa *isa() const override { return nullptr; }
// @brief Override from core::Agent.
const std::vector<const core::Isa*>& supported_isas() const override {
return supported_isas_;
}
const std::vector<const core::MemoryRegion *> &regions() const override {
return regions_;
@@ -90,6 +90,10 @@ class CpuAgent : public core::Agent {
void* data),
void* data) const override;
hsa_status_t IterateSupportedIsas(
hsa_status_t (*callback)(hsa_isa_t isa, void* data),
void* data) const override;
// @brief Override from core::Agent.
hsa_status_t IterateCache(hsa_status_t (*callback)(hsa_cache_t cache, void* data),
void* value) const override;
@@ -127,9 +131,10 @@ class CpuAgent : public core::Agent {
return regions_;
}
// @brief OVerride from core::Agent.
const core::Isa* isa() const override { return NULL; }
// @brief Override from core::Agent.
const std::vector<const core::Isa*>& supported_isas() const override {
return supported_isas_;
}
private:
// @brief Query the driver to get the region list owned by this agent.
void InitRegionList();
@@ -275,6 +275,10 @@ class GpuAgent : public GpuAgentInt {
void* data),
void* data) const override;
hsa_status_t IterateSupportedIsas(
hsa_status_t (*callback)(hsa_isa_t isa, void* data),
void* data) const override;
// @brief Override from core::Agent.
hsa_status_t IterateCache(hsa_status_t (*callback)(hsa_cache_t cache, void* data),
void* value) const override;
@@ -381,8 +385,8 @@ class GpuAgent : public GpuAgentInt {
return regions_;
}
// @brief Override from core::Agent.
const core::Isa* isa() const override { return isa_; }
const std::vector<const core::Isa *>& supported_isas() const override {
return supported_isas_;}
// @brief Override from AMD::GpuAgentInt.
__forceinline bool is_kv_device() const override { return is_kv_device_; }
@@ -432,7 +436,8 @@ class GpuAgent : public GpuAgentInt {
__forceinline bool AsyncScratchReclaimEnabled() const override {
// TODO: Need to update min CP FW ucode version once it is released
return (core::Runtime::runtime_singleton_->flag().enable_scratch_async_reclaim() &&
isa()->GetMajorVersion() == 9 && isa()->GetMinorVersion() == 4 &&
supported_isas()[0]->GetMajorVersion() == 9 &&
supported_isas()[0]->GetMinorVersion() == 4 &&
properties_.EngineId.ui32.uCode > 999);
};
@@ -163,11 +163,7 @@ public:
virtual hsa_isa_t IsaFromName(const char *name) = 0;
// This function will be deleted in a future patch. Use the overload
// that takes a generic version instead.
virtual bool IsaSupportedByAgent(hsa_agent_t agent, hsa_isa_t isa) = 0;
virtual bool IsaSupportedByAgent(hsa_agent_t agent, hsa_isa_t isa, unsigned genericVersion) { return IsaSupportedByAgent(agent, isa); }
virtual bool IsaSupportedByAgent(hsa_agent_t agent, hsa_isa_t isa, unsigned genericVersion) = 0;
virtual void* SegmentAlloc(amdgpu_hsa_elf_segment_t segment, hsa_agent_t agent, size_t size, size_t align, bool zero) = 0;
@@ -56,7 +56,7 @@ class LoaderContext final : public rocr::amd::hsa::loader::Context {
hsa_isa_t IsaFromName(const char *name) override;
bool IsaSupportedByAgent(hsa_agent_t agent, hsa_isa_t code_object_isa) override;
bool IsaSupportedByAgent(hsa_agent_t agent, hsa_isa_t code_object_isa, unsigned codeGenericVersion) override;
void* SegmentAlloc(amdgpu_hsa_elf_segment_t segment, hsa_agent_t agent, size_t size, size_t align, bool zero) override;
@@ -117,12 +117,16 @@ class Isa final: public amd::hsa::common::Signed<0xB13594F2BD8F212D> {
/// @returns True if @p code_object_isa and @p agent_isa are compatible,
/// false otherwise.
static bool IsCompatible(const Isa &code_object_isa, const Isa &agent_isa);
static bool IsCompatible(const Isa &code_object_isa,
const Isa &agent_isa, unsigned int codeGenericVersion);
/// @returns This Isa's version.
const Version &GetVersion() const {
return version_;
}
/// @returns This Isa's generic target.
const std::string & GetIsaGeneric() const {return generic_;}
/// @returns SRAM ECC feature status.
IsaFeature GetSramecc() const {
@@ -188,13 +192,15 @@ class Isa final: public amd::hsa::common::Signed<0xB13594F2BD8F212D> {
private:
/// @brief Default constructor.
Isa()
: targetid_(nullptr),
version_(Version(-1, -1, -1)),
: version_(Version(-1, -1, -1)),
sramecc_(IsaFeature::Unsupported),
xnack_(IsaFeature::Unsupported) {}
// @brief Isa's target ID name.
const char* targetid_;
std::string targetid_;
// @brief Isa's generic version, if it exists. "" otherwise.
std::string generic_;
/// @brief Isa's version.
Version version_;
@@ -223,7 +229,8 @@ class IsaRegistry final {
static const Isa *GetIsa(const Isa::Version &version,
IsaFeature sramecc = IsaFeature::Any,
IsaFeature xnack = IsaFeature::Any);
static const std::unordered_map<std::string, unsigned int> &
GetSupportedGenericVersions();
private:
/// @brief IsaRegistry's map type.
typedef std::unordered_map<std::string, std::reference_wrapper<const Isa>> IsaMap;