@@ -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);
@@ -2673,7 +2673,8 @@ void ProgramManager::bringSYCLDeviceImagesToState(
26732673
26742674 for (DevImgPlainWithDeps &ImgWithDeps : DeviceImages) {
26752675 device_image_plain &MainImg = ImgWithDeps.getMain ();
2676- const bundle_state DevImageState = getSyclObjImpl (MainImg)->get_state ();
2676+ const DeviceImageImplPtr &MainImgImpl = getSyclObjImpl (MainImg);
2677+ const bundle_state DevImageState = MainImgImpl->get_state ();
26772678 // At this time, there is no circumstance where a device image should ever
26782679 // be in the source state. That not good.
26792680 assert (DevImageState != bundle_state::ext_oneapi_source);
@@ -2689,9 +2690,8 @@ void ProgramManager::bringSYCLDeviceImagesToState(
26892690 break ;
26902691 case bundle_state::object:
26912692 if (DevImageState == bundle_state::input) {
2692- ImgWithDeps =
2693- compile (ImgWithDeps, getSyclObjImpl (MainImg)->get_devices (),
2694- /* PropList=*/ {});
2693+ ImgWithDeps = compile (ImgWithDeps, MainImgImpl->get_devices (),
2694+ /* PropList=*/ {});
26952695 break ;
26962696 }
26972697 // Device image is expected to be object state then.
@@ -2705,7 +2705,7 @@ void ProgramManager::bringSYCLDeviceImagesToState(
27052705 assert (DevImageState != bundle_state::ext_oneapi_source);
27062706 break ;
27072707 case bundle_state::input:
2708- ImgWithDeps = build (ImgWithDeps, getSyclObjImpl (MainImg) ->get_devices (),
2708+ ImgWithDeps = build (ImgWithDeps, MainImgImpl ->get_devices (),
27092709 /* PropList=*/ {});
27102710 break ;
27112711 case bundle_state::object: {
@@ -2719,7 +2719,7 @@ void ProgramManager::bringSYCLDeviceImagesToState(
27192719 break ;
27202720 }
27212721 case bundle_state::executable:
2722- ImgWithDeps = build (ImgWithDeps, getSyclObjImpl (MainImg) ->get_devices (),
2722+ ImgWithDeps = build (ImgWithDeps, MainImgImpl ->get_devices (),
27232723 /* PropList=*/ {});
27242724 break ;
27252725 }
@@ -2861,7 +2861,8 @@ static void mergeImageData(const std::vector<device_image_plain> &Imgs,
28612861 std::vector<unsigned char > &NewSpecConstBlob,
28622862 device_image_impl::SpecConstMapT &NewSpecConstMap) {
28632863 for (const device_image_plain &Img : Imgs) {
2864- std::shared_ptr<device_image_impl> DeviceImageImpl = getSyclObjImpl (Img);
2864+ const std::shared_ptr<device_image_impl> &DeviceImageImpl =
2865+ getSyclObjImpl (Img);
28652866 // Duplicates are not expected here, otherwise urProgramLink should fail
28662867 KernelIDs.insert (KernelIDs.end (),
28672868 DeviceImageImpl->get_kernel_ids_ptr ()->begin (),
@@ -2922,16 +2923,15 @@ ProgramManager::link(const DevImgPlainWithDeps &ImgWithDeps,
29222923 std::string LinkOptionsStr;
29232924 applyLinkOptionsFromEnvironment (LinkOptionsStr);
29242925 const device_image_plain &MainImg = ImgWithDeps.getMain ();
2926+ const std::shared_ptr<device_image_impl> &InputImpl = getSyclObjImpl (MainImg);
29252927 if (LinkOptionsStr.empty ()) {
2926- const std::shared_ptr<device_image_impl> &InputImpl =
2927- getSyclObjImpl (MainImg);
29282928 appendLinkOptionsFromImage (LinkOptionsStr,
29292929 *(InputImpl->get_bin_image_ref ()));
29302930 }
29312931 // Should always come last!
29322932 appendLinkEnvironmentVariablesThatAppend (LinkOptionsStr);
2933- const context &Context = getSyclObjImpl (MainImg) ->get_context ();
2934- const ContextImplPtr ContextImpl = getSyclObjImpl (Context);
2933+ const context &Context = InputImpl ->get_context ();
2934+ const ContextImplPtr & ContextImpl = getSyclObjImpl (Context);
29352935 const AdapterPtr &Adapter = ContextImpl->getAdapter ();
29362936
29372937 ur_program_handle_t LinkedProg = nullptr ;
@@ -2957,8 +2957,7 @@ ProgramManager::link(const DevImgPlainWithDeps &ImgWithDeps,
29572957
29582958 if (Error != UR_RESULT_SUCCESS) {
29592959 if (LinkedProg) {
2960- const std::string ErrorMsg =
2961- getProgramBuildLog (LinkedProg, std::move (ContextImpl));
2960+ const std::string ErrorMsg = getProgramBuildLog (LinkedProg, ContextImpl);
29622961 throw sycl::exception (make_error_code (errc::build), ErrorMsg);
29632962 }
29642963 throw set_ur_error (exception (make_error_code (errc::build), " link() failed" ),
@@ -2984,7 +2983,7 @@ ProgramManager::link(const DevImgPlainWithDeps &ImgWithDeps,
29842983 }
29852984 }
29862985
2987- auto BinImg = getSyclObjImpl (MainImg) ->get_bin_image_ref ();
2986+ auto BinImg = InputImpl ->get_bin_image_ref ();
29882987 DeviceImageImplPtr ExecutableImpl =
29892988 std::make_shared<detail::device_image_impl>(
29902989 BinImg, Context, Devs, bundle_state::executable, std::move (KernelIDs),
@@ -3013,7 +3012,6 @@ ProgramManager::build(const DevImgPlainWithDeps &DevImgWithDeps,
30133012 getSyclObjImpl (DevImgWithDeps.getMain ());
30143013
30153014 const context Context = MainInputImpl->get_context ();
3016- const ContextImplPtr ContextImpl = getSyclObjImpl (Context);
30173015
30183016 std::vector<const RTDeviceBinaryImage *> BinImgs;
30193017 BinImgs.reserve (DevImgWithDeps.size ());
@@ -3065,7 +3063,7 @@ ProgramManager::getOrCreateKernel(const context &Context,
30653063 PropList, NoAllowedPropertiesCheck, NoAllowedPropertiesCheck);
30663064 }
30673065
3068- const ContextImplPtr Ctx = getSyclObjImpl (Context);
3066+ const ContextImplPtr & Ctx = getSyclObjImpl (Context);
30693067
30703068 KernelProgramCache &Cache = Ctx->getKernelProgramCache ();
30713069
0 commit comments