diff --git a/sycl/include/sycl/ext/oneapi/memcpy2d.hpp b/sycl/include/sycl/ext/oneapi/memcpy2d.hpp index cfbe0a36ab0b4..fa0b1299fe767 100644 --- a/sycl/include/sycl/ext/oneapi/memcpy2d.hpp +++ b/sycl/include/sycl/ext/oneapi/memcpy2d.hpp @@ -34,7 +34,7 @@ void handler::ext_oneapi_memcpy2d(void *Dest, size_t DestPitch, const void *Src, #endif // Get the type of the pointers. - context Ctx = detail::createSyclObjFromImpl(getContextImplPtr()); + detail::context_impl &Ctx = getContextImpl(); usm::alloc SrcAllocType = get_pointer_type(Src, Ctx); usm::alloc DestAllocType = get_pointer_type(Dest, Ctx); bool SrcIsHost = @@ -71,7 +71,7 @@ void handler::ext_oneapi_copy2d(const T *Src, size_t SrcPitch, T *Dest, "to the width specified in 'ext_oneapi_copy2d'"); // Get the type of the pointers. - context Ctx = detail::createSyclObjFromImpl(getContextImplPtr()); + detail::context_impl &Ctx = getContextImpl(); usm::alloc SrcAllocType = get_pointer_type(Src, Ctx); usm::alloc DestAllocType = get_pointer_type(Dest, Ctx); bool SrcIsHost = @@ -106,7 +106,7 @@ void handler::ext_oneapi_memset2d(void *Dest, size_t DestPitch, int Value, "to the width specified in 'ext_oneapi_memset2d'"); T CharVal = static_cast(Value); - context Ctx = detail::createSyclObjFromImpl(getContextImplPtr()); + detail::context_impl &Ctx = getContextImpl(); usm::alloc DestAllocType = get_pointer_type(Dest, Ctx); // If the backends supports 2D fill we use that. Otherwise we use a fallback @@ -130,7 +130,7 @@ void handler::ext_oneapi_fill2d(void *Dest, size_t DestPitch, const T &Pattern, "Destination pitch must be greater than or equal " "to the width specified in 'ext_oneapi_fill2d'"); - context Ctx = detail::createSyclObjFromImpl(getContextImplPtr()); + detail::context_impl &Ctx = getContextImpl(); usm::alloc DestAllocType = get_pointer_type(Dest, Ctx); // If the backends supports 2D fill we use that. Otherwise we use a fallback diff --git a/sycl/include/sycl/handler.hpp b/sycl/include/sycl/handler.hpp index 1736cf5719940..276044efab979 100644 --- a/sycl/include/sycl/handler.hpp +++ b/sycl/include/sycl/handler.hpp @@ -3546,6 +3546,7 @@ class __SYCL_EXPORT handler { } const std::shared_ptr &getContextImplPtr() const; + detail::context_impl &getContextImpl() const; // Checks if 2D memory operations are supported by the underlying platform. bool supportsUSMMemcpy2D(); diff --git a/sycl/include/sycl/usm/usm_pointer_info.hpp b/sycl/include/sycl/usm/usm_pointer_info.hpp index a00e125c019b1..b16c183e71578 100644 --- a/sycl/include/sycl/usm/usm_pointer_info.hpp +++ b/sycl/include/sycl/usm/usm_pointer_info.hpp @@ -16,12 +16,23 @@ inline namespace _V1 { class device; class context; +namespace detail { +class context_impl; +__SYCL_EXPORT usm::alloc get_pointer_type(const void *ptr, context_impl &ctxt); +} // namespace detail + // Pointer queries /// Query the allocation type from a USM pointer /// /// \param ptr is the USM pointer to query /// \param ctxt is the sycl context the ptr was allocated in +#ifdef __INTEL_PREVIEW_BREAKING_CHANGES +inline usm::alloc get_pointer_type(const void *ptr, const context &ctxt) { + return get_pointer_type(ptr, *getSyclObjImpl(ctxt)); +} +#else __SYCL_EXPORT usm::alloc get_pointer_type(const void *ptr, const context &ctxt); +#endif /// Queries the device against which the pointer was allocated /// Throws an exception with errc::invalid error code if ptr is a host diff --git a/sycl/source/detail/context_impl.hpp b/sycl/source/detail/context_impl.hpp index 3f93b1b03721b..ba320c90d8598 100644 --- a/sycl/source/detail/context_impl.hpp +++ b/sycl/source/detail/context_impl.hpp @@ -364,12 +364,14 @@ void GetCapabilitiesIntersectionSet(const std::vector &Devices, // We're under sycl/source and these won't be exported but it's way more // convenient to be able to reference them without extra `detail::`. -inline auto get_ur_handles(const sycl::context &syclContext) { - sycl::detail::context_impl &Ctx = *sycl::detail::getSyclObjImpl(syclContext); +inline auto get_ur_handles(sycl::detail::context_impl &Ctx) { ur_context_handle_t urCtx = Ctx.getHandleRef(); const sycl::detail::Adapter *Adapter = Ctx.getAdapter().get(); return std::tuple{urCtx, Adapter}; } +inline auto get_ur_handles(const sycl::context &syclContext) { + return get_ur_handles(*sycl::detail::getSyclObjImpl(syclContext)); +} inline auto get_ur_handles(const sycl::device &syclDevice, const sycl::context &syclContext) { auto [urCtx, Adapter] = get_ur_handles(syclContext); diff --git a/sycl/source/detail/usm/usm_impl.cpp b/sycl/source/detail/usm/usm_impl.cpp index 1ea02f73b3846..aa62c4756dbd2 100644 --- a/sycl/source/detail/usm/usm_impl.cpp +++ b/sycl/source/detail/usm/usm_impl.cpp @@ -518,7 +518,8 @@ void *aligned_alloc(size_t Alignment, size_t Size, const queue &Q, alloc Kind, /// /// \param Ptr is the USM pointer to query /// \param Ctxt is the sycl context the ptr was allocated in -alloc get_pointer_type(const void *Ptr, const context &Ctxt) { +namespace detail { +alloc get_pointer_type(const void *Ptr, context_impl &Ctxt) { if (!Ptr) return alloc::unknown; @@ -559,6 +560,12 @@ alloc get_pointer_type(const void *Ptr, const context &Ctxt) { return ResultAlloc; } +} // namespace detail +#ifndef __INTEL_PREVIEW_BREAKING_CHANGES +__SYCL_EXPORT alloc get_pointer_type(const void *Ptr, const context &Ctxt) { + return get_pointer_type(Ptr, *getSyclObjImpl(Ctxt)); +} +#endif /// Queries the device against which the pointer was allocated /// diff --git a/sycl/source/handler.cpp b/sycl/source/handler.cpp index 7959442d78dea..d8b4614cd71c3 100644 --- a/sycl/source/handler.cpp +++ b/sycl/source/handler.cpp @@ -2214,6 +2214,13 @@ handler::getContextImplPtr() const { return impl->get_queue().getContextImplPtr(); } +detail::context_impl &handler::getContextImpl() const { + if (auto *Graph = impl->get_graph_or_null()) { + return *Graph->getContextImplPtr(); + } + return impl->get_queue().getContextImpl(); +} + void handler::setKernelCacheConfig(handler::StableKernelCacheConfig Config) { switch (Config) { case handler::StableKernelCacheConfig::Default: diff --git a/sycl/test/abi/sycl_symbols_linux.dump b/sycl/test/abi/sycl_symbols_linux.dump index 0fc1af0bafe99..a8aabfd389f4d 100644 --- a/sycl/test/abi/sycl_symbols_linux.dump +++ b/sycl/test/abi/sycl_symbols_linux.dump @@ -3298,6 +3298,7 @@ _ZN4sycl3_V16detail16AccessorBaseHostC1ENS0_2idILi3EEENS0_5rangeILi3EEES6_NS0_6a _ZN4sycl3_V16detail16AccessorBaseHostC1ENS0_2idILi3EEENS0_5rangeILi3EEES6_NS0_6access4modeEPviimbRKNS0_13property_listE _ZN4sycl3_V16detail16AccessorBaseHostC2ENS0_2idILi3EEENS0_5rangeILi3EEES6_NS0_6access4modeEPviibmbRKNS0_13property_listE _ZN4sycl3_V16detail16AccessorBaseHostC2ENS0_2idILi3EEENS0_5rangeILi3EEES6_NS0_6access4modeEPviimbRKNS0_13property_listE +_ZN4sycl3_V16detail16get_pointer_typeEPKvRNS1_12context_implE _ZN4sycl3_V16detail16reduGetMaxWGSizeERNS0_7handlerEm _ZN4sycl3_V16detail16reduGetMaxWGSizeESt10shared_ptrINS1_10queue_implEEm _ZN4sycl3_V16detail17HostProfilingInfo3endEv @@ -4082,6 +4083,7 @@ _ZNK4sycl3_V17context8get_infoINS0_4info7context7devicesEEENS0_6detail20is_conte _ZNK4sycl3_V17context8get_infoINS0_4info7context8platformEEENS0_6detail20is_context_info_descIT_E11return_typeEv _ZNK4sycl3_V17context9getNativeEv _ZNK4sycl3_V17handler11eventNeededEv +_ZNK4sycl3_V17handler14getContextImplEv _ZNK4sycl3_V17handler15getCommandGraphEv _ZNK4sycl3_V17handler15getKernelBundleEv _ZNK4sycl3_V17handler16getDeviceBackendEv diff --git a/sycl/test/abi/sycl_symbols_windows.dump b/sycl/test/abi/sycl_symbols_windows.dump index 0b198da691920..f1bd500a1516c 100644 --- a/sycl/test/abi/sycl_symbols_windows.dump +++ b/sycl/test/abi/sycl_symbols_windows.dump @@ -4054,6 +4054,7 @@ ?getChannelType@UnsampledImageAccessorBaseHost@detail@_V1@sycl@@QEBA?AW4image_channel_type@34@XZ ?getChannelType@image_plain@detail@_V1@sycl@@IEBA?AW4image_channel_type@34@XZ ?getCommandGraph@handler@_V1@sycl@@AEBA?AV?$shared_ptr@Vgraph_impl@detail@experimental@oneapi@ext@_V1@sycl@@@std@@XZ +?getContextImpl@handler@_V1@sycl@@AEBAAEAVcontext_impl@detail@23@XZ ?getContextImplPtr@handler@_V1@sycl@@AEBAAEBV?$shared_ptr@Vcontext_impl@detail@_V1@sycl@@@std@@XZ ?getCurrentDSODir@OSUtil@detail@_V1@sycl@@SA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ ?getDeviceBackend@handler@_V1@sycl@@AEBA?AW4backend@23@XZ @@ -4207,6 +4208,7 @@ ?get_platforms@platform@_V1@sycl@@SA?AV?$vector@Vplatform@_V1@sycl@@V?$allocator@Vplatform@_V1@sycl@@@std@@@std@@XZ ?get_pointer_device@_V1@sycl@@YA?AVdevice@12@PEBXAEBVcontext@12@@Z ?get_pointer_type@_V1@sycl@@YA?AW4alloc@usm@12@PEBXAEBVcontext@12@@Z +?get_pointer_type@detail@_V1@sycl@@YA?AW4alloc@usm@23@PEBXAEAVcontext_impl@123@@Z ?get_precision@stream@_V1@sycl@@QEBA_KXZ ?get_predecessors@node@experimental@oneapi@ext@_V1@sycl@@QEBA?AV?$vector@Vnode@experimental@oneapi@ext@_V1@sycl@@V?$allocator@Vnode@experimental@oneapi@ext@_V1@sycl@@@std@@@std@@XZ ?get_queue@fusion_wrapper@experimental@codeplay@ext@_V1@sycl@@QEBA?AVqueue@56@XZ