Skip to content
Snippets Groups Projects
Commit 8ce5eab8 authored by Akash Kothari's avatar Akash Kothari
Browse files

Fix preffered targets getter imeplementation in VISCUtils header

parent 1b191369
No related branches found
No related tags found
No related merge requests found
......@@ -539,24 +539,26 @@ visc::Target getPreferredTarget(Function* F) {
DEBUG(errs() << "Finding preferred target for " << F->getName() << "\n");
Module* M = F->getParent();
auto PrefTarget = [=](StringRef Name) {
auto FoundPrefTarget = [=](StringRef Name) {
NamedMDNode* HintNode = M->getOrInsertNamedMetadata(Name);
for(unsigned i = 0; i < HintNode->getNumOperands(); i++) {
MDNode* N = HintNode->getOperand(i);
Value* FHint = dyn_cast<ValueAsMetadata>(N->getOperand(0).get())->getValue();
if(F == FHint)
return true;
}
}
return false;
};
if(PrefTarget("visc_hint_gpu")) return visc::GPU_TARGET;
if(PrefTarget("visc_hint_spir")) return visc::SPIR_TARGET;
if(PrefTarget("visc_hint_cudnn")) return visc::CUDNN_TARGET;
if(PrefTarget("visc_hint_promise")) return visc::PROMISE_TARGET;
if(PrefTarget("visc_hint_cpu_gpu")) return visc::CPU_OR_GPU_TARGET;
if(PrefTarget("visc_hint_cpu_spir")) return visc::CPU_OR_SPIR_TARGET;
return visc::CPU_TARGET;
if(FoundPrefTarget("visc_hint_cpu")) return visc::CPU_TARGET;
if(FoundPrefTarget("visc_hint_gpu")) return visc::GPU_TARGET;
if(FoundPrefTarget("visc_hint_spir")) return visc::SPIR_TARGET;
if(FoundPrefTarget("visc_hint_cudnn")) return visc::CUDNN_TARGET;
if(FoundPrefTarget("visc_hint_promise")) return visc::PROMISE_TARGET;
if(FoundPrefTarget("visc_hint_cpu_gpu")) return visc::CPU_OR_GPU_TARGET;
if(FoundPrefTarget("visc_hint_cpu_spir")) return visc::CPU_OR_SPIR_TARGET;
return visc::None;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment