Skip to content

Commit 0014759

Browse files
[SYCL] Fix regression in update_host (#15153)
Restores missed context analysis for host pointer update. Regression is caused by 3dc75a7 --------- Signed-off-by: Tikhomirova, Kseniya <kseniya.tikhomirova@intel.com>
1 parent 399574e commit 0014759

File tree

4 files changed

+10
-6
lines changed

4 files changed

+10
-6
lines changed

sycl/source/detail/buffer_impl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ void *buffer_impl::allocateMem(ContextImplPtr Context, bool InitFromUserData,
2424
void *HostPtr,
2525
ur_event_handle_t &OutEventToWait) {
2626
bool HostPtrReadOnly = false;
27-
BaseT::determineHostPtr(InitFromUserData, HostPtr, HostPtrReadOnly);
27+
BaseT::determineHostPtr(Context, InitFromUserData, HostPtr, HostPtrReadOnly);
2828
assert(!(nullptr == HostPtr && BaseT::useHostPtr() && !Context) &&
2929
"Internal error. Allocating memory on the host "
3030
"while having use_host_ptr property");

sycl/source/detail/image_impl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ void *image_impl::allocateMem(ContextImplPtr Context, bool InitFromUserData,
327327
void *HostPtr,
328328
ur_event_handle_t &OutEventToWait) {
329329
bool HostPtrReadOnly = false;
330-
BaseT::determineHostPtr(InitFromUserData, HostPtr, HostPtrReadOnly);
330+
BaseT::determineHostPtr(Context, InitFromUserData, HostPtr, HostPtrReadOnly);
331331

332332
ur_image_desc_t Desc = getImageDesc(HostPtr != nullptr);
333333
assert(checkImageDesc(Desc, Context, HostPtr) &&

sycl/source/detail/sycl_mem_obj_t.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,8 @@ SYCLMemObjT::SYCLMemObjT(ur_native_handle_t MemObject,
107107
sizeof(Context), &Context, nullptr);
108108

109109
if (MInteropContext->getHandleRef() != Context)
110-
throw sycl::exception(make_error_code(errc::invalid),
110+
throw sycl::exception(
111+
make_error_code(errc::invalid),
111112
"Input context must be the same as the context of cl_mem");
112113

113114
if (MInteropContext->getBackend() == backend::opencl)
@@ -175,7 +176,8 @@ size_t SYCLMemObjT::getBufSizeForContext(const ContextImplPtr &Context,
175176

176177
bool SYCLMemObjT::isInterop() const { return MOpenCLInterop; }
177178

178-
void SYCLMemObjT::determineHostPtr(bool InitFromUserData, void *&HostPtr,
179+
void SYCLMemObjT::determineHostPtr(const ContextImplPtr &Context,
180+
bool InitFromUserData, void *&HostPtr,
179181
bool &HostPtrReadOnly) {
180182
// The data for the allocation can be provided via either the user pointer
181183
// (InitFromUserData, can be read-only) or a runtime-allocated read-write
@@ -186,6 +188,8 @@ void SYCLMemObjT::determineHostPtr(bool InitFromUserData, void *&HostPtr,
186188
// 2. The allocation is not the first one and not on host. InitFromUserData ==
187189
// false, HostPtr is provided if the command is linked. The host pointer is
188190
// guaranteed to be reused in this case.
191+
if (!Context && !MOpenCLInterop && !MHostPtrReadOnly)
192+
InitFromUserData = true;
189193

190194
if (InitFromUserData) {
191195
assert(!HostPtr && "Cannot init from user data and reuse host ptr provided "

sycl/source/detail/sycl_mem_obj_t.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -327,8 +327,8 @@ class SYCLMemObjT : public SYCLMemObjI {
327327

328328
protected:
329329
// An allocateMem helper that determines which host ptr to use
330-
void determineHostPtr(bool InitFromUserData, void *&HostPtr,
331-
bool &HostPtrReadOnly);
330+
void determineHostPtr(const ContextImplPtr &Context, bool InitFromUserData,
331+
void *&HostPtr, bool &HostPtrReadOnly);
332332

333333
// Allocator used for allocation memory on host.
334334
std::unique_ptr<SYCLMemObjAllocator> MAllocator;

0 commit comments

Comments
 (0)