Skip to content

Commit dbe68d4

Browse files
fix merge issues
Signed-off-by: Tikhomirova, Kseniya <[email protected]>
1 parent 3c2f1a4 commit dbe68d4

File tree

2 files changed

+5
-117
lines changed

2 files changed

+5
-117
lines changed

sycl/source/detail/program_manager/program_manager.cpp

Lines changed: 5 additions & 116 deletions
Original file line numberDiff line numberDiff line change
@@ -842,12 +842,6 @@ ur_program_handle_t ProgramManager::getBuiltURProgram(
842842
// Should always come last!
843843
appendCompileEnvironmentVariablesThatAppend(CompileOpts);
844844
appendLinkEnvironmentVariablesThatAppend(LinkOpts);
845-
<<<<<<< HEAD
846-
// getOrCreateURProgram adds NativePrg to NativePrograms storage.
847-
auto [NativePrg, DeviceCodeWasInCache] = getOrCreateURProgram(
848-
Img, AllImages, Context, {Device}, CompileOpts + LinkOpts, SpecConsts);
849-
=======
850-
>>>>>>> sycl
851845

852846
auto [NativePrg, DeviceCodeWasInCache] =
853847
getOrCreateURProgram(MainImg, ImgWithDeps.getAll(), Context, Devs,
@@ -890,19 +884,7 @@ ur_program_handle_t ProgramManager::getBuiltURProgram(
890884
if (UseDeviceLibs)
891885
DeviceLibReqMask |= getDeviceLibReqMask(*BinImg);
892886

893-
<<<<<<< HEAD
894-
SerializedObj ImgSpecConsts =
895-
DeviceImageImpl->get_spec_const_blob_ref();
896-
897-
// adds NativePrg to NativePrograms
898-
ur_program_handle_t NativePrg =
899-
createURProgram(*BinImg, Context, {Device});
900-
901-
if (BinImg->supportsSpecConstants())
902-
setSpecializationConstants(DeviceImageImpl, NativePrg, Adapter);
903-
=======
904887
ur_program_handle_t NativePrg = createURProgram(*BinImg, Context, Devs);
905-
>>>>>>> sycl
906888

907889
if (BinImg->supportsSpecConstants()) {
908890
enableITTAnnotationsIfNeeded(NativePrg, Adapter);
@@ -914,16 +896,6 @@ ur_program_handle_t ProgramManager::getBuiltURProgram(
914896
ProgramsToLink.push_back(NativePrg);
915897
}
916898
}
917-
<<<<<<< HEAD
918-
std::vector<ur_device_handle_t> Devs = {
919-
getSyclObjImpl(Device).get()->getHandleRef()};
920-
;
921-
// build adds BuiltProgram to NativePrograms storage
922-
ProgramPtr BuiltProgram = build(
923-
std::move(ProgramManaged), ContextImpl, CompileOpts, LinkOpts, Devs,
924-
DeviceLibReqMask, ProgramsToLink,
925-
/*CreatedFromBinary*/ Img.getFormat() != SYCL_DEVICE_BINARY_TYPE_SPIRV);
926-
=======
927899

928900
std::vector<ur_device_handle_t> URDevices;
929901
for (auto Dev : Devs)
@@ -935,27 +907,20 @@ ur_program_handle_t ProgramManager::getBuiltURProgram(
935907
/*CreatedFromBinary*/ MainImg.getFormat() !=
936908
SYCL_DEVICE_BINARY_TYPE_SPIRV);
937909

938-
>>>>>>> sycl
939910
// Those extra programs won't be used anymore, just the final linked result
940911
for (ur_program_handle_t Prg : ProgramsToLink)
941912
Adapter->call<UrApiKind::urProgramRelease>(Prg);
942913
emitBuiltProgramInfo(BuiltProgram.get(), ContextImpl);
943914

944915
{
945916
std::lock_guard<std::mutex> Lock(MNativeProgramsMutex);
946-
<<<<<<< HEAD
947917
// NativePrograms map does not intend to keep reference to program handle,
948918
// so keys in the map can be invalid (reference count went to zero and the
949919
// underlying program disposed of). Protecting from incorrect values by
950920
// removal of map entries with same handle (obviously invalid entries).
951921
std::ignore = NativePrograms.erase(BuiltProgram.get());
952-
NativePrograms.insert({BuiltProgram.get(), &Img});
953-
for (RTDeviceBinaryImage *LinkedImg : DeviceImagesToLink) {
954-
NativePrograms.insert({BuiltProgram.get(), LinkedImg});
955-
=======
956922
for (const RTDeviceBinaryImage *Img : ImgWithDeps) {
957923
NativePrograms.insert({BuiltProgram.get(), Img});
958-
>>>>>>> sycl
959924
}
960925
}
961926

@@ -2757,6 +2722,11 @@ ProgramManager::link(const DevImgPlainWithDeps &ImgWithDeps,
27572722

27582723
{
27592724
std::lock_guard<std::mutex> Lock(MNativeProgramsMutex);
2725+
// NativePrograms map does not intend to keep reference to program handle,
2726+
// so keys in the map can be invalid (reference count went to zero and the
2727+
// underlying program disposed of). Protecting from incorrect values by
2728+
// removal of map entries with same handle (obviously invalid entries).
2729+
std::ignore = NativePrograms.erase(LinkedProg);
27602730
for (const device_image_plain &Img : ImgWithDeps) {
27612731
NativePrograms.insert(
27622732
{LinkedProg, getSyclObjImpl(Img)->get_bin_image_ref()});
@@ -2799,86 +2769,6 @@ ProgramManager::build(const DevImgPlainWithDeps &DevImgWithDeps,
27992769
std::vector<unsigned char> SpecConstBlob;
28002770
device_image_impl::SpecConstMapT SpecConstMap;
28012771

2802-
<<<<<<< HEAD
2803-
const RTDeviceBinaryImage *ImgPtr = InputImpl->get_bin_image_ref();
2804-
const RTDeviceBinaryImage &Img = *ImgPtr;
2805-
2806-
SerializedObj SpecConsts = InputImpl->get_spec_const_blob_ref();
2807-
2808-
// TODO: Unify this code with getBuiltPIProgram
2809-
auto BuildF = [this, &Context, &Img, &Devs, &CompileOpts, &LinkOpts,
2810-
&InputImpl, SpecConsts] {
2811-
ContextImplPtr ContextImpl = getSyclObjImpl(Context);
2812-
const AdapterPtr &Adapter = ContextImpl->getAdapter();
2813-
applyOptionsFromImage(CompileOpts, LinkOpts, Img, Devs, Adapter);
2814-
// Should always come last!
2815-
appendCompileEnvironmentVariablesThatAppend(CompileOpts);
2816-
appendLinkEnvironmentVariablesThatAppend(LinkOpts);
2817-
2818-
// Device is not used when creating program from SPIRV, so passing only one
2819-
// device is OK.
2820-
// getOrCreateURProgram adds NativePrg to NativePrograms storage (no extra
2821-
// ref).
2822-
auto [NativePrg, DeviceCodeWasInCache] = getOrCreateURProgram(
2823-
Img, {&Img}, Context, Devs, CompileOpts + LinkOpts, SpecConsts);
2824-
2825-
if (!DeviceCodeWasInCache &&
2826-
InputImpl->get_bin_image_ref()->supportsSpecConstants())
2827-
setSpecializationConstants(InputImpl, NativePrg, Adapter);
2828-
2829-
UrFuncInfo<UrApiKind::urProgramRelease> programReleaseInfo;
2830-
auto programRelease =
2831-
programReleaseInfo.getFuncPtrFromModule(ur::getURLoaderLibrary());
2832-
ProgramPtr ProgramManaged(NativePrg, programRelease);
2833-
2834-
// Link a fallback implementation of device libraries if they are not
2835-
// supported by a device compiler.
2836-
// Pre-compiled programs are supposed to be already linked.
2837-
// If device image is not SPIR-V, DeviceLibReqMask will be 0 which means
2838-
// no fallback device library will be linked.
2839-
uint32_t DeviceLibReqMask = 0;
2840-
if (Img.getFormat() == SYCL_DEVICE_BINARY_TYPE_SPIRV &&
2841-
!SYCLConfig<SYCL_DEVICELIB_NO_FALLBACK>::get())
2842-
DeviceLibReqMask = getDeviceLibReqMask(Img);
2843-
2844-
// TODO: Add support for dynamic linking with kernel bundles
2845-
std::vector<ur_program_handle_t> ExtraProgramsToLink;
2846-
std::vector<ur_device_handle_t> URDevices;
2847-
for (auto Dev : Devs) {
2848-
URDevices.push_back(getSyclObjImpl(Dev).get()->getHandleRef());
2849-
}
2850-
ProgramPtr BuiltProgram =
2851-
build(std::move(ProgramManaged), ContextImpl, CompileOpts, LinkOpts,
2852-
URDevices, DeviceLibReqMask, ExtraProgramsToLink);
2853-
2854-
emitBuiltProgramInfo(BuiltProgram.get(), ContextImpl);
2855-
2856-
{
2857-
std::lock_guard<std::mutex> Lock(MNativeProgramsMutex);
2858-
NativePrograms.insert({BuiltProgram.get(), &Img});
2859-
}
2860-
2861-
ContextImpl->addDeviceGlobalInitializer(BuiltProgram.get(), Devs, &Img);
2862-
2863-
// Save program to persistent cache if it is not there
2864-
if (!DeviceCodeWasInCache)
2865-
PersistentDeviceCodeCache::putItemToDisc(Devs[0], {&Img}, SpecConsts,
2866-
CompileOpts + LinkOpts,
2867-
BuiltProgram.get());
2868-
2869-
return BuiltProgram.release();
2870-
};
2871-
2872-
if (!SYCLConfig<SYCL_CACHE_IN_MEM>::get()) {
2873-
auto ResProgram = BuildF();
2874-
DeviceImageImplPtr ExecImpl = std::make_shared<detail::device_image_impl>(
2875-
InputImpl->get_bin_image_ref(), Context, Devs, bundle_state::executable,
2876-
InputImpl->get_kernel_ids_ptr(), ResProgram,
2877-
InputImpl->get_spec_const_data_ref(),
2878-
InputImpl->get_spec_const_blob_ref());
2879-
2880-
return createSyclObjFromImpl<device_image_plain>(ExecImpl);
2881-
=======
28822772
if (DevImgWithDeps.hasDeps()) {
28832773
KernelIDs = std::make_shared<std::vector<kernel_id>>();
28842774
// Sort the images to make the order of spec constant values used for
@@ -2894,7 +2784,6 @@ ProgramManager::build(const DevImgPlainWithDeps &DevImgWithDeps,
28942784
KernelIDs = MainInputImpl->get_kernel_ids_ptr();
28952785
SpecConstBlob = MainInputImpl->get_spec_const_blob_ref();
28962786
SpecConstMap = MainInputImpl->get_spec_const_data_ref();
2897-
>>>>>>> sycl
28982787
}
28992788

29002789
ur_program_handle_t ResProgram =

sycl/source/detail/program_manager/program_manager.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,6 @@ class ProgramManager {
340340

341341
std::set<RTDeviceBinaryImage *>
342342
getRawDeviceImages(const std::vector<kernel_id> &KernelIDs);
343-
344343
private:
345344
ProgramManager(ProgramManager const &) = delete;
346345
ProgramManager &operator=(ProgramManager const &) = delete;

0 commit comments

Comments
 (0)