@@ -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
@@ -2928,12 +2928,10 @@ struct AMDGPUDeviceTy : public GenericDeviceTy, AMDGenericDeviceTy {
29282928 DP (" The number of XGMI Engines: %i\n " , NumXGmiEngines);
29292929
29302930 // 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+" ))
29372935 IsXnackEnabled = true ;
29382936
29392937 // detect if device is an APU.
@@ -4666,13 +4664,16 @@ struct AMDGPUPluginTy final : public GenericPluginTy {
46664664 if (!Processor)
46674665 return false ;
46684666
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 ;
46764677 }
46774678
46784679 bool isDataExchangable (int32_t SrcDeviceId, int32_t DstDeviceId) override {
0 commit comments