@@ -406,8 +406,8 @@ Error asyncMemCopy(bool UseMultipleSdmaEngines, void *Dst, hsa_agent_t DstAgent,
406406#endif
407407}
408408
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) {
411411 auto Err = utils::iterateAgentISAs (Agent, [&](hsa_isa_t ISA) {
412412 uint32_t Length;
413413 hsa_status_t Status;
@@ -421,13 +421,13 @@ Expected<std::string> getTargetTripleAndFeatures(hsa_agent_t Agent) {
421421 return Status;
422422
423423 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;
427429 });
428- if (Err)
429- return Err;
430- return Target;
430+ return Err;
431431}
432432
433433} // namespace utils
@@ -2926,12 +2926,10 @@ struct AMDGPUDeviceTy : public GenericDeviceTy, AMDGenericDeviceTy {
29262926 DP (" The number of XGMI Engines: %i\n " , NumXGmiEngines);
29272927
29282928 // Detect if XNACK is enabled
2929- auto TargeTripleAndFeaturesOrError =
2930- utils::getTargetTripleAndFeatures (Agent);
2931- if (!TargeTripleAndFeaturesOrError)
2932- return TargeTripleAndFeaturesOrError.takeError ();
2933- if (static_cast <StringRef>(*TargeTripleAndFeaturesOrError)
2934- .contains (" xnack+" ))
2929+ SmallVector<SmallString<32 >> Targets;
2930+ if (auto Err = utils::getTargetTripleAndFeatures (Agent, Targets))
2931+ return Err;
2932+ if (!Targets.empty () && Targets[0 ].str ().contains (" xnack+" ))
29352933 IsXnackEnabled = true ;
29362934
29372935 // detect if device is an APU.
@@ -4659,13 +4657,16 @@ struct AMDGPUPluginTy final : public GenericPluginTy {
46594657 if (!Processor)
46604658 return false ;
46614659
4662- auto TargeTripleAndFeaturesOrError =
4663- utils::getTargetTripleAndFeatures (getKernelAgent (DeviceId));
4664- if (!TargeTripleAndFeaturesOrError)
4665- return TargeTripleAndFeaturesOrError.takeError ();
4666- return utils::isImageCompatibleWithEnv (Processor ? *Processor : " " ,
4667- ElfOrErr->getPlatformFlags (),
4668- *TargeTripleAndFeaturesOrError);
4660+ SmallVector<SmallString<32 >> Targets;
4661+ if (auto Err = utils::getTargetTripleAndFeatures (
4662+ getKernelAgent (DeviceId), Targets))
4663+ return Err;
4664+ for (auto &Target : Targets)
4665+ if (utils::isImageCompatibleWithEnv (
4666+ Processor ? *Processor : " " , ElfOrErr->getPlatformFlags (),
4667+ Target.str ()))
4668+ return true ;
4669+ return false ;
46694670 }
46704671
46714672 bool isDataExchangable (int32_t SrcDeviceId, int32_t DstDeviceId) override {
0 commit comments