@@ -233,7 +233,7 @@ ProgramManager::createURProgram(const RTDeviceBinaryImage &Img,
233
233
const auto &ProgMetadata = Img.getProgramMetadataUR ();
234
234
235
235
// Load the image
236
- const ContextImplPtr Ctx = getSyclObjImpl (Context);
236
+ const ContextImplPtr & Ctx = getSyclObjImpl (Context);
237
237
std::vector<const uint8_t *> Binaries (
238
238
Devices.size (), const_cast <uint8_t *>(RawImg.BinaryStart ));
239
239
std::vector<size_t > Lengths (Devices.size (), ImgSize);
@@ -2696,7 +2696,8 @@ void ProgramManager::bringSYCLDeviceImagesToState(
2696
2696
2697
2697
for (DevImgPlainWithDeps &ImgWithDeps : DeviceImages) {
2698
2698
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 ();
2700
2701
// At this time, there is no circumstance where a device image should ever
2701
2702
// be in the source state. That not good.
2702
2703
assert (DevImageState != bundle_state::ext_oneapi_source);
@@ -2712,9 +2713,8 @@ void ProgramManager::bringSYCLDeviceImagesToState(
2712
2713
break ;
2713
2714
case bundle_state::object:
2714
2715
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=*/ {});
2718
2718
break ;
2719
2719
}
2720
2720
// Device image is expected to be object state then.
@@ -2728,7 +2728,7 @@ void ProgramManager::bringSYCLDeviceImagesToState(
2728
2728
assert (DevImageState != bundle_state::ext_oneapi_source);
2729
2729
break ;
2730
2730
case bundle_state::input:
2731
- ImgWithDeps = build (ImgWithDeps, getSyclObjImpl (MainImg) ->get_devices (),
2731
+ ImgWithDeps = build (ImgWithDeps, MainImgImpl ->get_devices (),
2732
2732
/* PropList=*/ {});
2733
2733
break ;
2734
2734
case bundle_state::object: {
@@ -2742,7 +2742,7 @@ void ProgramManager::bringSYCLDeviceImagesToState(
2742
2742
break ;
2743
2743
}
2744
2744
case bundle_state::executable:
2745
- ImgWithDeps = build (ImgWithDeps, getSyclObjImpl (MainImg) ->get_devices (),
2745
+ ImgWithDeps = build (ImgWithDeps, MainImgImpl ->get_devices (),
2746
2746
/* PropList=*/ {});
2747
2747
break ;
2748
2748
}
@@ -2884,7 +2884,8 @@ static void mergeImageData(const std::vector<device_image_plain> &Imgs,
2884
2884
std::vector<unsigned char > &NewSpecConstBlob,
2885
2885
device_image_impl::SpecConstMapT &NewSpecConstMap) {
2886
2886
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);
2888
2889
// Duplicates are not expected here, otherwise urProgramLink should fail
2889
2890
if (DeviceImageImpl->get_kernel_ids_ptr ())
2890
2891
KernelIDs.insert (KernelIDs.end (),
@@ -2946,16 +2947,15 @@ ProgramManager::link(const DevImgPlainWithDeps &ImgWithDeps,
2946
2947
std::string LinkOptionsStr;
2947
2948
applyLinkOptionsFromEnvironment (LinkOptionsStr);
2948
2949
const device_image_plain &MainImg = ImgWithDeps.getMain ();
2950
+ const std::shared_ptr<device_image_impl> &InputImpl = getSyclObjImpl (MainImg);
2949
2951
if (LinkOptionsStr.empty ()) {
2950
- const std::shared_ptr<device_image_impl> &InputImpl =
2951
- getSyclObjImpl (MainImg);
2952
2952
appendLinkOptionsFromImage (LinkOptionsStr,
2953
2953
*(InputImpl->get_bin_image_ref ()));
2954
2954
}
2955
2955
// Should always come last!
2956
2956
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);
2959
2959
const AdapterPtr &Adapter = ContextImpl->getAdapter ();
2960
2960
2961
2961
ur_program_handle_t LinkedProg = nullptr ;
@@ -2981,8 +2981,7 @@ ProgramManager::link(const DevImgPlainWithDeps &ImgWithDeps,
2981
2981
2982
2982
if (Error != UR_RESULT_SUCCESS) {
2983
2983
if (LinkedProg) {
2984
- const std::string ErrorMsg =
2985
- getProgramBuildLog (LinkedProg, std::move (ContextImpl));
2984
+ const std::string ErrorMsg = getProgramBuildLog (LinkedProg, ContextImpl);
2986
2985
throw sycl::exception (make_error_code (errc::build), ErrorMsg);
2987
2986
}
2988
2987
throw set_ur_error (exception (make_error_code (errc::build), " link() failed" ),
@@ -3008,7 +3007,7 @@ ProgramManager::link(const DevImgPlainWithDeps &ImgWithDeps,
3008
3007
}
3009
3008
}
3010
3009
3011
- auto BinImg = getSyclObjImpl (MainImg) ->get_bin_image_ref ();
3010
+ auto BinImg = InputImpl ->get_bin_image_ref ();
3012
3011
DeviceImageImplPtr ExecutableImpl =
3013
3012
std::make_shared<detail::device_image_impl>(
3014
3013
BinImg, Context, Devs, bundle_state::executable, std::move (KernelIDs),
@@ -3037,7 +3036,6 @@ ProgramManager::build(const DevImgPlainWithDeps &DevImgWithDeps,
3037
3036
getSyclObjImpl (DevImgWithDeps.getMain ());
3038
3037
3039
3038
const context Context = MainInputImpl->get_context ();
3040
- const ContextImplPtr ContextImpl = getSyclObjImpl (Context);
3041
3039
3042
3040
std::vector<const RTDeviceBinaryImage *> BinImgs;
3043
3041
BinImgs.reserve (DevImgWithDeps.size ());
@@ -3089,7 +3087,7 @@ ProgramManager::getOrCreateKernel(const context &Context,
3089
3087
PropList, NoAllowedPropertiesCheck, NoAllowedPropertiesCheck);
3090
3088
}
3091
3089
3092
- const ContextImplPtr Ctx = getSyclObjImpl (Context);
3090
+ const ContextImplPtr & Ctx = getSyclObjImpl (Context);
3093
3091
3094
3092
KernelProgramCache &Cache = Ctx->getKernelProgramCache ();
3095
3093
0 commit comments