@@ -190,9 +190,8 @@ Error asyncMemCopy(bool UseMultipleSdmaEngines, void *Dst, hsa_agent_t DstAgent,
190190#endif
191191}
192192
193- Expected<StringRef>
194- getTargetTripleAndFeatures (hsa_agent_t Agent, SmallVector<StringRef> &Targets) {
195- StringRef SpecificTarget;
193+ Error getTargetTripleAndFeatures (hsa_agent_t Agent,
194+ SmallVector<StringRef> &Targets) {
196195 auto Err = hsa_utils::iterateAgentISAs (Agent, [&](hsa_isa_t ISA) {
197196 uint32_t Length;
198197 hsa_status_t Status;
@@ -209,16 +208,10 @@ getTargetTripleAndFeatures(hsa_agent_t Agent, SmallVector<StringRef> &Targets) {
209208 if (TripleTarget.consume_front (" amdgcn-amd-amdhsa" )) {
210209 auto Target = TripleTarget.ltrim (' -' ).rtrim (' \0 ' );
211210 Targets.push_back (Target);
212- if (!Target.ends_with (" generic" ))
213- SpecificTarget = Target; // Expect one (and only one) to be found
214211 }
215212 return HSA_STATUS_SUCCESS;
216213 });
217- if (Err)
218- return Err;
219- if (SpecificTarget.empty ())
220- return Plugin::error (" Specific Target ISA not found" );
221- return SpecificTarget;
214+ return Err;
222215}
223216} // namespace hsa_utils
224217
@@ -1996,12 +1989,9 @@ struct AMDGPUDeviceTy : public GenericDeviceTy, AMDGenericDeviceTy {
19961989
19971990 // Detect if XNACK is enabled
19981991 SmallVector<StringRef> Targets;
1999- auto TargeTripleAndFeaturesOrError =
2000- hsa_utils::getTargetTripleAndFeatures (Agent, Targets);
2001- if (!TargeTripleAndFeaturesOrError)
2002- return TargeTripleAndFeaturesOrError.takeError ();
2003- if (static_cast <StringRef>(*TargeTripleAndFeaturesOrError)
2004- .contains (" xnack+" ))
1992+ if (auto Err = hsa_utils::getTargetTripleAndFeatures (Agent, Targets))
1993+ return Err;
1994+ if (!Targets.empty () && Targets[0 ].contains (" xnack+" ))
20051995 IsXnackEnabled = true ;
20061996
20071997 // detect if device is an APU.
@@ -3216,10 +3206,9 @@ struct AMDGPUPluginTy final : public GenericPluginTy {
32163206 return false ;
32173207
32183208 SmallVector<StringRef> Targets;
3219- auto TargetTripleAndFeaturesOrError = hsa_utils::getTargetTripleAndFeatures (
3220- getKernelAgent (DeviceId), Targets);
3221- if (!TargetTripleAndFeaturesOrError)
3222- return TargetTripleAndFeaturesOrError.takeError ();
3209+ if (auto Err = hsa_utils::getTargetTripleAndFeatures (
3210+ getKernelAgent (DeviceId), Targets))
3211+ return Err;
32233212 for (auto &Target : Targets)
32243213 if (offloading::amdgpu::isImageCompatibleWithEnv (
32253214 Processor ? *Processor : " " , ElfOrErr->getPlatformFlags (),
0 commit comments