@@ -838,14 +838,13 @@ ProgramManager::collectDependentDeviceImagesForVirtualFunctions(
838838 return DeviceImagesToLink;
839839}
840840
841- static void
842- setSpecializationConstants (const std::shared_ptr<device_image_impl> &InputImpl,
843- ur_program_handle_t Prog,
844- const AdapterPtr &Adapter) {
845- std::lock_guard<std::mutex> Lock{InputImpl->get_spec_const_data_lock ()};
841+ static void setSpecializationConstants (device_image_impl &InputImpl,
842+ ur_program_handle_t Prog,
843+ const AdapterPtr &Adapter) {
844+ std::lock_guard<std::mutex> Lock{InputImpl.get_spec_const_data_lock ()};
846845 const std::map<std::string, std::vector<device_image_impl::SpecConstDescT>>
847- &SpecConstData = InputImpl-> get_spec_const_data_ref ();
848- const SerializedObj &SpecConsts = InputImpl-> get_spec_const_blob_ref ();
846+ &SpecConstData = InputImpl. get_spec_const_data_ref ();
847+ const SerializedObj &SpecConsts = InputImpl. get_spec_const_blob_ref ();
849848
850849 // Set all specialization IDs from descriptors in the input device image.
851850 for (const auto &[SpecConstNames, SpecConstDescs] : SpecConstData) {
@@ -941,7 +940,7 @@ ur_program_handle_t ProgramManager::getBuiltURProgram(
941940 if (!DeviceCodeWasInCache && MainImg.supportsSpecConstants ()) {
942941 enableITTAnnotationsIfNeeded (NativePrg, Adapter);
943942 if (DevImgWithDeps)
944- setSpecializationConstants (getSyclObjImpl (DevImgWithDeps->getMain ()),
943+ setSpecializationConstants (* getSyclObjImpl (DevImgWithDeps->getMain ()),
945944 NativePrg, Adapter);
946945 }
947946
@@ -982,7 +981,7 @@ ur_program_handle_t ProgramManager::getBuiltURProgram(
982981 enableITTAnnotationsIfNeeded (NativePrg, Adapter);
983982 if (DevImgWithDeps)
984983 setSpecializationConstants (
985- getSyclObjImpl (DevImgWithDeps->getAll ()[I]), NativePrg,
984+ * getSyclObjImpl (DevImgWithDeps->getAll ()[I]), NativePrg,
986985 Adapter);
987986 }
988987 ProgramsToLink.push_back (NativePrg);
@@ -2508,9 +2507,9 @@ device_image_plain ProgramManager::getDeviceImageFromBinaryImage(
25082507 KernelIDs = m_BinImg2KernelIDs[BinImage];
25092508 }
25102509
2511- DeviceImageImplPtr Impl = std::make_shared<detail::device_image_impl> (
2510+ DeviceImageImplPtr Impl = device_image_impl::create (
25122511 BinImage, Ctx, std::vector<device>{Dev}, ImgState, KernelIDs,
2513- /* PIProgram=*/ nullptr );
2512+ /* PIProgram=*/ nullptr , ImageOriginSYCLOffline );
25142513
25152514 return createSyclObjFromImpl<device_image_plain>(std::move (Impl));
25162515}
@@ -2668,9 +2667,10 @@ ProgramManager::getSYCLDeviceImagesWithCompatibleState(
26682667 if (ImgInfoPair.second .RequirementCounter == 0 )
26692668 continue ;
26702669
2671- DeviceImageImplPtr MainImpl = std::make_shared<detail::device_image_impl> (
2670+ DeviceImageImplPtr MainImpl = device_image_impl::create (
26722671 ImgInfoPair.first , Ctx, Devs, ImgInfoPair.second .State ,
2673- ImgInfoPair.second .KernelIDs , /* PIProgram=*/ nullptr );
2672+ ImgInfoPair.second .KernelIDs , /* PIProgram=*/ nullptr ,
2673+ ImageOriginSYCLOffline);
26742674
26752675 std::vector<device_image_plain> Images;
26762676 const std::set<RTDeviceBinaryImage *> &Deps = ImgInfoPair.second .Deps ;
@@ -2701,8 +2701,9 @@ device_image_plain ProgramManager::createDependencyImage(
27012701
27022702 assert (DepState == getBinImageState (DepImage) &&
27032703 " State mismatch between main image and its dependency" );
2704- DeviceImageImplPtr DepImpl = std::make_shared<detail::device_image_impl>(
2705- DepImage, Ctx, Devs, DepState, DepKernelIDs, /* PIProgram=*/ nullptr );
2704+ DeviceImageImplPtr DepImpl =
2705+ device_image_impl::create (DepImage, Ctx, Devs, DepState, DepKernelIDs,
2706+ /* PIProgram=*/ nullptr , ImageOriginSYCLOffline);
27062707
27072708 return createSyclObjFromImpl<device_image_plain>(std::move (DepImpl));
27082709}
@@ -2857,42 +2858,42 @@ ProgramManager::compile(const DevImgPlainWithDeps &ImgWithDeps,
28572858 std::vector<device_image_plain> CompiledImages;
28582859 CompiledImages.reserve (ImgWithDeps.size ());
28592860 for (const device_image_plain &DeviceImage : ImgWithDeps.getAll ()) {
2860- const std::shared_ptr<device_image_impl> &InputImpl =
2861- getSyclObjImpl (DeviceImage);
2861+ device_image_impl &InputImpl = *getSyclObjImpl (DeviceImage);
28622862
28632863 const AdapterPtr &Adapter =
2864- getSyclObjImpl (InputImpl-> get_context ())->getAdapter ();
2864+ getSyclObjImpl (InputImpl. get_context ())->getAdapter ();
28652865
28662866 ur_program_handle_t Prog =
2867- createURProgram (*InputImpl-> get_bin_image_ref (),
2868- *getSyclObjImpl (InputImpl-> get_context ()), Devs);
2867+ createURProgram (*InputImpl. get_bin_image_ref (),
2868+ *getSyclObjImpl (InputImpl. get_context ()), Devs);
28692869
2870- if (InputImpl-> get_bin_image_ref ()->supportsSpecConstants ())
2870+ if (InputImpl. get_bin_image_ref ()->supportsSpecConstants ())
28712871 setSpecializationConstants (InputImpl, Prog, Adapter);
28722872
2873- KernelNameSetT KernelNames = InputImpl-> getKernelNames ();
2873+ KernelNameSetT KernelNames = InputImpl. getKernelNames ();
28742874
28752875 std::optional<detail::KernelCompilerBinaryInfo> RTCInfo =
2876- InputImpl-> getRTCInfo ();
2877- DeviceImageImplPtr ObjectImpl = std::make_shared<detail::device_image_impl> (
2878- InputImpl-> get_bin_image_ref (), InputImpl-> get_context (),
2876+ InputImpl. getRTCInfo ();
2877+ DeviceImageImplPtr ObjectImpl = device_image_impl::create (
2878+ InputImpl. get_bin_image_ref (), InputImpl. get_context (),
28792879 std::vector<device>{Devs}, bundle_state::object,
2880- InputImpl->get_kernel_ids_ptr (), Prog,
2881- InputImpl->get_spec_const_data_ref (),
2882- InputImpl->get_spec_const_blob_ref (), InputImpl->getOriginMask (),
2883- std::move (RTCInfo), std::move (KernelNames));
2880+ InputImpl.get_kernel_ids_ptr (), Prog,
2881+ InputImpl.get_spec_const_data_ref (),
2882+ InputImpl.get_spec_const_blob_ref (), InputImpl.getOriginMask (),
2883+ std::move (RTCInfo), std::move (KernelNames),
2884+ /* MergedImageStorage = */ nullptr );
28842885
28852886 std::string CompileOptions;
28862887 applyCompileOptionsFromEnvironment (CompileOptions);
28872888 appendCompileOptionsFromImage (
2888- CompileOptions, *(InputImpl-> get_bin_image_ref ()), Devs, Adapter);
2889+ CompileOptions, *(InputImpl. get_bin_image_ref ()), Devs, Adapter);
28892890 // Should always come last!
28902891 appendCompileEnvironmentVariablesThatAppend (CompileOptions);
2891- ur_result_t Error = doCompile (
2892- Adapter, ObjectImpl->get_ur_program_ref (), Devs.size (),
2893- URDevices.data (),
2894- getSyclObjImpl (InputImpl-> get_context ()).get ()->getHandleRef (),
2895- CompileOptions.c_str ());
2892+ ur_result_t Error =
2893+ doCompile ( Adapter, ObjectImpl->get_ur_program_ref (), Devs.size (),
2894+ URDevices.data (),
2895+ getSyclObjImpl (InputImpl. get_context ()).get ()->getHandleRef (),
2896+ CompileOptions.c_str ());
28962897 if (Error != UR_RESULT_SUCCESS)
28972898 throw sycl::exception (
28982899 make_error_code (errc::build),
@@ -3074,13 +3075,11 @@ ProgramManager::link(const std::vector<device_image_plain> &Imgs,
30743075 }
30753076 auto MergedRTCInfo = detail::KernelCompilerBinaryInfo::Merge (RTCInfoPtrs);
30763077
3077- DeviceImageImplPtr ExecutableImpl =
3078- std::make_shared<detail::device_image_impl>(
3079- NewBinImg, Context, std::vector<device>{Devs},
3080- bundle_state::executable, std::move (KernelIDs), LinkedProg,
3081- std::move (NewSpecConstMap), std::move (NewSpecConstBlob),
3082- CombinedOrigins, std::move (MergedRTCInfo),
3083- std::move (MergedKernelNames), std::move (MergedImageStorage));
3078+ DeviceImageImplPtr ExecutableImpl = device_image_impl::create (
3079+ NewBinImg, Context, std::vector<device>{Devs}, bundle_state::executable,
3080+ std::move (KernelIDs), LinkedProg, std::move (NewSpecConstMap),
3081+ std::move (NewSpecConstBlob), CombinedOrigins, std::move (MergedRTCInfo),
3082+ std::move (MergedKernelNames), std::move (MergedImageStorage));
30843083
30853084 // TODO: Make multiple sets of device images organized by devices they are
30863085 // compiled for.
@@ -3156,7 +3155,7 @@ ProgramManager::build(const DevImgPlainWithDeps &DevImgWithDeps,
31563155 }
31573156 auto MergedRTCInfo = detail::KernelCompilerBinaryInfo::Merge (RTCInfoPtrs);
31583157
3159- DeviceImageImplPtr ExecImpl = std::make_shared<detail::device_image_impl> (
3158+ DeviceImageImplPtr ExecImpl = device_image_impl::create (
31603159 ResultBinImg, Context, std::vector<device>{Devs},
31613160 bundle_state::executable, std::move (KernelIDs), ResProgram,
31623161 std::move (SpecConstMap), std::move (SpecConstBlob), CombinedOrigins,
0 commit comments