Skip to content

Commit cba353c

Browse files
committed
[SQUASH] Exculde invalid exec paths leading to flushSpecConstants, fix it.
Signed-off-by: Konstantin S Bobrovsky <[email protected]>
1 parent d54a65e commit cba353c

File tree

3 files changed

+25
-26
lines changed

3 files changed

+25
-26
lines changed

sycl/source/detail/program_impl.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,6 @@ void program_impl::compile(const string_class &Options) {
332332
check_device_feature_support<info::device::is_compiler_available>(MDevices);
333333
vector_class<RT::PiDevice> Devices(get_pi_devices());
334334
const detail::plugin &Plugin = getPlugin();
335-
ProgramManager::getInstance().flushSpecConstants(*this);
336335
RT::PiResult Err = Plugin.call_nocheck<PiApiKind::piProgramCompile>(
337336
MProgram, Devices.size(), Devices.data(), Options.c_str(), 0, nullptr,
338337
nullptr, nullptr, nullptr);

sycl/source/detail/program_manager/program_manager.cpp

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -960,37 +960,35 @@ void ProgramManager::flushSpecConstants(const program_impl &Prg,
960960
std::cerr << ">>> ProgramManager::flushSpecConstants(" << Prg.get()
961961
<< ",...)\n";
962962
}
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+
}
964982
if (!Img->supportsSpecConstants()) {
965983
if (DbgProgMgr > 0)
966984
std::cerr << ">>> ProgramManager::flushSpecConstants: binary image "
967985
<< &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
968988
return;
969989
}
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;
992990
}
993-
Prg.flush_spec_constants(*Img);
991+
Prg.flush_spec_constants(*Img, NativePrg);
994992
}
995993

996994
} // namespace detail

sycl/test/spec_const/spec_const_hw.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,9 @@ int main(int argc, char **argv) {
7373
program2.set_spec_constant<MyFloatConst>(goldf);
7474

7575
program1.build_with_kernel_type<KernelAAAi>();
76-
program2.build_with_kernel_type<KernelBBBf>();
76+
// Use an option (does not matter which exactly) to test different internal
77+
// SYCL RT execution path
78+
program2.build_with_kernel_type<KernelBBBf>("-cl-fast-relaxed-math");
7779

7880
std::vector<int> veci(1);
7981
std::vector<float> vecf(1);

0 commit comments

Comments
 (0)