@@ -960,37 +960,35 @@ void ProgramManager::flushSpecConstants(const program_impl &Prg,
960
960
std::cerr << " >>> ProgramManager::flushSpecConstants(" << Prg.get ()
961
961
<< " ,...)\n " ;
962
962
}
963
- if (Img) {
963
+ pi::PiProgram PrgHandle = Prg.getHandleRef ();
964
+ // program_impl can't correspond to two different native programs
965
+ assert (!NativePrg || !PrgHandle || (NativePrg == PrgHandle));
966
+ NativePrg = NativePrg ? NativePrg : PrgHandle;
967
+
968
+ if (!Img) {
969
+ // caller hasn't provided the image object - find it
970
+ { // make sure NativePrograms map access is synchronized
971
+ ContextImplPtr Ctx = getSyclObjImpl (Prg.get_context ());
972
+ auto LockGuard = Ctx->getKernelProgramCache ().acquireCachedPrograms ();
973
+ auto It = NativePrograms.find (NativePrg);
974
+ if (It == NativePrograms.end ()) {
975
+ if (DbgProgMgr > 0 )
976
+ std::cerr << " >>> WARNING: flushSpecConstants requested on a "
977
+ " program w/o known binary image\n " ;
978
+ return ; // program origin is unknown
979
+ }
980
+ Img = It->second ;
981
+ }
964
982
if (!Img->supportsSpecConstants ()) {
965
983
if (DbgProgMgr > 0 )
966
984
std::cerr << " >>> ProgramManager::flushSpecConstants: binary image "
967
985
<< &Img->getRawData () << " doesn't support spec constants\n " ;
986
+ // this device binary image does not support runtime setting of
987
+ // specialization constants; compiler must have generated default values
968
988
return ;
969
989
}
970
- Prg.flush_spec_constants (*Img, NativePrg);
971
- return ;
972
- }
973
- { // make sure NativePrograms map access is synchronized
974
- ContextImplPtr Ctx = getSyclObjImpl (Prg.get_context ());
975
- auto LockGuard = Ctx->getKernelProgramCache ().acquireCachedPrograms ();
976
- auto It = NativePrograms.find (pi::cast<pi::PiProgram>(Prg.get ()));
977
- if (It == NativePrograms.end ()) {
978
- if (DbgProgMgr > 0 )
979
- std::cerr << " >>> WARNING: flushSpecConstants requested on a "
980
- " program w/o known binary image\n " ;
981
- return ; // program origin is unknown
982
- }
983
- Img = It->second ;
984
- }
985
- if (!Img->supportsSpecConstants ()) {
986
- if (DbgProgMgr > 0 )
987
- std::cerr << " >>> ProgramManager::flushSpecConstants: binary image "
988
- << &Img->getRawData () << " doesn't support spec constants\n " ;
989
- // this device binary image does not support runtime setting of
990
- // specialization constants; compiler must have generated default values
991
- return ;
992
990
}
993
- Prg.flush_spec_constants (*Img);
991
+ Prg.flush_spec_constants (*Img, NativePrg );
994
992
}
995
993
996
994
} // namespace detail
0 commit comments