-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[Offload][AMDGPU] accept generic target #118919
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -190,8 +190,8 @@ Error asyncMemCopy(bool UseMultipleSdmaEngines, void *Dst, hsa_agent_t DstAgent, | |
#endif | ||
} | ||
|
||
Expected<std::string> getTargetTripleAndFeatures(hsa_agent_t Agent) { | ||
std::string Target; | ||
Error getTargetTripleAndFeatures(hsa_agent_t Agent, | ||
SmallVector<SmallString<32>> &Targets) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't see too much point of using There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. then 32 is sufficient here |
||
auto Err = hsa_utils::iterateAgentISAs(Agent, [&](hsa_isa_t ISA) { | ||
uint32_t Length; | ||
hsa_status_t Status; | ||
|
@@ -205,13 +205,13 @@ Expected<std::string> getTargetTripleAndFeatures(hsa_agent_t Agent) { | |
return Status; | ||
|
||
llvm::StringRef TripleTarget(ISAName.begin(), Length); | ||
if (TripleTarget.consume_front("amdgcn-amd-amdhsa")) | ||
Target = TripleTarget.ltrim('-').rtrim('\0').str(); | ||
return HSA_STATUS_INFO_BREAK; | ||
if (TripleTarget.consume_front("amdgcn-amd-amdhsa")) { | ||
auto Target = TripleTarget.ltrim('-').rtrim('\0'); | ||
Targets.push_back(Target); | ||
hidekisaito marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
return HSA_STATUS_SUCCESS; | ||
}); | ||
if (Err) | ||
return Err; | ||
return Target; | ||
return Err; | ||
} | ||
} // namespace hsa_utils | ||
|
||
|
@@ -1988,12 +1988,10 @@ struct AMDGPUDeviceTy : public GenericDeviceTy, AMDGenericDeviceTy { | |
return Err; | ||
|
||
// Detect if XNACK is enabled | ||
auto TargeTripleAndFeaturesOrError = | ||
hsa_utils::getTargetTripleAndFeatures(Agent); | ||
if (!TargeTripleAndFeaturesOrError) | ||
return TargeTripleAndFeaturesOrError.takeError(); | ||
if (static_cast<StringRef>(*TargeTripleAndFeaturesOrError) | ||
.contains("xnack+")) | ||
SmallVector<SmallString<32>> Targets; | ||
if (auto Err = hsa_utils::getTargetTripleAndFeatures(Agent, Targets)) | ||
return Err; | ||
if (!Targets.empty() && Targets[0].str().contains("xnack+")) | ||
IsXnackEnabled = true; | ||
|
||
// detect if device is an APU. | ||
|
@@ -3207,13 +3205,16 @@ struct AMDGPUPluginTy final : public GenericPluginTy { | |
if (!Processor) | ||
return false; | ||
|
||
auto TargeTripleAndFeaturesOrError = | ||
hsa_utils::getTargetTripleAndFeatures(getKernelAgent(DeviceId)); | ||
if (!TargeTripleAndFeaturesOrError) | ||
return TargeTripleAndFeaturesOrError.takeError(); | ||
return offloading::amdgpu::isImageCompatibleWithEnv( | ||
Processor ? *Processor : "", ElfOrErr->getPlatformFlags(), | ||
*TargeTripleAndFeaturesOrError); | ||
SmallVector<SmallString<32>> Targets; | ||
if (auto Err = hsa_utils::getTargetTripleAndFeatures( | ||
getKernelAgent(DeviceId), Targets)) | ||
return Err; | ||
for (auto &Target : Targets) | ||
if (offloading::amdgpu::isImageCompatibleWithEnv( | ||
Processor ? *Processor : "", ElfOrErr->getPlatformFlags(), | ||
Target.str())) | ||
return true; | ||
return false; | ||
} | ||
|
||
bool isDataExchangable(int32_t SrcDeviceId, int32_t DstDeviceId) override { | ||
|
Uh oh!
There was an error while loading. Please reload this page.