@@ -233,7 +233,7 @@ ProgramManager::createURProgram(const RTDeviceBinaryImage &Img,
233233 const auto &ProgMetadata = Img.getProgramMetadataUR ();
234234
235235 // Load the image
236- const ContextImplPtr Ctx = getSyclObjImpl (Context);
236+ const ContextImplPtr & Ctx = getSyclObjImpl (Context);
237237 std::vector<const uint8_t *> Binaries (
238238 Devices.size (), const_cast <uint8_t *>(RawImg.BinaryStart ));
239239 std::vector<size_t > Lengths (Devices.size (), ImgSize);
@@ -2696,7 +2696,8 @@ void ProgramManager::bringSYCLDeviceImagesToState(
26962696
26972697 for (DevImgPlainWithDeps &ImgWithDeps : DeviceImages) {
26982698 device_image_plain &MainImg = ImgWithDeps.getMain ();
2699- const bundle_state DevImageState = getSyclObjImpl (MainImg)->get_state ();
2699+ const DeviceImageImplPtr &MainImgImpl = getSyclObjImpl (MainImg);
2700+ const bundle_state DevImageState = MainImgImpl->get_state ();
27002701 // At this time, there is no circumstance where a device image should ever
27012702 // be in the source state. That not good.
27022703 assert (DevImageState != bundle_state::ext_oneapi_source);
@@ -2712,9 +2713,8 @@ void ProgramManager::bringSYCLDeviceImagesToState(
27122713 break ;
27132714 case bundle_state::object:
27142715 if (DevImageState == bundle_state::input) {
2715- ImgWithDeps =
2716- compile (ImgWithDeps, getSyclObjImpl (MainImg)->get_devices (),
2717- /* PropList=*/ {});
2716+ ImgWithDeps = compile (ImgWithDeps, MainImgImpl->get_devices (),
2717+ /* PropList=*/ {});
27182718 break ;
27192719 }
27202720 // Device image is expected to be object state then.
@@ -2728,7 +2728,7 @@ void ProgramManager::bringSYCLDeviceImagesToState(
27282728 assert (DevImageState != bundle_state::ext_oneapi_source);
27292729 break ;
27302730 case bundle_state::input:
2731- ImgWithDeps = build (ImgWithDeps, getSyclObjImpl (MainImg) ->get_devices (),
2731+ ImgWithDeps = build (ImgWithDeps, MainImgImpl ->get_devices (),
27322732 /* PropList=*/ {});
27332733 break ;
27342734 case bundle_state::object: {
@@ -2742,7 +2742,7 @@ void ProgramManager::bringSYCLDeviceImagesToState(
27422742 break ;
27432743 }
27442744 case bundle_state::executable:
2745- ImgWithDeps = build (ImgWithDeps, getSyclObjImpl (MainImg) ->get_devices (),
2745+ ImgWithDeps = build (ImgWithDeps, MainImgImpl ->get_devices (),
27462746 /* PropList=*/ {});
27472747 break ;
27482748 }
@@ -2884,7 +2884,8 @@ static void mergeImageData(const std::vector<device_image_plain> &Imgs,
28842884 std::vector<unsigned char > &NewSpecConstBlob,
28852885 device_image_impl::SpecConstMapT &NewSpecConstMap) {
28862886 for (const device_image_plain &Img : Imgs) {
2887- std::shared_ptr<device_image_impl> DeviceImageImpl = getSyclObjImpl (Img);
2887+ const std::shared_ptr<device_image_impl> &DeviceImageImpl =
2888+ getSyclObjImpl (Img);
28882889 // Duplicates are not expected here, otherwise urProgramLink should fail
28892890 if (DeviceImageImpl->get_kernel_ids_ptr ())
28902891 KernelIDs.insert (KernelIDs.end (),
@@ -2946,16 +2947,15 @@ ProgramManager::link(const DevImgPlainWithDeps &ImgWithDeps,
29462947 std::string LinkOptionsStr;
29472948 applyLinkOptionsFromEnvironment (LinkOptionsStr);
29482949 const device_image_plain &MainImg = ImgWithDeps.getMain ();
2950+ const std::shared_ptr<device_image_impl> &InputImpl = getSyclObjImpl (MainImg);
29492951 if (LinkOptionsStr.empty ()) {
2950- const std::shared_ptr<device_image_impl> &InputImpl =
2951- getSyclObjImpl (MainImg);
29522952 appendLinkOptionsFromImage (LinkOptionsStr,
29532953 *(InputImpl->get_bin_image_ref ()));
29542954 }
29552955 // Should always come last!
29562956 appendLinkEnvironmentVariablesThatAppend (LinkOptionsStr);
2957- const context &Context = getSyclObjImpl (MainImg) ->get_context ();
2958- const ContextImplPtr ContextImpl = getSyclObjImpl (Context);
2957+ const context &Context = InputImpl ->get_context ();
2958+ const ContextImplPtr & ContextImpl = getSyclObjImpl (Context);
29592959 const AdapterPtr &Adapter = ContextImpl->getAdapter ();
29602960
29612961 ur_program_handle_t LinkedProg = nullptr ;
@@ -2981,8 +2981,7 @@ ProgramManager::link(const DevImgPlainWithDeps &ImgWithDeps,
29812981
29822982 if (Error != UR_RESULT_SUCCESS) {
29832983 if (LinkedProg) {
2984- const std::string ErrorMsg =
2985- getProgramBuildLog (LinkedProg, std::move (ContextImpl));
2984+ const std::string ErrorMsg = getProgramBuildLog (LinkedProg, ContextImpl);
29862985 throw sycl::exception (make_error_code (errc::build), ErrorMsg);
29872986 }
29882987 throw set_ur_error (exception (make_error_code (errc::build), " link() failed" ),
@@ -3008,7 +3007,7 @@ ProgramManager::link(const DevImgPlainWithDeps &ImgWithDeps,
30083007 }
30093008 }
30103009
3011- auto BinImg = getSyclObjImpl (MainImg) ->get_bin_image_ref ();
3010+ auto BinImg = InputImpl ->get_bin_image_ref ();
30123011 DeviceImageImplPtr ExecutableImpl =
30133012 std::make_shared<detail::device_image_impl>(
30143013 BinImg, Context, Devs, bundle_state::executable, std::move (KernelIDs),
@@ -3037,7 +3036,6 @@ ProgramManager::build(const DevImgPlainWithDeps &DevImgWithDeps,
30373036 getSyclObjImpl (DevImgWithDeps.getMain ());
30383037
30393038 const context Context = MainInputImpl->get_context ();
3040- const ContextImplPtr ContextImpl = getSyclObjImpl (Context);
30413039
30423040 std::vector<const RTDeviceBinaryImage *> BinImgs;
30433041 BinImgs.reserve (DevImgWithDeps.size ());
@@ -3089,7 +3087,7 @@ ProgramManager::getOrCreateKernel(const context &Context,
30893087 PropList, NoAllowedPropertiesCheck, NoAllowedPropertiesCheck);
30903088 }
30913089
3092- const ContextImplPtr Ctx = getSyclObjImpl (Context);
3090+ const ContextImplPtr & Ctx = getSyclObjImpl (Context);
30933091
30943092 KernelProgramCache &Cache = Ctx->getKernelProgramCache ();
30953093
0 commit comments