@@ -406,8 +406,8 @@ Error asyncMemCopy(bool UseMultipleSdmaEngines, void *Dst, hsa_agent_t DstAgent,
406
406
#endif
407
407
}
408
408
409
- Expected<std::string> getTargetTripleAndFeatures (hsa_agent_t Agent) {
410
- std::string Target;
409
+ Error getTargetTripleAndFeatures (hsa_agent_t Agent,
410
+ SmallVector<SmallString< 32 >> &Targets) {
411
411
auto Err = utils::iterateAgentISAs (Agent, [&](hsa_isa_t ISA) {
412
412
uint32_t Length;
413
413
hsa_status_t Status;
@@ -421,13 +421,13 @@ Expected<std::string> getTargetTripleAndFeatures(hsa_agent_t Agent) {
421
421
return Status;
422
422
423
423
llvm::StringRef TripleTarget (ISAName.begin (), Length);
424
- if (TripleTarget.consume_front (" amdgcn-amd-amdhsa" ))
425
- Target = TripleTarget.ltrim (' -' ).rtrim (' \0 ' ).str ();
426
- return HSA_STATUS_INFO_BREAK;
424
+ if (TripleTarget.consume_front (" amdgcn-amd-amdhsa" )) {
425
+ auto Target = TripleTarget.ltrim (' -' ).rtrim (' \0 ' );
426
+ Targets.push_back (Target);
427
+ }
428
+ return HSA_STATUS_SUCCESS;
427
429
});
428
- if (Err)
429
- return Err;
430
- return Target;
430
+ return Err;
431
431
}
432
432
433
433
} // namespace utils
@@ -2928,12 +2928,10 @@ struct AMDGPUDeviceTy : public GenericDeviceTy, AMDGenericDeviceTy {
2928
2928
DP (" The number of XGMI Engines: %i\n " , NumXGmiEngines);
2929
2929
2930
2930
// Detect if XNACK is enabled
2931
- auto TargeTripleAndFeaturesOrError =
2932
- utils::getTargetTripleAndFeatures (Agent);
2933
- if (!TargeTripleAndFeaturesOrError)
2934
- return TargeTripleAndFeaturesOrError.takeError ();
2935
- if (static_cast <StringRef>(*TargeTripleAndFeaturesOrError)
2936
- .contains (" xnack+" ))
2931
+ SmallVector<SmallString<32 >> Targets;
2932
+ if (auto Err = utils::getTargetTripleAndFeatures (Agent, Targets))
2933
+ return Err;
2934
+ if (!Targets.empty () && Targets[0 ].str ().contains (" xnack+" ))
2937
2935
IsXnackEnabled = true ;
2938
2936
2939
2937
// detect if device is an APU.
@@ -4666,13 +4664,16 @@ struct AMDGPUPluginTy final : public GenericPluginTy {
4666
4664
if (!Processor)
4667
4665
return false ;
4668
4666
4669
- auto TargeTripleAndFeaturesOrError =
4670
- utils::getTargetTripleAndFeatures (getKernelAgent (DeviceId));
4671
- if (!TargeTripleAndFeaturesOrError)
4672
- return TargeTripleAndFeaturesOrError.takeError ();
4673
- return utils::isImageCompatibleWithEnv (Processor ? *Processor : " " ,
4674
- ElfOrErr->getPlatformFlags (),
4675
- *TargeTripleAndFeaturesOrError);
4667
+ SmallVector<SmallString<32 >> Targets;
4668
+ if (auto Err = utils::getTargetTripleAndFeatures (
4669
+ getKernelAgent (DeviceId), Targets))
4670
+ return Err;
4671
+ for (auto &Target : Targets)
4672
+ if (utils::isImageCompatibleWithEnv (
4673
+ Processor ? *Processor : " " , ElfOrErr->getPlatformFlags (),
4674
+ Target.str ()))
4675
+ return true ;
4676
+ return false ;
4676
4677
}
4677
4678
4678
4679
bool isDataExchangable (int32_t SrcDeviceId, int32_t DstDeviceId) override {
0 commit comments