@@ -190,8 +190,8 @@ Error asyncMemCopy(bool UseMultipleSdmaEngines, void *Dst, hsa_agent_t DstAgent,
190
190
#endif
191
191
}
192
192
193
- Expected<std::string> getTargetTripleAndFeatures (hsa_agent_t Agent) {
194
- std::string Target;
193
+ Error getTargetTripleAndFeatures (hsa_agent_t Agent,
194
+ SmallVector<SmallString< 32 >> &Targets) {
195
195
auto Err = hsa_utils::iterateAgentISAs (Agent, [&](hsa_isa_t ISA) {
196
196
uint32_t Length;
197
197
hsa_status_t Status;
@@ -205,13 +205,13 @@ Expected<std::string> getTargetTripleAndFeatures(hsa_agent_t Agent) {
205
205
return Status;
206
206
207
207
llvm::StringRef TripleTarget (ISAName.begin (), Length);
208
- if (TripleTarget.consume_front (" amdgcn-amd-amdhsa" ))
209
- Target = TripleTarget.ltrim (' -' ).rtrim (' \0 ' ).str ();
210
- return HSA_STATUS_INFO_BREAK;
208
+ if (TripleTarget.consume_front (" amdgcn-amd-amdhsa" )) {
209
+ auto Target = TripleTarget.ltrim (' -' ).rtrim (' \0 ' );
210
+ Targets.push_back (Target);
211
+ }
212
+ return HSA_STATUS_SUCCESS;
211
213
});
212
- if (Err)
213
- return Err;
214
- return Target;
214
+ return Err;
215
215
}
216
216
} // namespace hsa_utils
217
217
@@ -1992,12 +1992,10 @@ struct AMDGPUDeviceTy : public GenericDeviceTy, AMDGenericDeviceTy {
1992
1992
return Err;
1993
1993
1994
1994
// Detect if XNACK is enabled
1995
- auto TargeTripleAndFeaturesOrError =
1996
- hsa_utils::getTargetTripleAndFeatures (Agent);
1997
- if (!TargeTripleAndFeaturesOrError)
1998
- return TargeTripleAndFeaturesOrError.takeError ();
1999
- if (static_cast <StringRef>(*TargeTripleAndFeaturesOrError)
2000
- .contains (" xnack+" ))
1995
+ SmallVector<SmallString<32 >> Targets;
1996
+ if (auto Err = hsa_utils::getTargetTripleAndFeatures (Agent, Targets))
1997
+ return Err;
1998
+ if (!Targets.empty () && Targets[0 ].str ().contains (" xnack+" ))
2001
1999
IsXnackEnabled = true ;
2002
2000
2003
2001
// detect if device is an APU.
@@ -3211,13 +3209,16 @@ struct AMDGPUPluginTy final : public GenericPluginTy {
3211
3209
if (!Processor)
3212
3210
return false ;
3213
3211
3214
- auto TargeTripleAndFeaturesOrError =
3215
- hsa_utils::getTargetTripleAndFeatures (getKernelAgent (DeviceId));
3216
- if (!TargeTripleAndFeaturesOrError)
3217
- return TargeTripleAndFeaturesOrError.takeError ();
3218
- return offloading::amdgpu::isImageCompatibleWithEnv (
3219
- Processor ? *Processor : " " , ElfOrErr->getPlatformFlags (),
3220
- *TargeTripleAndFeaturesOrError);
3212
+ SmallVector<SmallString<32 >> Targets;
3213
+ if (auto Err = hsa_utils::getTargetTripleAndFeatures (
3214
+ getKernelAgent (DeviceId), Targets))
3215
+ return Err;
3216
+ for (auto &Target : Targets)
3217
+ if (offloading::amdgpu::isImageCompatibleWithEnv (
3218
+ Processor ? *Processor : " " , ElfOrErr->getPlatformFlags (),
3219
+ Target.str ()))
3220
+ return true ;
3221
+ return false ;
3221
3222
}
3222
3223
3223
3224
bool isDataExchangable (int32_t SrcDeviceId, int32_t DstDeviceId) override {
0 commit comments