Skip to content

Commit a1d0874

Browse files
[NFC][SYCL] Use plan context_impl & in sycl/ext/oneapi/memcpy2d.hpp
Continuation of the refactoring in #18795 #18877 #18966 #18979 #18980 #18981 #19007
1 parent c72f681 commit a1d0874

File tree

7 files changed

+37
-6
lines changed

7 files changed

+37
-6
lines changed

sycl/include/sycl/ext/oneapi/memcpy2d.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ void handler::ext_oneapi_memcpy2d(void *Dest, size_t DestPitch, const void *Src,
3434
#endif
3535

3636
// Get the type of the pointers.
37-
context Ctx = detail::createSyclObjFromImpl<context>(getContextImplPtr());
37+
detail::context_impl &Ctx = getContextImpl();
3838
usm::alloc SrcAllocType = get_pointer_type(Src, Ctx);
3939
usm::alloc DestAllocType = get_pointer_type(Dest, Ctx);
4040
bool SrcIsHost =
@@ -71,7 +71,7 @@ void handler::ext_oneapi_copy2d(const T *Src, size_t SrcPitch, T *Dest,
7171
"to the width specified in 'ext_oneapi_copy2d'");
7272

7373
// Get the type of the pointers.
74-
context Ctx = detail::createSyclObjFromImpl<context>(getContextImplPtr());
74+
detail::context_impl &Ctx = getContextImpl();
7575
usm::alloc SrcAllocType = get_pointer_type(Src, Ctx);
7676
usm::alloc DestAllocType = get_pointer_type(Dest, Ctx);
7777
bool SrcIsHost =
@@ -106,7 +106,7 @@ void handler::ext_oneapi_memset2d(void *Dest, size_t DestPitch, int Value,
106106
"to the width specified in 'ext_oneapi_memset2d'");
107107
T CharVal = static_cast<T>(Value);
108108

109-
context Ctx = detail::createSyclObjFromImpl<context>(getContextImplPtr());
109+
detail::context_impl &Ctx = getContextImpl();
110110
usm::alloc DestAllocType = get_pointer_type(Dest, Ctx);
111111

112112
// If the backends supports 2D fill we use that. Otherwise we use a fallback

sycl/include/sycl/handler.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3531,6 +3531,7 @@ class __SYCL_EXPORT handler {
35313531
}
35323532

35333533
const std::shared_ptr<detail::context_impl> &getContextImplPtr() const;
3534+
detail::context_impl &getContextImpl() const;
35343535

35353536
// Checks if 2D memory operations are supported by the underlying platform.
35363537
bool supportsUSMMemcpy2D();

sycl/include/sycl/usm/usm_pointer_info.hpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,23 @@ inline namespace _V1 {
1616
class device;
1717
class context;
1818

19+
namespace detail {
20+
class context_impl;
21+
__SYCL_EXPORT usm::alloc get_pointer_type(const void *ptr, context_impl &ctxt);
22+
}
23+
1924
// Pointer queries
2025
/// Query the allocation type from a USM pointer
2126
///
2227
/// \param ptr is the USM pointer to query
2328
/// \param ctxt is the sycl context the ptr was allocated in
29+
#ifdef __INTEL_PREVIEW_BREAKING_CHANGES
30+
inline usm::alloc get_pointer_type(const void *ptr, const context &ctxt) {
31+
return get_pointer_type(ptr, *getSyclObjImpl(ctxt));
32+
}
33+
#else
2434
__SYCL_EXPORT usm::alloc get_pointer_type(const void *ptr, const context &ctxt);
35+
#endif
2536

2637
/// Queries the device against which the pointer was allocated
2738
/// Throws an exception with errc::invalid error code if ptr is a host

sycl/source/detail/context_impl.hpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -364,12 +364,14 @@ void GetCapabilitiesIntersectionSet(const std::vector<sycl::device> &Devices,
364364

365365
// We're under sycl/source and these won't be exported but it's way more
366366
// convenient to be able to reference them without extra `detail::`.
367-
inline auto get_ur_handles(const sycl::context &syclContext) {
368-
sycl::detail::context_impl &Ctx = *sycl::detail::getSyclObjImpl(syclContext);
367+
inline auto get_ur_handles(sycl::detail::context_impl &Ctx) {
369368
ur_context_handle_t urCtx = Ctx.getHandleRef();
370369
const sycl::detail::Adapter *Adapter = Ctx.getAdapter().get();
371370
return std::tuple{urCtx, Adapter};
372371
}
372+
inline auto get_ur_handles(const sycl::context &syclContext) {
373+
return get_ur_handles(*sycl::detail::getSyclObjImpl(syclContext));
374+
}
373375
inline auto get_ur_handles(const sycl::device &syclDevice,
374376
const sycl::context &syclContext) {
375377
auto [urCtx, Adapter] = get_ur_handles(syclContext);

sycl/source/detail/usm/usm_impl.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,8 @@ void *aligned_alloc(size_t Alignment, size_t Size, const queue &Q, alloc Kind,
518518
///
519519
/// \param Ptr is the USM pointer to query
520520
/// \param Ctxt is the sycl context the ptr was allocated in
521-
alloc get_pointer_type(const void *Ptr, const context &Ctxt) {
521+
namespace detail {
522+
alloc get_pointer_type(const void *Ptr, context_impl &Ctxt) {
522523
if (!Ptr)
523524
return alloc::unknown;
524525

@@ -559,6 +560,12 @@ alloc get_pointer_type(const void *Ptr, const context &Ctxt) {
559560

560561
return ResultAlloc;
561562
}
563+
} // namespace detail
564+
#ifndef __INTEL_PREVIEW_BREAKING_CHANGES
565+
__SYCL_EXPORT alloc get_pointer_type(const void *Ptr, const context &Ctxt) {
566+
return get_pointer_type(Ptr, *getSyclObjImpl(Ctxt));
567+
}
568+
#endif
562569

563570
/// Queries the device against which the pointer was allocated
564571
///

sycl/source/handler.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2184,6 +2184,14 @@ handler::getContextImplPtr() const {
21842184
return impl->get_queue().getContextImplPtr();
21852185
}
21862186

2187+
detail::context_impl &
2188+
handler::getContextImpl() const {
2189+
if (auto *Graph = impl->get_graph_or_null()) {
2190+
return *Graph->getContextImplPtr();
2191+
}
2192+
return impl->get_queue().getContextImpl();
2193+
}
2194+
21872195
void handler::setKernelCacheConfig(handler::StableKernelCacheConfig Config) {
21882196
switch (Config) {
21892197
case handler::StableKernelCacheConfig::Default:

sycl/test/abi/sycl_symbols_linux.dump

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3298,6 +3298,7 @@ _ZN4sycl3_V16detail16AccessorBaseHostC1ENS0_2idILi3EEENS0_5rangeILi3EEES6_NS0_6a
32983298
_ZN4sycl3_V16detail16AccessorBaseHostC1ENS0_2idILi3EEENS0_5rangeILi3EEES6_NS0_6access4modeEPviimbRKNS0_13property_listE
32993299
_ZN4sycl3_V16detail16AccessorBaseHostC2ENS0_2idILi3EEENS0_5rangeILi3EEES6_NS0_6access4modeEPviibmbRKNS0_13property_listE
33003300
_ZN4sycl3_V16detail16AccessorBaseHostC2ENS0_2idILi3EEENS0_5rangeILi3EEES6_NS0_6access4modeEPviimbRKNS0_13property_listE
3301+
_ZN4sycl3_V16detail16get_pointer_typeEPKvRNS1_12context_implE
33013302
_ZN4sycl3_V16detail16reduGetMaxWGSizeERNS0_7handlerEm
33023303
_ZN4sycl3_V16detail16reduGetMaxWGSizeESt10shared_ptrINS1_10queue_implEEm
33033304
_ZN4sycl3_V16detail17HostProfilingInfo3endEv
@@ -4082,6 +4083,7 @@ _ZNK4sycl3_V17context8get_infoINS0_4info7context7devicesEEENS0_6detail20is_conte
40824083
_ZNK4sycl3_V17context8get_infoINS0_4info7context8platformEEENS0_6detail20is_context_info_descIT_E11return_typeEv
40834084
_ZNK4sycl3_V17context9getNativeEv
40844085
_ZNK4sycl3_V17handler11eventNeededEv
4086+
_ZNK4sycl3_V17handler14getContextImplEv
40854087
_ZNK4sycl3_V17handler15getCommandGraphEv
40864088
_ZNK4sycl3_V17handler16getDeviceBackendEv
40874089
_ZNK4sycl3_V17handler17getContextImplPtrEv

0 commit comments

Comments
 (0)