ROCm Runtime Support for respecting target xnack setting
This includes the changes provided by Konstantin, "Add xnack from elf header" (Change 136389).
Change-Id: I95e51141caa0d7c21903b09212c02e4906ec54a3
[ROCm/ROCR-Runtime commit: 8e3d26c617]
Этот коммит содержится в:
коммит произвёл
Wing-Ki Chau(Wilkin)
родитель
544b3a88ec
Коммит
c7af4e8857
@@ -207,6 +207,7 @@ namespace amd {
|
||||
|
||||
virtual uint16_t Machine() = 0;
|
||||
virtual uint16_t Type() = 0;
|
||||
virtual uint32_t EFlags() = 0;
|
||||
|
||||
std::string output() { return out.str(); }
|
||||
|
||||
|
||||
@@ -267,6 +267,7 @@ namespace code {
|
||||
const amd::elf::Section* HsaText() const { assert(hsatext); return hsatext; }
|
||||
amd::elf::SymbolTable* Symtab() { assert(img); return img->symtab(); }
|
||||
uint16_t Machine() const { return img->Machine(); }
|
||||
uint32_t EFlags() const { return img->EFlags(); }
|
||||
|
||||
AmdHsaCode(bool combineDataSegments = true);
|
||||
virtual ~AmdHsaCode();
|
||||
|
||||
@@ -168,14 +168,20 @@ class Isa final: public amd::hsa::common::Signed<0xB13594F2BD8F212D> {
|
||||
|
||||
private:
|
||||
/// @brief Default constructor.
|
||||
Isa(): version_(Version(-1, -1, -1)) {}
|
||||
Isa(): version_(Version(-1, -1, -1)), xnackEnabled_(false) {}
|
||||
|
||||
/// @brief Construct from @p version.
|
||||
Isa(const Version &version): version_(version) {}
|
||||
Isa(const Version &version): version_(version), xnackEnabled_(false) {}
|
||||
|
||||
/// @brief Construct from @p version.
|
||||
Isa(const Version &version, const bool xnack): version_(version), xnackEnabled_(xnack) {}
|
||||
|
||||
/// @brief Isa's version.
|
||||
Version version_;
|
||||
|
||||
/// @brief Isa's supported xnack flag.
|
||||
bool xnackEnabled_;
|
||||
|
||||
/// @brief Isa's supported wavefront.
|
||||
Wavefront wavefront_;
|
||||
|
||||
@@ -190,7 +196,7 @@ class IsaRegistry final {
|
||||
/// @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);
|
||||
static const Isa *GetIsa(const Isa::Version &version, bool xnack);
|
||||
|
||||
private:
|
||||
/// @brief IsaRegistry's map type.
|
||||
|
||||
@@ -96,7 +96,7 @@ GpuAgent::GpuAgent(HSAuint32 node, const HsaNodeProperties& node_props)
|
||||
// Set instruction set architecture via node property, only on GPU device.
|
||||
isa_ = (core::Isa*)core::IsaRegistry::GetIsa(core::Isa::Version(
|
||||
node_props.EngineId.ui32.Major, node_props.EngineId.ui32.Minor,
|
||||
node_props.EngineId.ui32.Stepping));
|
||||
node_props.EngineId.ui32.Stepping), profile_ == HSA_PROFILE_FULL);
|
||||
|
||||
// Check if the device is Kaveri, only on GPU device.
|
||||
if (isa_->GetMajorVersion() == 7 && isa_->GetMinorVersion() == 0 &&
|
||||
|
||||
@@ -70,6 +70,11 @@ std::string Isa::GetFullName() const {
|
||||
full_name << GetVendor() << ":" << GetArchitecture() << ":"
|
||||
<< GetMajorVersion() << ":" << GetMinorVersion() << ":"
|
||||
<< GetStepping();
|
||||
|
||||
if (xnackEnabled_) {
|
||||
full_name << "-xnack";
|
||||
}
|
||||
|
||||
return full_name.str();
|
||||
}
|
||||
|
||||
@@ -176,8 +181,8 @@ const Isa *IsaRegistry::GetIsa(const std::string &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());
|
||||
const Isa *IsaRegistry::GetIsa(const Isa::Version &version, bool xnack) {
|
||||
auto isareg_iter = supported_isas_.find(Isa(version, xnack).GetFullName());
|
||||
return isareg_iter == supported_isas_.end() ? nullptr : &isareg_iter->second;
|
||||
}
|
||||
|
||||
@@ -185,29 +190,30 @@ const IsaRegistry::IsaMap IsaRegistry::supported_isas_ =
|
||||
IsaRegistry::GetSupportedIsas();
|
||||
|
||||
const IsaRegistry::IsaMap IsaRegistry::GetSupportedIsas() {
|
||||
#define ISAREG_ENTRY_GEN(maj, min, stp) \
|
||||
#define ISAREG_ENTRY_GEN(maj, min, stp, xnack) \
|
||||
Isa amd_amdgpu_##maj##min##stp; \
|
||||
amd_amdgpu_##maj##min##stp.version_ = Isa::Version(maj, min, stp); \
|
||||
amd_amdgpu_##maj##min##stp.xnackEnabled_ = xnack; \
|
||||
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(7, 0, 2)
|
||||
ISAREG_ENTRY_GEN(8, 0, 1)
|
||||
ISAREG_ENTRY_GEN(8, 0, 2)
|
||||
ISAREG_ENTRY_GEN(8, 0, 3)
|
||||
ISAREG_ENTRY_GEN(9, 0, 0)
|
||||
ISAREG_ENTRY_GEN(9, 0, 1)
|
||||
ISAREG_ENTRY_GEN(9, 0, 2)
|
||||
ISAREG_ENTRY_GEN(9, 0, 3)
|
||||
ISAREG_ENTRY_GEN(9, 0, 4)
|
||||
ISAREG_ENTRY_GEN(9, 0, 5)
|
||||
ISAREG_ENTRY_GEN(9, 0, 6)
|
||||
ISAREG_ENTRY_GEN(9, 0, 7)
|
||||
ISAREG_ENTRY_GEN(7, 0, 0, false)
|
||||
ISAREG_ENTRY_GEN(7, 0, 1, false)
|
||||
ISAREG_ENTRY_GEN(7, 0, 2, false)
|
||||
ISAREG_ENTRY_GEN(8, 0, 1, true)
|
||||
ISAREG_ENTRY_GEN(8, 0, 2, false)
|
||||
ISAREG_ENTRY_GEN(8, 0, 3, false)
|
||||
ISAREG_ENTRY_GEN(9, 0, 0, false)
|
||||
ISAREG_ENTRY_GEN(9, 0, 1, false)
|
||||
ISAREG_ENTRY_GEN(9, 0, 2, true)
|
||||
ISAREG_ENTRY_GEN(9, 0, 3, false)
|
||||
ISAREG_ENTRY_GEN(9, 0, 4, false)
|
||||
ISAREG_ENTRY_GEN(9, 0, 5, false)
|
||||
ISAREG_ENTRY_GEN(9, 0, 6, false)
|
||||
ISAREG_ENTRY_GEN(9, 0, 7, false)
|
||||
|
||||
return supported_isas;
|
||||
}
|
||||
|
||||
@@ -52,6 +52,10 @@
|
||||
#define EF_AMDGPU_XNACK 0x00000001
|
||||
#define EF_AMDGPU_TRAP_HANDLER 0x00000002
|
||||
|
||||
// FIXME: We really need to start thinking about separating legacy code out,
|
||||
// it is getting messy.
|
||||
#define EF_AMDGPU_XNACK_LC 0x100
|
||||
|
||||
// ELF Section Header Flag Enumeration Values.
|
||||
#define SHF_AMDGPU_HSA_GLOBAL (0x00100000 & SHF_MASKOS)
|
||||
#define SHF_AMDGPU_HSA_READONLY (0x00200000 & SHF_MASKOS)
|
||||
|
||||
@@ -703,6 +703,7 @@ namespace amd {
|
||||
|
||||
uint16_t Machine() override { return ehdr.e_machine; }
|
||||
uint16_t Type() override { return ehdr.e_type; }
|
||||
uint32_t EFlags() override{ return ehdr.e_flags; }
|
||||
|
||||
GElfStringTable* shstrtab() override;
|
||||
GElfStringTable* strtab() override;
|
||||
|
||||
@@ -1110,9 +1110,6 @@ hsa_status_t ExecutableImpl::LoadCodeObject(
|
||||
std::string codeIsa;
|
||||
if (!code->GetNoteIsa(codeIsa)) { return HSA_STATUS_ERROR_INVALID_CODE_OBJECT; }
|
||||
|
||||
hsa_isa_t objectsIsa = context_->IsaFromName(codeIsa.c_str());
|
||||
if (!objectsIsa.handle) { return HSA_STATUS_ERROR_INVALID_ISA_NAME; }
|
||||
|
||||
uint32_t majorVersion, minorVersion;
|
||||
if (!code->GetNoteCodeObjectVersion(&majorVersion, &minorVersion)) {
|
||||
return HSA_STATUS_ERROR_INVALID_CODE_OBJECT;
|
||||
@@ -1120,6 +1117,13 @@ hsa_status_t ExecutableImpl::LoadCodeObject(
|
||||
|
||||
if (majorVersion != 1 && majorVersion != 2) { return HSA_STATUS_ERROR_INVALID_CODE_OBJECT; }
|
||||
if (agent.handle == 0 && majorVersion == 1) { return HSA_STATUS_ERROR_INVALID_AGENT; }
|
||||
|
||||
if (majorVersion == 2 && (code->EFlags() & EF_AMDGPU_XNACK_LC))
|
||||
codeIsa = codeIsa + "-xnack";
|
||||
|
||||
hsa_isa_t objectsIsa = context_->IsaFromName(codeIsa.c_str());
|
||||
if (!objectsIsa.handle) { return HSA_STATUS_ERROR_INVALID_ISA_NAME; }
|
||||
|
||||
if (agent.handle != 0 && !context_->IsaSupportedByAgent(agent, objectsIsa)) { return HSA_STATUS_ERROR_INCOMPATIBLE_ARGUMENTS; }
|
||||
|
||||
uint32_t codeHsailMajor;
|
||||
|
||||
Ссылка в новой задаче
Block a user