From e1ea2c8dcef55c8952d4950dd838e2279203b4b0 Mon Sep 17 00:00:00 2001 From: mdimakov Date: Sat, 20 Feb 2021 17:01:07 +0300 Subject: [PATCH 01/19] [SYCL] Fix get_native() and add get_backend() accordingly to the specification Signed-off-by: mdimakov --- sycl/include/CL/sycl/backend.hpp | 1 + sycl/include/CL/sycl/backend/opencl.hpp | 4 ++++ sycl/include/CL/sycl/context.hpp | 5 +++++ sycl/include/CL/sycl/device.hpp | 5 +++++ sycl/include/CL/sycl/event.hpp | 7 ++++++- sycl/include/CL/sycl/program.hpp | 5 +++++ sycl/include/CL/sycl/queue.hpp | 5 +++++ sycl/source/context.cpp | 2 ++ sycl/source/detail/context_impl.cpp | 2 ++ sycl/source/detail/context_impl.hpp | 14 ++++++++++++++ sycl/source/detail/device_impl.cpp | 2 ++ sycl/source/detail/device_impl.hpp | 14 ++++++++++++++ sycl/source/detail/event_impl.cpp | 25 +++++++++++++++++++------ sycl/source/detail/event_impl.hpp | 4 ++++ sycl/source/detail/program_impl.cpp | 2 ++ sycl/source/detail/program_impl.hpp | 14 ++++++++++++++ sycl/source/detail/queue_impl.cpp | 2 ++ sycl/source/detail/queue_impl.hpp | 13 +++++++++++++ sycl/source/device.cpp | 2 ++ sycl/source/event.cpp | 2 ++ sycl/source/program.cpp | 2 ++ sycl/source/queue.cpp | 2 ++ 22 files changed, 127 insertions(+), 7 deletions(-) diff --git a/sycl/include/CL/sycl/backend.hpp b/sycl/include/CL/sycl/backend.hpp index 9edca021dca6b..e4bf93499dc85 100644 --- a/sycl/include/CL/sycl/backend.hpp +++ b/sycl/include/CL/sycl/backend.hpp @@ -17,6 +17,7 @@ namespace sycl { template auto get_native(const SyclObjectT &Obj) -> typename interop::type { + assert (Obj.get_backend() == BackendName && "Current and submitted backends are different"); return Obj.template get_native(); } diff --git a/sycl/include/CL/sycl/backend/opencl.hpp b/sycl/include/CL/sycl/backend/opencl.hpp index abd406260eb80..0daa45839312f 100644 --- a/sycl/include/CL/sycl/backend/opencl.hpp +++ b/sycl/include/CL/sycl/backend/opencl.hpp @@ -36,6 +36,10 @@ template <> struct interop { using type = cl_program; }; +template <> struct interop { + using type = cl_event; +}; + template struct interop get_devices(info::device_type deviceType = info::device_type::all); + /// Returns the backend associated with this device. + /// + /// \return the backend associated with this device. + backend get_backend() const noexcept; + /// Gets the native handle of the SYCL device. /// /// \return a native handle, the type of which defined by the backend. diff --git a/sycl/include/CL/sycl/event.hpp b/sycl/include/CL/sycl/event.hpp index 2b96d9e547faa..5902a44be06a9 100644 --- a/sycl/include/CL/sycl/event.hpp +++ b/sycl/include/CL/sycl/event.hpp @@ -118,12 +118,17 @@ class __SYCL_EXPORT event { typename info::param_traits::return_type get_profiling_info() const; + /// Returns the backend associated with this platform. + /// + /// \return the backend associated with this platform + backend get_backend() const noexcept; + /// Gets the native handle of the SYCL event. /// /// \return a native handle, the type of which defined by the backend. template auto get_native() const -> typename interop::type { - return static_cast::type>(getNative()); + return reinterpret_cast::type>(getNative()); } private: diff --git a/sycl/include/CL/sycl/program.hpp b/sycl/include/CL/sycl/program.hpp index e97c109ee9c61..f041c2f695fdc 100644 --- a/sycl/include/CL/sycl/program.hpp +++ b/sycl/include/CL/sycl/program.hpp @@ -356,6 +356,11 @@ class __SYCL_EXPORT program { #endif // __SYCL_DEVICE_ONLY__ } + /// Returns the backend associated with this program. + /// + /// \return the backend associated with this program. + backend get_backend() const noexcept; + /// Gets the native handle of the SYCL platform. /// /// \return a native handle, the type of which defined by the backend. diff --git a/sycl/include/CL/sycl/queue.hpp b/sycl/include/CL/sycl/queue.hpp index 5cca7be19772b..a1c49a05043be 100644 --- a/sycl/include/CL/sycl/queue.hpp +++ b/sycl/include/CL/sycl/queue.hpp @@ -750,6 +750,11 @@ class __SYCL_EXPORT queue { /// Equivalent to has_property() bool is_in_order() const; + /// Returns the backend associated with this queue. + /// + /// \return the backend associated with this queue. + backend get_backend() const noexcept; + /// Gets the native handle of the SYCL queue. /// /// \return a native handle, the type of which defined by the backend. diff --git a/sycl/source/context.cpp b/sycl/source/context.cpp index 5e30d0bd955f2..f45201a5446d2 100644 --- a/sycl/source/context.cpp +++ b/sycl/source/context.cpp @@ -117,6 +117,8 @@ cl_context context::get() const { return impl->get(); } bool context::is_host() const { return impl->is_host(); } +backend context::get_backend() const noexcept { return impl->get_backend(); } + platform context::get_platform() const { return impl->get_info(); } diff --git a/sycl/source/detail/context_impl.cpp b/sycl/source/detail/context_impl.cpp index 666f12b226e61..d5ed47992fc88 100644 --- a/sycl/source/detail/context_impl.cpp +++ b/sycl/source/detail/context_impl.cpp @@ -163,6 +163,8 @@ context_impl::hasDevice(shared_ptr_class Device) const { pi_native_handle context_impl::getNative() const { auto Plugin = getPlugin(); + if (Plugin.getBackend() == backend::opencl) + Plugin.call(getHandleRef()); pi_native_handle Handle; Plugin.call(getHandleRef(), &Handle); return Handle; diff --git a/sycl/source/detail/context_impl.hpp b/sycl/source/detail/context_impl.hpp index 967c4a6cffcbe..1b3dc147bf506 100644 --- a/sycl/source/detail/context_impl.hpp +++ b/sycl/source/detail/context_impl.hpp @@ -98,6 +98,20 @@ class context_impl { /// \return true if this context is a host context. bool is_host() const; + /// Returns the backend associated with this context. + /// + /// \return the backend associated with this context. + backend get_backend() const noexcept { + backend Result; + if (is_host()) + Result = backend::host; + else { + Result = getPlugin().getBackend(); + } + + return Result; + } + /// Gets asynchronous exception handler. /// /// \return an instance of SYCL async_handler. diff --git a/sycl/source/detail/device_impl.cpp b/sycl/source/detail/device_impl.cpp index 7343954313c16..5e4c0c4b9d42e 100644 --- a/sycl/source/detail/device_impl.cpp +++ b/sycl/source/detail/device_impl.cpp @@ -209,6 +209,8 @@ vector_class device_impl::create_sub_devices( pi_native_handle device_impl::getNative() const { auto Plugin = getPlugin(); + if (Plugin.getBackend() == backend::opencl) + Plugin.call(getHandleRef()); pi_native_handle Handle; Plugin.call(getHandleRef(), &Handle); return Handle; diff --git a/sycl/source/detail/device_impl.hpp b/sycl/source/detail/device_impl.hpp index 0e1381f933964..dd8084845d7d8 100644 --- a/sycl/source/detail/device_impl.hpp +++ b/sycl/source/detail/device_impl.hpp @@ -204,6 +204,20 @@ class device_impl { bool is_affinity_supported(info::partition_affinity_domain AffinityDomain) const; + /// Returns the backend associated with this device. + /// + // \return the Backend associated with this platform. + backend get_backend() const noexcept { + backend Result; + if (is_host()) + Result = backend::host; + else { + Result = getPlugin().getBackend(); + } + + return Result; + } + /// Gets the native handle of the SYCL device. /// /// \return a native handle. diff --git a/sycl/source/detail/event_impl.cpp b/sycl/source/detail/event_impl.cpp index d034a259d136c..81a4ce5d3053d 100644 --- a/sycl/source/detail/event_impl.cpp +++ b/sycl/source/detail/event_impl.cpp @@ -290,12 +290,25 @@ void HostProfilingInfo::start() { StartTime = getTimestamp(); } void HostProfilingInfo::end() { EndTime = getTimestamp(); } -pi_native_handle event_impl::getNative() const { - auto Plugin = getPlugin(); - pi_native_handle Handle; - Plugin.call(getHandleRef(), &Handle); - return Handle; -} + backend event_impl::get_backend() const noexcept { + backend Result; + if (is_host()) + Result = backend::host; + else { + Result = getPlugin().getBackend(); + } + + return Result; + } + + pi_native_handle event_impl::getNative() const { + auto Plugin = getPlugin(); + if (Plugin.getBackend() == backend::opencl) + Plugin.call(getHandleRef()); + pi_native_handle Handle; + Plugin.call(getHandleRef(), &Handle); + return Handle; + } } // namespace detail } // namespace sycl diff --git a/sycl/source/detail/event_impl.hpp b/sycl/source/detail/event_impl.hpp index 4b291159c8e4f..67ae29faa5777 100644 --- a/sycl/source/detail/event_impl.hpp +++ b/sycl/source/detail/event_impl.hpp @@ -149,6 +149,10 @@ class event_impl { /// @return a pointer to HostProfilingInfo instance. HostProfilingInfo *getHostProfilingInfo() { return MHostProfilingInfo.get(); } + /// Returns the backend associated with this event. + /// + /// \return the backend associated with this event. + backend get_backend() const noexcept; /// Gets the native handle of the SYCL event. /// /// \return a native handle. diff --git a/sycl/source/detail/program_impl.cpp b/sycl/source/detail/program_impl.cpp index ec41944559d7a..1e3a579ce06ad 100644 --- a/sycl/source/detail/program_impl.cpp +++ b/sycl/source/detail/program_impl.cpp @@ -583,6 +583,8 @@ void program_impl::flush_spec_constants(const RTDeviceBinaryImage &Img, pi_native_handle program_impl::getNative() const { const auto &Plugin = getPlugin(); + if (Plugin.getBackend() == backend::opencl) + Plugin.call(MProgram); pi_native_handle Handle; Plugin.call(MProgram, &Handle); return Handle; diff --git a/sycl/source/detail/program_impl.hpp b/sycl/source/detail/program_impl.hpp index 822e70e8f0769..3887e66abe1b0 100644 --- a/sycl/source/detail/program_impl.hpp +++ b/sycl/source/detail/program_impl.hpp @@ -340,6 +340,20 @@ class program_impl { /// \return true if caching is allowed for this program. bool is_cacheable() const { return MProgramAndKernelCachingAllowed; } + /// Returns the backend associated with this context. + /// + /// \return the backend associated with this context. + backend get_backend() const noexcept { + backend Result; + if (is_host()) + Result = backend::host; + else { + Result = getPlugin().getBackend(); + } + + return Result; + } + /// Returns the native plugin handle. pi_native_handle getNative() const; diff --git a/sycl/source/detail/queue_impl.cpp b/sycl/source/detail/queue_impl.cpp index 9d4fe1bcc36d0..bcbe28720ac56 100644 --- a/sycl/source/detail/queue_impl.cpp +++ b/sycl/source/detail/queue_impl.cpp @@ -273,6 +273,8 @@ void queue_impl::initHostTaskAndEventCallbackThreadPool() { pi_native_handle queue_impl::getNative() const { const detail::plugin &Plugin = getPlugin(); + if (Plugin.getBackend() == backend::opencl) + Plugin.call(MQueues[0]); pi_native_handle Handle{}; Plugin.call(MQueues[0], &Handle); return Handle; diff --git a/sycl/source/detail/queue_impl.hpp b/sycl/source/detail/queue_impl.hpp index c4e01a61ad8cb..8567f8f0fa0aa 100644 --- a/sycl/source/detail/queue_impl.hpp +++ b/sycl/source/detail/queue_impl.hpp @@ -371,6 +371,19 @@ class queue_impl { MHostTaskThreadPool->finishAndWait(); } } + /// Returns the backend associated with this queue. + /// + /// \return the backend associated with this queue. + backend get_backend() const noexcept { + backend Result; + if (is_host()) + Result = backend::host; + else { + Result = getPlugin().getBackend(); + } + + return Result; + } /// Gets the native handle of the SYCL queue. /// diff --git a/sycl/source/device.cpp b/sycl/source/device.cpp index 57ca9f6190615..7b6d4929a767a 100644 --- a/sycl/source/device.cpp +++ b/sycl/source/device.cpp @@ -136,6 +136,8 @@ device::get_info() const { #undef __SYCL_PARAM_TRAITS_SPEC +backend device::get_backend() const noexcept { return impl->get_backend(); } + pi_native_handle device::getNative() const { return impl->getNative(); } bool device::has(aspect Aspect) const { return impl->has(Aspect); } diff --git a/sycl/source/event.cpp b/sycl/source/event.cpp index fa36438ae09b5..62e236fc5b218 100644 --- a/sycl/source/event.cpp +++ b/sycl/source/event.cpp @@ -85,6 +85,8 @@ event::event(shared_ptr_class event_impl) #undef __SYCL_PARAM_TRAITS_SPEC +backend event::get_backend() const noexcept { return impl->get_backend(); } + pi_native_handle event::getNative() const { return impl->getNative(); } } // namespace sycl diff --git a/sycl/source/program.cpp b/sycl/source/program.cpp index c7a33d7ba8d1b..5566f45d7a954 100644 --- a/sycl/source/program.cpp +++ b/sycl/source/program.cpp @@ -47,6 +47,8 @@ program::program(const context &context, cl_program clProgram) clRetainProgram(clProgram); } +backend program::get_backend() const noexcept { return impl->get_backend(); } + pi_native_handle program::getNative() const { return impl->getNative(); } program::program(std::shared_ptr impl) : impl(impl) {} diff --git a/sycl/source/queue.cpp b/sycl/source/queue.cpp index a651d4a5d9236..e744934f17438 100644 --- a/sycl/source/queue.cpp +++ b/sycl/source/queue.cpp @@ -138,6 +138,8 @@ bool queue::is_in_order() const { return impl->has_property(); } +backend queue::get_backend() const noexcept { return impl->get_backend(); } + pi_native_handle queue::getNative() const { return impl->getNative(); } } // namespace sycl From 5cc520bac626b52355674edcb34ac843dd34d866 Mon Sep 17 00:00:00 2001 From: mdimakov Date: Sat, 20 Feb 2021 17:20:16 +0300 Subject: [PATCH 02/19] [SYCL] Clang-format fix Signed-off-by: mdimakov --- sycl/include/CL/sycl/backend.hpp | 3 ++- sycl/include/CL/sycl/backend/opencl.hpp | 4 +-- sycl/include/CL/sycl/event.hpp | 5 ++-- sycl/source/detail/event_impl.cpp | 34 ++++++++++++------------- sycl/source/detail/program_impl.hpp | 2 +- sycl/source/detail/queue_impl.hpp | 1 + 6 files changed, 25 insertions(+), 24 deletions(-) diff --git a/sycl/include/CL/sycl/backend.hpp b/sycl/include/CL/sycl/backend.hpp index e4bf93499dc85..720edcf758be0 100644 --- a/sycl/include/CL/sycl/backend.hpp +++ b/sycl/include/CL/sycl/backend.hpp @@ -17,7 +17,8 @@ namespace sycl { template auto get_native(const SyclObjectT &Obj) -> typename interop::type { - assert (Obj.get_backend() == BackendName && "Current and submitted backends are different"); + assert(Obj.get_backend() == BackendName && + "Current and submitted backends are different"); return Obj.template get_native(); } diff --git a/sycl/include/CL/sycl/backend/opencl.hpp b/sycl/include/CL/sycl/backend/opencl.hpp index 0daa45839312f..81e6a2de4b62e 100644 --- a/sycl/include/CL/sycl/backend/opencl.hpp +++ b/sycl/include/CL/sycl/backend/opencl.hpp @@ -36,9 +36,7 @@ template <> struct interop { using type = cl_program; }; -template <> struct interop { - using type = cl_event; -}; +template <> struct interop { using type = cl_event; }; template struct interop auto get_native() const -> typename interop::type { - return reinterpret_cast::type>(getNative()); + return reinterpret_cast::type>( + getNative()); } private: diff --git a/sycl/source/detail/event_impl.cpp b/sycl/source/detail/event_impl.cpp index 81a4ce5d3053d..77f2bf4fe5394 100644 --- a/sycl/source/detail/event_impl.cpp +++ b/sycl/source/detail/event_impl.cpp @@ -290,25 +290,25 @@ void HostProfilingInfo::start() { StartTime = getTimestamp(); } void HostProfilingInfo::end() { EndTime = getTimestamp(); } - backend event_impl::get_backend() const noexcept { - backend Result; - if (is_host()) - Result = backend::host; - else { - Result = getPlugin().getBackend(); - } - - return Result; +backend event_impl::get_backend() const noexcept { + backend Result; + if (is_host()) + Result = backend::host; + else { + Result = getPlugin().getBackend(); } - pi_native_handle event_impl::getNative() const { - auto Plugin = getPlugin(); - if (Plugin.getBackend() == backend::opencl) - Plugin.call(getHandleRef()); - pi_native_handle Handle; - Plugin.call(getHandleRef(), &Handle); - return Handle; - } + return Result; +} + +pi_native_handle event_impl::getNative() const { + auto Plugin = getPlugin(); + if (Plugin.getBackend() == backend::opencl) + Plugin.call(getHandleRef()); + pi_native_handle Handle; + Plugin.call(getHandleRef(), &Handle); + return Handle; +} } // namespace detail } // namespace sycl diff --git a/sycl/source/detail/program_impl.hpp b/sycl/source/detail/program_impl.hpp index 3887e66abe1b0..be77860d9f1f4 100644 --- a/sycl/source/detail/program_impl.hpp +++ b/sycl/source/detail/program_impl.hpp @@ -353,7 +353,7 @@ class program_impl { return Result; } - + /// Returns the native plugin handle. pi_native_handle getNative() const; diff --git a/sycl/source/detail/queue_impl.hpp b/sycl/source/detail/queue_impl.hpp index 8567f8f0fa0aa..003fe5f52dd66 100644 --- a/sycl/source/detail/queue_impl.hpp +++ b/sycl/source/detail/queue_impl.hpp @@ -371,6 +371,7 @@ class queue_impl { MHostTaskThreadPool->finishAndWait(); } } + /// Returns the backend associated with this queue. /// /// \return the backend associated with this queue. From b08fc229050036ed47e4cb61ff759b030f3c7963 Mon Sep 17 00:00:00 2001 From: mdimakov Date: Sat, 20 Feb 2021 17:27:56 +0300 Subject: [PATCH 03/19] [SYCL] Clang-format fix Signed-off-by: mdimakov --- sycl/source/detail/queue_impl.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sycl/source/detail/queue_impl.hpp b/sycl/source/detail/queue_impl.hpp index 003fe5f52dd66..1ab8267f63a66 100644 --- a/sycl/source/detail/queue_impl.hpp +++ b/sycl/source/detail/queue_impl.hpp @@ -371,8 +371,8 @@ class queue_impl { MHostTaskThreadPool->finishAndWait(); } } - - /// Returns the backend associated with this queue. + + /// Returns the backend associated with this queue. /// /// \return the backend associated with this queue. backend get_backend() const noexcept { From 3daa42391cd37f470d642d939c04047fd88e921c Mon Sep 17 00:00:00 2001 From: mdimakov Date: Wed, 24 Feb 2021 11:14:03 +0300 Subject: [PATCH 04/19] [SYCL] Adress to review comment Signed-off-by: mdimakov --- sycl/source/detail/context_impl.hpp | 3 +-- sycl/source/detail/device_impl.hpp | 3 +-- sycl/source/detail/event_impl.cpp | 3 +-- sycl/source/detail/platform_impl.hpp | 3 +-- sycl/source/detail/program_impl.hpp | 3 +-- sycl/source/detail/queue_impl.hpp | 3 +-- 6 files changed, 6 insertions(+), 12 deletions(-) diff --git a/sycl/source/detail/context_impl.hpp b/sycl/source/detail/context_impl.hpp index 1b3dc147bf506..fde72882ef502 100644 --- a/sycl/source/detail/context_impl.hpp +++ b/sycl/source/detail/context_impl.hpp @@ -105,9 +105,8 @@ class context_impl { backend Result; if (is_host()) Result = backend::host; - else { + else Result = getPlugin().getBackend(); - } return Result; } diff --git a/sycl/source/detail/device_impl.hpp b/sycl/source/detail/device_impl.hpp index dd8084845d7d8..f14702b8dcbda 100644 --- a/sycl/source/detail/device_impl.hpp +++ b/sycl/source/detail/device_impl.hpp @@ -211,9 +211,8 @@ class device_impl { backend Result; if (is_host()) Result = backend::host; - else { + else Result = getPlugin().getBackend(); - } return Result; } diff --git a/sycl/source/detail/event_impl.cpp b/sycl/source/detail/event_impl.cpp index 77f2bf4fe5394..a181ddea8feaf 100644 --- a/sycl/source/detail/event_impl.cpp +++ b/sycl/source/detail/event_impl.cpp @@ -294,9 +294,8 @@ backend event_impl::get_backend() const noexcept { backend Result; if (is_host()) Result = backend::host; - else { + else Result = getPlugin().getBackend(); - } return Result; } diff --git a/sycl/source/detail/platform_impl.hpp b/sycl/source/detail/platform_impl.hpp index a2a269ade0e96..c1f8cf6583dde 100644 --- a/sycl/source/detail/platform_impl.hpp +++ b/sycl/source/detail/platform_impl.hpp @@ -113,9 +113,8 @@ class platform_impl { backend Result; if (is_host()) Result = backend::host; - else { + else Result = getPlugin().getBackend(); - } return Result; } diff --git a/sycl/source/detail/program_impl.hpp b/sycl/source/detail/program_impl.hpp index be77860d9f1f4..85388bffc1725 100644 --- a/sycl/source/detail/program_impl.hpp +++ b/sycl/source/detail/program_impl.hpp @@ -347,9 +347,8 @@ class program_impl { backend Result; if (is_host()) Result = backend::host; - else { + else Result = getPlugin().getBackend(); - } return Result; } diff --git a/sycl/source/detail/queue_impl.hpp b/sycl/source/detail/queue_impl.hpp index 1ab8267f63a66..096df9588d56c 100644 --- a/sycl/source/detail/queue_impl.hpp +++ b/sycl/source/detail/queue_impl.hpp @@ -379,9 +379,8 @@ class queue_impl { backend Result; if (is_host()) Result = backend::host; - else { + else Result = getPlugin().getBackend(); - } return Result; } From c5f16968be2ede9346f3ee67d067f2b870d6a5a1 Mon Sep 17 00:00:00 2001 From: mdimakov Date: Wed, 24 Feb 2021 16:53:14 +0300 Subject: [PATCH 05/19] [SYCL] Sycl symbols was added --- sycl/test/abi/sycl_symbols_linux.dump | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/sycl/test/abi/sycl_symbols_linux.dump b/sycl/test/abi/sycl_symbols_linux.dump index 472f460b94c79..73c24266fa654 100644 --- a/sycl/test/abi/sycl_symbols_linux.dump +++ b/sycl/test/abi/sycl_symbols_linux.dump @@ -5,7 +5,6 @@ # RUN: env LLVM_BIN_PATH=%llvm_build_bin_dir python %sycl_tools_src_dir/abi_check.py --mode check_symbols --reference %s %sycl_libs_dir/libsycl.so # REQUIRES: linux -# UNSUPPORTED: libcxx _Z20__spirv_ocl_prefetchPKcm _Z21__spirv_MemoryBarrierN5__spv5ScopeEj @@ -3616,6 +3615,8 @@ _ZN2cl4sycl20aligned_alloc_sharedEmmRKNS0_5queueE _ZN2cl4sycl20aligned_alloc_sharedEmmRKNS0_6deviceERKNS0_7contextE _ZN2cl4sycl4freeEPvRKNS0_5queueE _ZN2cl4sycl4freeEPvRKNS0_7contextE +_ZN2cl4sycl5INTEL15online_compilerILNS1_15source_languageE0EE7compileIJSt6vectorINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaISC_EEEEES6_IhSaIhEERKSC_DpRKT_ +_ZN2cl4sycl5INTEL15online_compilerILNS1_15source_languageE1EE7compileIJSt6vectorINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaISC_EEEEES6_IhSaIhEERKSC_DpRKT_ _ZN2cl4sycl5event13get_wait_listEv _ZN2cl4sycl5event14wait_and_throwERKSt6vectorIS1_SaIS1_EE _ZN2cl4sycl5event14wait_and_throwEv @@ -3627,8 +3628,6 @@ _ZN2cl4sycl5eventC1Ev _ZN2cl4sycl5eventC2EP9_cl_eventRKNS0_7contextE _ZN2cl4sycl5eventC2ESt10shared_ptrINS0_6detail10event_implEE _ZN2cl4sycl5eventC2Ev -_ZN2cl4sycl5INTEL15online_compilerILNS1_15source_languageE0EE7compileIJSt6vectorINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaISC_EEEEES6_IhSaIhEERKSC_DpRKT_ -_ZN2cl4sycl5INTEL15online_compilerILNS1_15source_languageE1EE7compileIJSt6vectorINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaISC_EEEEES6_IhSaIhEERKSC_DpRKT_ _ZN2cl4sycl5queue10mem_adviseEPKvm14_pi_mem_advice _ZN2cl4sycl5queue10wait_proxyERKNS0_6detail13code_locationE _ZN2cl4sycl5queue11submit_implESt8functionIFvRNS0_7handlerEEERKNS0_6detail13code_locationE @@ -3890,6 +3889,7 @@ _ZNK2cl4sycl15interop_handler12GetNativeMemEPNS0_6detail16AccessorImplHostE _ZNK2cl4sycl15interop_handler14GetNativeQueueEv _ZNK2cl4sycl16default_selectorclERKNS0_6deviceE _ZNK2cl4sycl20accelerator_selectorclERKNS0_6deviceE +_ZNK2cl4sycl5event11get_backendEv _ZNK2cl4sycl5event18get_profiling_infoILNS0_4info15event_profilingE4737EEENS3_12param_traitsIS4_XT_EE11return_typeEv _ZNK2cl4sycl5event18get_profiling_infoILNS0_4info15event_profilingE4738EEENS3_12param_traitsIS4_XT_EE11return_typeEv _ZNK2cl4sycl5event18get_profiling_infoILNS0_4info15event_profilingE4739EEENS3_12param_traitsIS4_XT_EE11return_typeEv @@ -3901,6 +3901,7 @@ _ZNK2cl4sycl5event9getNativeEv _ZNK2cl4sycl5eventeqERKS1_ _ZNK2cl4sycl5eventneERKS1_ _ZNK2cl4sycl5queue10get_deviceEv +_ZNK2cl4sycl5queue11get_backendEv _ZNK2cl4sycl5queue11get_contextEv _ZNK2cl4sycl5queue11is_in_orderEv _ZNK2cl4sycl5queue12get_propertyINS0_8property5queue16enable_profilingEEET_v @@ -3945,6 +3946,7 @@ _ZNK2cl4sycl6detail12sampler_impl18get_filtering_modeEv _ZNK2cl4sycl6detail12sampler_impl19get_addressing_modeEv _ZNK2cl4sycl6detail12sampler_impl33get_coordinate_normalization_modeEv _ZNK2cl4sycl6detail14host_half_impl4halfcvfEv +_ZNK2cl4sycl6device11get_backendEv _ZNK2cl4sycl6device12get_platformEv _ZNK2cl4sycl6device13has_extensionERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE _ZNK2cl4sycl6device14is_acceleratorEv @@ -3964,6 +3966,7 @@ _ZNK2cl4sycl6device8get_infoILNS0_4info6deviceE16785EEENS3_12param_traitsIS4_XT_ _ZNK2cl4sycl6device8get_infoILNS0_4info6deviceE16786EEENS3_12param_traitsIS4_XT_EE11return_typeEv _ZNK2cl4sycl6device8get_infoILNS0_4info6deviceE16787EEENS3_12param_traitsIS4_XT_EE11return_typeEv _ZNK2cl4sycl6device8get_infoILNS0_4info6deviceE16788EEENS3_12param_traitsIS4_XT_EE11return_typeEv +_ZNK2cl4sycl6device8get_infoILNS0_4info6deviceE16915EEENS3_12param_traitsIS4_XT_EE11return_typeEv _ZNK2cl4sycl6device8get_infoILNS0_4info6deviceE4096EEENS3_12param_traitsIS4_XT_EE11return_typeEv _ZNK2cl4sycl6device8get_infoILNS0_4info6deviceE4097EEENS3_12param_traitsIS4_XT_EE11return_typeEv _ZNK2cl4sycl6device8get_infoILNS0_4info6deviceE4098EEENS3_12param_traitsIS4_XT_EE11return_typeEv @@ -4039,7 +4042,6 @@ _ZNK2cl4sycl6device8get_infoILNS0_4info6deviceE4168EEENS3_12param_traitsIS4_XT_E _ZNK2cl4sycl6device8get_infoILNS0_4info6deviceE4169EEENS3_12param_traitsIS4_XT_EE11return_typeEv _ZNK2cl4sycl6device8get_infoILNS0_4info6deviceE4188EEENS3_12param_traitsIS4_XT_EE11return_typeEv _ZNK2cl4sycl6device8get_infoILNS0_4info6deviceE4189EEENS3_12param_traitsIS4_XT_EE11return_typeEv -_ZNK2cl4sycl6device8get_infoILNS0_4info6deviceE16915EEENS3_12param_traitsIS4_XT_EE11return_typeEv _ZNK2cl4sycl6device8get_infoILNS0_4info6deviceE65568EEENS3_12param_traitsIS4_XT_EE11return_typeEv _ZNK2cl4sycl6device8get_infoILNS0_4info6deviceE65569EEENS3_12param_traitsIS4_XT_EE11return_typeEv _ZNK2cl4sycl6device8get_infoILNS0_4info6deviceE65570EEENS3_12param_traitsIS4_XT_EE11return_typeEv @@ -4080,6 +4082,7 @@ _ZNK2cl4sycl6stream22get_max_statement_sizeEv _ZNK2cl4sycl6stream8get_sizeEv _ZNK2cl4sycl6streameqERKS1_ _ZNK2cl4sycl6streamneERKS1_ +_ZNK2cl4sycl7context11get_backendEv _ZNK2cl4sycl7context11get_devicesEv _ZNK2cl4sycl7context12get_platformEv _ZNK2cl4sycl7context12get_propertyINS0_3ext6oneapi8property6buffer22use_pinned_host_memoryEEET_v @@ -4112,6 +4115,7 @@ _ZNK2cl4sycl7program10get_kernelENSt7__cxx1112basic_stringIcSt11char_traitsIcESa _ZNK2cl4sycl7program10get_kernelENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEb _ZNK2cl4sycl7program10has_kernelENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE _ZNK2cl4sycl7program10has_kernelENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEb +_ZNK2cl4sycl7program11get_backendEv _ZNK2cl4sycl7program11get_contextEv _ZNK2cl4sycl7program11get_devicesEv _ZNK2cl4sycl7program12get_binariesEv From f953902bfaf114c771097b67674019195bbb5cd0 Mon Sep 17 00:00:00 2001 From: mdimakov Date: Tue, 2 Mar 2021 09:48:35 +0300 Subject: [PATCH 06/19] [SYCL] Unit test for the free get_native() Signed-off-by: mdimakov --- sycl/unittests/CMakeLists.txt | 1 + .../get_native_interop/CMakeLists.txt | 3 + .../get_native_interop/test_get_native.cpp | 129 ++++++++++++++++++ 3 files changed, 133 insertions(+) create mode 100644 sycl/unittests/get_native_interop/CMakeLists.txt create mode 100644 sycl/unittests/get_native_interop/test_get_native.cpp diff --git a/sycl/unittests/CMakeLists.txt b/sycl/unittests/CMakeLists.txt index 1d500283eed37..f2789b4ffb6a1 100644 --- a/sycl/unittests/CMakeLists.txt +++ b/sycl/unittests/CMakeLists.txt @@ -9,6 +9,7 @@ endforeach() include(AddSYCLUnitTest) +add_subdirectory(get_native_interop) add_subdirectory(misc) add_subdirectory(pi) add_subdirectory(kernel-and-program) diff --git a/sycl/unittests/get_native_interop/CMakeLists.txt b/sycl/unittests/get_native_interop/CMakeLists.txt new file mode 100644 index 0000000000000..8b0bd05db8349 --- /dev/null +++ b/sycl/unittests/get_native_interop/CMakeLists.txt @@ -0,0 +1,3 @@ +add_sycl_unittest_with_device(GetNativeTests OBJECT + test_get_native.cpp +) \ No newline at end of file diff --git a/sycl/unittests/get_native_interop/test_get_native.cpp b/sycl/unittests/get_native_interop/test_get_native.cpp new file mode 100644 index 0000000000000..e3b76414bbcba --- /dev/null +++ b/sycl/unittests/get_native_interop/test_get_native.cpp @@ -0,0 +1,129 @@ +//==----------- test_get_native.cpp --- get_native interop unit test -------------==// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include +#include +#include +#include +#include + +#include +#include + +using namespace cl::sycl; + +int TestCounter; + +static pi_result redefinedContextRetain(pi_context c) { + ++TestCounter; + return PI_SUCCESS; +} + +static pi_result redefinedQueueRetain(pi_queue c) { + ++TestCounter; + return PI_SUCCESS; +} + +static pi_result redefinedDeviceRetain(pi_device c) { + ++TestCounter; + return PI_SUCCESS; +} + +static pi_result redefinedProgramRetain(pi_program c) { + ++TestCounter; + return PI_SUCCESS; +} + +static pi_result redefinedEventRetain(pi_event c) { + ++TestCounter; + return PI_SUCCESS; +} + +static pi_result redefinedProgramCreateWithSource(pi_context context, + pi_uint32 count, + const char **strings, + const size_t *lengths, + pi_program *ret_program) { + return PI_SUCCESS; +} + +static pi_result +redefinedProgramBuild(pi_program program, pi_uint32 num_devices, + const pi_device *device_list, const char *options, + void (*pfn_notify)(pi_program program, void *user_data), + void *user_data) { + return PI_SUCCESS; +} + +pi_result redefinedEventsWait(pi_uint32 num_events, + const pi_event *event_list) { + return PI_SUCCESS; +} + +pi_result redefinedEventGetInfo(pi_event event, pi_event_info param_name, + size_t param_value_size, void *param_value, + size_t *param_value_size_ret) { + EXPECT_EQ(param_name, PI_EVENT_INFO_COMMAND_EXECUTION_STATUS) + << "Unexpected event info requested"; + // Report half of events as complete + static int Counter = 0; + auto *Result = reinterpret_cast(param_value); + *Result = (++Counter % 2 == 0) ? PI_EVENT_COMPLETE : PI_EVENT_RUNNING; + return PI_SUCCESS; +} + +pi_result redefinedEventRelease(pi_event event) { + return PI_SUCCESS; +} + +TEST(GetNativeTest, GetNativeHandle) { + platform Plt{default_selector()}; + if (Plt.is_host()) { + std::cout << "Not run on host - no PI events created in that case" + << std::endl; + return; + } + TestCounter = 0; + + unittest::PiMock Mock{Plt}; + Mock.redefine( + redefinedProgramCreateWithSource); + Mock.redefine(redefinedProgramBuild); + + Mock.redefine(redefinedEventsWait); + Mock.redefine(redefinedEventGetInfo); + Mock.redefine(redefinedEventRelease); + + Mock.redefine(redefinedContextRetain); + Mock.redefine(redefinedQueueRetain); + Mock.redefine(redefinedDeviceRetain); + Mock.redefine(redefinedProgramRetain); + Mock.redefine(redefinedEventRetain); + + default_selector Selector; + context Context(Plt); + queue Queue(Context, Selector); + + program Program{Context}; + Program.build_with_source(""); + + auto Device = Queue.get_device(); + + unsigned char *HostAlloc = (unsigned char *)malloc_host(1, Context); + auto Event = Queue.memset(HostAlloc, 42, 1); + + auto c_g = get_native(Context); + auto q_g = get_native(Queue); + auto p_g = get_native(Program); + auto d_g = get_native(Device); + auto e_g = get_native(Event); + + // When creating a context, the piDeviceRetain is called so here is the 6 retain calls + ASSERT_EQ(TestCounter, 6) + << "Not all the retain methods was called"; +} From 4e292b497837e7fb5467602478da71f31d0b77ff Mon Sep 17 00:00:00 2001 From: mdimakov Date: Tue, 2 Mar 2021 09:55:25 +0300 Subject: [PATCH 07/19] [SYCL] Clang-format fix Signed-off-by: mdimakov --- .../get_native_interop/test_get_native.cpp | 21 +++++++++---------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/sycl/unittests/get_native_interop/test_get_native.cpp b/sycl/unittests/get_native_interop/test_get_native.cpp index e3b76414bbcba..055577d9d44d0 100644 --- a/sycl/unittests/get_native_interop/test_get_native.cpp +++ b/sycl/unittests/get_native_interop/test_get_native.cpp @@ -1,4 +1,5 @@ -//==----------- test_get_native.cpp --- get_native interop unit test -------------==// +//==----------- test_get_native.cpp --- get_native interop unit test +//-------------==// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -77,9 +78,7 @@ pi_result redefinedEventGetInfo(pi_event event, pi_event_info param_name, return PI_SUCCESS; } -pi_result redefinedEventRelease(pi_event event) { - return PI_SUCCESS; -} +pi_result redefinedEventRelease(pi_event event) { return PI_SUCCESS; } TEST(GetNativeTest, GetNativeHandle) { platform Plt{default_selector()}; @@ -106,9 +105,9 @@ TEST(GetNativeTest, GetNativeHandle) { Mock.redefine(redefinedEventRetain); default_selector Selector; - context Context(Plt); + context Context(Plt); queue Queue(Context, Selector); - + program Program{Context}; Program.build_with_source(""); @@ -116,14 +115,14 @@ TEST(GetNativeTest, GetNativeHandle) { unsigned char *HostAlloc = (unsigned char *)malloc_host(1, Context); auto Event = Queue.memset(HostAlloc, 42, 1); - - auto c_g = get_native(Context); + + auto c_g = get_native(Context); auto q_g = get_native(Queue); auto p_g = get_native(Program); auto d_g = get_native(Device); auto e_g = get_native(Event); - // When creating a context, the piDeviceRetain is called so here is the 6 retain calls - ASSERT_EQ(TestCounter, 6) - << "Not all the retain methods was called"; + // When creating a context, the piDeviceRetain is called so here is the 6 + // retain calls + ASSERT_EQ(TestCounter, 6) << "Not all the retain methods was called"; } From e0ef3a99186f0a6164b2f3be5105e367fc823b61 Mon Sep 17 00:00:00 2001 From: mdimakov Date: Tue, 2 Mar 2021 09:58:33 +0300 Subject: [PATCH 08/19] [SYCL] Clang-format fix Signed-off-by: mdimakov --- sycl/unittests/get_native_interop/test_get_native.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sycl/unittests/get_native_interop/test_get_native.cpp b/sycl/unittests/get_native_interop/test_get_native.cpp index 055577d9d44d0..12d66a6a73908 100644 --- a/sycl/unittests/get_native_interop/test_get_native.cpp +++ b/sycl/unittests/get_native_interop/test_get_native.cpp @@ -1,4 +1,4 @@ -//==----------- test_get_native.cpp --- get_native interop unit test +//==----------- test_get_native.cpp --- get_native interop unit test //-------------==// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. From 7ce2a71ad6cc8fb108e38f95f8622a30cb85377c Mon Sep 17 00:00:00 2001 From: mdimakov Date: Fri, 5 Mar 2021 12:01:51 +0300 Subject: [PATCH 09/19] [SYCL] Added check for cuda Signed-off-by: mdimakov --- sycl/unittests/get_native_interop/test_get_native.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sycl/unittests/get_native_interop/test_get_native.cpp b/sycl/unittests/get_native_interop/test_get_native.cpp index 12d66a6a73908..cafa35759cea5 100644 --- a/sycl/unittests/get_native_interop/test_get_native.cpp +++ b/sycl/unittests/get_native_interop/test_get_native.cpp @@ -82,6 +82,8 @@ pi_result redefinedEventRelease(pi_event event) { return PI_SUCCESS; } TEST(GetNativeTest, GetNativeHandle) { platform Plt{default_selector()}; + if (Plt.get_backend() == backend::cuda) + return; if (Plt.is_host()) { std::cout << "Not run on host - no PI events created in that case" << std::endl; From e95167c8acac82418f096a13d4e869854cd16cb0 Mon Sep 17 00:00:00 2001 From: mdimakov Date: Fri, 5 Mar 2021 12:02:29 +0300 Subject: [PATCH 10/19] [SYCL] Addressed to review comment Signed-off-by: mdimakov --- sycl/test/abi/sycl_symbols_linux.dump | 1 + 1 file changed, 1 insertion(+) diff --git a/sycl/test/abi/sycl_symbols_linux.dump b/sycl/test/abi/sycl_symbols_linux.dump index 80e3f11519e9a..8a03af2772712 100644 --- a/sycl/test/abi/sycl_symbols_linux.dump +++ b/sycl/test/abi/sycl_symbols_linux.dump @@ -5,6 +5,7 @@ # RUN: env LLVM_BIN_PATH=%llvm_build_bin_dir python %sycl_tools_src_dir/abi_check.py --mode check_symbols --reference %s %sycl_libs_dir/libsycl.so # REQUIRES: linux +# UNSUPPORTED: libcxx _Z20__spirv_ocl_prefetchPKcm _Z21__spirv_MemoryBarrierN5__spv5ScopeEj From b45fa4548de986e947a707dfea3e3241abdaf78d Mon Sep 17 00:00:00 2001 From: mdimakov Date: Wed, 10 Mar 2021 19:23:55 +0300 Subject: [PATCH 11/19] Adress review comments Signed-off-by: mdimakov --- sycl/include/CL/sycl/backend.hpp | 6 ++-- sycl/source/context.cpp | 5 ++- sycl/source/detail/context_impl.hpp | 7 +++-- sycl/source/detail/device_impl.hpp | 9 +++--- sycl/source/detail/event_impl.cpp | 4 +-- sycl/source/detail/event_impl.hpp | 5 ++- sycl/source/detail/get_backend.hpp | 31 +++++++++++++++++++ sycl/source/detail/platform_impl.hpp | 12 +------ sycl/source/detail/program_impl.hpp | 7 +++-- sycl/source/detail/queue_impl.hpp | 19 ------------ sycl/source/device.cpp | 5 ++- sycl/source/event.cpp | 5 ++- sycl/source/platform.cpp | 3 +- sycl/source/program.cpp | 5 ++- sycl/source/queue.cpp | 5 ++- .../get_native_interop/CMakeLists.txt | 2 +- .../get_native_interop/test_get_native.cpp | 4 ++- 17 files changed, 81 insertions(+), 53 deletions(-) create mode 100644 sycl/source/detail/get_backend.hpp diff --git a/sycl/include/CL/sycl/backend.hpp b/sycl/include/CL/sycl/backend.hpp index 720edcf758be0..6532651f6c87a 100644 --- a/sycl/include/CL/sycl/backend.hpp +++ b/sycl/include/CL/sycl/backend.hpp @@ -10,6 +10,7 @@ #include #include +#include __SYCL_INLINE_NAMESPACE(cl) { namespace sycl { @@ -17,8 +18,9 @@ namespace sycl { template auto get_native(const SyclObjectT &Obj) -> typename interop::type { - assert(Obj.get_backend() == BackendName && - "Current and submitted backends are different"); + // TODO use SYCL 2020 exception when implemented + if (Obj.get_backend() != BackendName) + throw runtime_error("Backends mismatch", PI_INVALID_OPERATION); return Obj.template get_native(); } diff --git a/sycl/source/context.cpp b/sycl/source/context.cpp index f45201a5446d2..1b5365cb8ba2d 100644 --- a/sycl/source/context.cpp +++ b/sycl/source/context.cpp @@ -16,6 +16,7 @@ #include #include #include +#include #include #include @@ -117,7 +118,9 @@ cl_context context::get() const { return impl->get(); } bool context::is_host() const { return impl->is_host(); } -backend context::get_backend() const noexcept { return impl->get_backend(); } +backend context::get_backend() const noexcept { + return getImplBackend(impl); +} platform context::get_platform() const { return impl->get_info(); diff --git a/sycl/source/detail/context_impl.hpp b/sycl/source/detail/context_impl.hpp index fde72882ef502..33dbbe3d4e0b8 100644 --- a/sycl/source/detail/context_impl.hpp +++ b/sycl/source/detail/context_impl.hpp @@ -101,15 +101,16 @@ class context_impl { /// Returns the backend associated with this context. /// /// \return the backend associated with this context. - backend get_backend() const noexcept { - backend Result; + //backend getBackend() const noexcept { + // return getPlugin().getBackend(); } + /* backend Result; if (is_host()) Result = backend::host; else Result = getPlugin().getBackend(); return Result; - } + }*/ /// Gets asynchronous exception handler. /// diff --git a/sycl/source/detail/device_impl.hpp b/sycl/source/detail/device_impl.hpp index f14702b8dcbda..9d51d23641bbb 100644 --- a/sycl/source/detail/device_impl.hpp +++ b/sycl/source/detail/device_impl.hpp @@ -206,16 +206,17 @@ class device_impl { /// Returns the backend associated with this device. /// - // \return the Backend associated with this platform. - backend get_backend() const noexcept { - backend Result; + // \return the Backend associated with this device. + // backend getBackend() const noexcept { + // return getPlugin().getBackend(); } + /*backend Result; if (is_host()) Result = backend::host; else Result = getPlugin().getBackend(); return Result; - } + }*/ /// Gets the native handle of the SYCL device. /// diff --git a/sycl/source/detail/event_impl.cpp b/sycl/source/detail/event_impl.cpp index a181ddea8feaf..dc286767c0a6f 100644 --- a/sycl/source/detail/event_impl.cpp +++ b/sycl/source/detail/event_impl.cpp @@ -290,7 +290,7 @@ void HostProfilingInfo::start() { StartTime = getTimestamp(); } void HostProfilingInfo::end() { EndTime = getTimestamp(); } -backend event_impl::get_backend() const noexcept { +/*backend event_impl::get_backend() const noexcept { backend Result; if (is_host()) Result = backend::host; @@ -298,7 +298,7 @@ backend event_impl::get_backend() const noexcept { Result = getPlugin().getBackend(); return Result; -} +}*/ pi_native_handle event_impl::getNative() const { auto Plugin = getPlugin(); diff --git a/sycl/source/detail/event_impl.hpp b/sycl/source/detail/event_impl.hpp index 67ae29faa5777..3de67c07e4f4b 100644 --- a/sycl/source/detail/event_impl.hpp +++ b/sycl/source/detail/event_impl.hpp @@ -13,6 +13,7 @@ #include #include #include +#include #include #include @@ -152,7 +153,9 @@ class event_impl { /// Returns the backend associated with this event. /// /// \return the backend associated with this event. - backend get_backend() const noexcept; + //backend getBackend() const noexcept { + // return getPlugin().getBackend(); + //} /// Gets the native handle of the SYCL event. /// /// \return a native handle. diff --git a/sycl/source/detail/get_backend.hpp b/sycl/source/detail/get_backend.hpp new file mode 100644 index 0000000000000..e18574d69cbf3 --- /dev/null +++ b/sycl/source/detail/get_backend.hpp @@ -0,0 +1,31 @@ +//==------------------ get_backend.hpp - getImplBackend for impls -------------------------==// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#pragma once +#include + +__SYCL_INLINE_NAMESPACE(cl) { +namespace sycl { +namespace detail { + + +template +backend getImplBackend(const T &Impl) { + backend Result; + if (Impl->is_host()) + Result = backend::host; + else + Result = Impl->getPlugin().getBackend(); + + return Result; +} + + +} // namespace detail +} // namespace sycl +} // __SYCL_INLINE_NAMESPACE(cl) diff --git a/sycl/source/detail/platform_impl.hpp b/sycl/source/detail/platform_impl.hpp index c1f8cf6583dde..d3b29606acef0 100644 --- a/sycl/source/detail/platform_impl.hpp +++ b/sycl/source/detail/platform_impl.hpp @@ -11,6 +11,7 @@ #include #include #include +#include #include #include @@ -108,17 +109,6 @@ class platform_impl { /// \return a vector of all available SYCL platforms. static vector_class get_platforms(); - // \return the Backend associated with this platform. - backend get_backend() const noexcept { - backend Result; - if (is_host()) - Result = backend::host; - else - Result = getPlugin().getBackend(); - - return Result; - } - // \return the Plugin associated with this platform. const plugin &getPlugin() const { assert(!MHostPlatform && "Plugin is not available for Host."); diff --git a/sycl/source/detail/program_impl.hpp b/sycl/source/detail/program_impl.hpp index 85388bffc1725..61ca905943981 100644 --- a/sycl/source/detail/program_impl.hpp +++ b/sycl/source/detail/program_impl.hpp @@ -343,15 +343,16 @@ class program_impl { /// Returns the backend associated with this context. /// /// \return the backend associated with this context. - backend get_backend() const noexcept { - backend Result; + // backend getBackend() const noexcept { + // return getPlugin().getBackend(); } + /*backend Result; if (is_host()) Result = backend::host; else Result = getPlugin().getBackend(); return Result; - } + }*/ /// Returns the native plugin handle. pi_native_handle getNative() const; diff --git a/sycl/source/detail/queue_impl.hpp b/sycl/source/detail/queue_impl.hpp index 096df9588d56c..65efe7ddd4e6d 100644 --- a/sycl/source/detail/queue_impl.hpp +++ b/sycl/source/detail/queue_impl.hpp @@ -366,25 +366,6 @@ class queue_impl { return *MHostTaskThreadPool; } - void stopThreadPool() { - if (MHostTaskThreadPool) { - MHostTaskThreadPool->finishAndWait(); - } - } - - /// Returns the backend associated with this queue. - /// - /// \return the backend associated with this queue. - backend get_backend() const noexcept { - backend Result; - if (is_host()) - Result = backend::host; - else - Result = getPlugin().getBackend(); - - return Result; - } - /// Gets the native handle of the SYCL queue. /// /// \return a native handle. diff --git a/sycl/source/device.cpp b/sycl/source/device.cpp index 7b6d4929a767a..fb7edbc99780a 100644 --- a/sycl/source/device.cpp +++ b/sycl/source/device.cpp @@ -13,6 +13,7 @@ #include #include #include +#include __SYCL_INLINE_NAMESPACE(cl) { namespace sycl { @@ -136,7 +137,9 @@ device::get_info() const { #undef __SYCL_PARAM_TRAITS_SPEC -backend device::get_backend() const noexcept { return impl->get_backend(); } +backend device::get_backend() const noexcept { + return getImplBackend(impl); +} pi_native_handle device::getNative() const { return impl->getNative(); } diff --git a/sycl/source/event.cpp b/sycl/source/event.cpp index 62e236fc5b218..e880b9f40dc4d 100644 --- a/sycl/source/event.cpp +++ b/sycl/source/event.cpp @@ -13,6 +13,7 @@ #include #include #include +#include #include #include @@ -85,7 +86,9 @@ event::event(shared_ptr_class event_impl) #undef __SYCL_PARAM_TRAITS_SPEC -backend event::get_backend() const noexcept { return impl->get_backend(); } +backend event::get_backend() const noexcept { + return getImplBackend(impl); +} pi_native_handle event::getNative() const { return impl->getNative(); } diff --git a/sycl/source/platform.cpp b/sycl/source/platform.cpp index 3ab9f5b020d6d..a6256179ba1e8 100644 --- a/sycl/source/platform.cpp +++ b/sycl/source/platform.cpp @@ -11,6 +11,7 @@ #include #include #include +#include #include __SYCL_INLINE_NAMESPACE(cl) { @@ -43,7 +44,7 @@ vector_class platform::get_platforms() { return detail::platform_impl::get_platforms(); } -backend platform::get_backend() const noexcept { return impl->get_backend(); } +backend platform::get_backend() const noexcept { return getImplBackend(impl); } template typename info::param_traits::return_type diff --git a/sycl/source/program.cpp b/sycl/source/program.cpp index 5566f45d7a954..9f3e81723e437 100644 --- a/sycl/source/program.cpp +++ b/sycl/source/program.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #include #include @@ -47,7 +48,9 @@ program::program(const context &context, cl_program clProgram) clRetainProgram(clProgram); } -backend program::get_backend() const noexcept { return impl->get_backend(); } +backend program::get_backend() const noexcept { + return getImplBackend(impl); +} pi_native_handle program::getNative() const { return impl->getNative(); } diff --git a/sycl/source/queue.cpp b/sycl/source/queue.cpp index e744934f17438..cc051fbfd64d3 100644 --- a/sycl/source/queue.cpp +++ b/sycl/source/queue.cpp @@ -11,6 +11,7 @@ #include #include #include +#include #include #include @@ -138,7 +139,9 @@ bool queue::is_in_order() const { return impl->has_property(); } -backend queue::get_backend() const noexcept { return impl->get_backend(); } +backend queue::get_backend() const noexcept { + return getImplBackend(impl); +} pi_native_handle queue::getNative() const { return impl->getNative(); } diff --git a/sycl/unittests/get_native_interop/CMakeLists.txt b/sycl/unittests/get_native_interop/CMakeLists.txt index 8b0bd05db8349..b65136606d448 100644 --- a/sycl/unittests/get_native_interop/CMakeLists.txt +++ b/sycl/unittests/get_native_interop/CMakeLists.txt @@ -1,3 +1,3 @@ add_sycl_unittest_with_device(GetNativeTests OBJECT test_get_native.cpp -) \ No newline at end of file +) diff --git a/sycl/unittests/get_native_interop/test_get_native.cpp b/sycl/unittests/get_native_interop/test_get_native.cpp index cafa35759cea5..1fa3a3fc5ef85 100644 --- a/sycl/unittests/get_native_interop/test_get_native.cpp +++ b/sycl/unittests/get_native_interop/test_get_native.cpp @@ -82,8 +82,10 @@ pi_result redefinedEventRelease(pi_event event) { return PI_SUCCESS; } TEST(GetNativeTest, GetNativeHandle) { platform Plt{default_selector()}; - if (Plt.get_backend() == backend::cuda) + if (Plt.get_backend() != backend::opencl) { + std::cout << "Test is created for opencl only" << std::endl; return; + } if (Plt.is_host()) { std::cout << "Not run on host - no PI events created in that case" << std::endl; From 4a8513843591ba8e4632dd8d7b44119260262920 Mon Sep 17 00:00:00 2001 From: mdimakov Date: Wed, 10 Mar 2021 21:57:32 +0300 Subject: [PATCH 12/19] [SYCL] Address review comment Signed-off-by: mdimakov --- sycl/source/detail/context_impl.hpp | 14 -------------- sycl/source/detail/device_impl.hpp | 14 -------------- sycl/source/detail/event_impl.hpp | 6 ------ sycl/source/detail/platform_impl.hpp | 1 - sycl/source/detail/program_impl.hpp | 14 -------------- sycl/test/abi/sycl_symbols_linux.dump | 24 ------------------------ 6 files changed, 73 deletions(-) diff --git a/sycl/source/detail/context_impl.hpp b/sycl/source/detail/context_impl.hpp index 33dbbe3d4e0b8..967c4a6cffcbe 100644 --- a/sycl/source/detail/context_impl.hpp +++ b/sycl/source/detail/context_impl.hpp @@ -98,20 +98,6 @@ class context_impl { /// \return true if this context is a host context. bool is_host() const; - /// Returns the backend associated with this context. - /// - /// \return the backend associated with this context. - //backend getBackend() const noexcept { - // return getPlugin().getBackend(); } - /* backend Result; - if (is_host()) - Result = backend::host; - else - Result = getPlugin().getBackend(); - - return Result; - }*/ - /// Gets asynchronous exception handler. /// /// \return an instance of SYCL async_handler. diff --git a/sycl/source/detail/device_impl.hpp b/sycl/source/detail/device_impl.hpp index 9d51d23641bbb..0e1381f933964 100644 --- a/sycl/source/detail/device_impl.hpp +++ b/sycl/source/detail/device_impl.hpp @@ -204,20 +204,6 @@ class device_impl { bool is_affinity_supported(info::partition_affinity_domain AffinityDomain) const; - /// Returns the backend associated with this device. - /// - // \return the Backend associated with this device. - // backend getBackend() const noexcept { - // return getPlugin().getBackend(); } - /*backend Result; - if (is_host()) - Result = backend::host; - else - Result = getPlugin().getBackend(); - - return Result; - }*/ - /// Gets the native handle of the SYCL device. /// /// \return a native handle. diff --git a/sycl/source/detail/event_impl.hpp b/sycl/source/detail/event_impl.hpp index 3de67c07e4f4b..81e9e9b626356 100644 --- a/sycl/source/detail/event_impl.hpp +++ b/sycl/source/detail/event_impl.hpp @@ -150,12 +150,6 @@ class event_impl { /// @return a pointer to HostProfilingInfo instance. HostProfilingInfo *getHostProfilingInfo() { return MHostProfilingInfo.get(); } - /// Returns the backend associated with this event. - /// - /// \return the backend associated with this event. - //backend getBackend() const noexcept { - // return getPlugin().getBackend(); - //} /// Gets the native handle of the SYCL event. /// /// \return a native handle. diff --git a/sycl/source/detail/platform_impl.hpp b/sycl/source/detail/platform_impl.hpp index d3b29606acef0..2dea8751da14d 100644 --- a/sycl/source/detail/platform_impl.hpp +++ b/sycl/source/detail/platform_impl.hpp @@ -11,7 +11,6 @@ #include #include #include -#include #include #include diff --git a/sycl/source/detail/program_impl.hpp b/sycl/source/detail/program_impl.hpp index 61ca905943981..822e70e8f0769 100644 --- a/sycl/source/detail/program_impl.hpp +++ b/sycl/source/detail/program_impl.hpp @@ -340,20 +340,6 @@ class program_impl { /// \return true if caching is allowed for this program. bool is_cacheable() const { return MProgramAndKernelCachingAllowed; } - /// Returns the backend associated with this context. - /// - /// \return the backend associated with this context. - // backend getBackend() const noexcept { - // return getPlugin().getBackend(); } - /*backend Result; - if (is_host()) - Result = backend::host; - else - Result = getPlugin().getBackend(); - - return Result; - }*/ - /// Returns the native plugin handle. pi_native_handle getNative() const; diff --git a/sycl/test/abi/sycl_symbols_linux.dump b/sycl/test/abi/sycl_symbols_linux.dump index f0541d34daa9d..80e3f11519e9a 100644 --- a/sycl/test/abi/sycl_symbols_linux.dump +++ b/sycl/test/abi/sycl_symbols_linux.dump @@ -5,7 +5,6 @@ # RUN: env LLVM_BIN_PATH=%llvm_build_bin_dir python %sycl_tools_src_dir/abi_check.py --mode check_symbols --reference %s %sycl_libs_dir/libsycl.so # REQUIRES: linux -# UNSUPPORTED: libcxx _Z20__spirv_ocl_prefetchPKcm _Z21__spirv_MemoryBarrierN5__spv5ScopeEj @@ -3779,14 +3778,10 @@ _ZN2cl4sycl6detail18stringifyErrorCodeEi _ZN2cl4sycl6detail19convertChannelOrderE23_pi_image_channel_order _ZN2cl4sycl6detail19convertChannelOrderENS0_19image_channel_orderE _ZN2cl4sycl6detail19getImageElementSizeEhNS0_18image_channel_typeE -_ZN2cl4sycl6detail19kernel_bundle_plain37set_specialization_constant_raw_valueEjPKvm _ZN2cl4sycl6detail20associateWithHandlerERNS0_7handlerEPNS1_16AccessorBaseHostENS0_6access6targetE _ZN2cl4sycl6detail20getDeviceFromHandlerERNS0_7handlerE _ZN2cl4sycl6detail22addHostAccessorAndWaitEPNS1_16AccessorImplHostE _ZN2cl4sycl6detail22getImageNumberChannelsENS0_19image_channel_orderE -_ZN2cl4sycl6detail22get_kernel_bundle_implERKNS0_7contextERKSt6vectorINS0_6deviceESaIS6_EENS0_12bundle_stateE -_ZN2cl4sycl6detail22get_kernel_bundle_implERKNS0_7contextERKSt6vectorINS0_6deviceESaIS6_EENS0_12bundle_stateERKSt8functionIFbRKSt10shared_ptrINS1_17device_image_implEEEE -_ZN2cl4sycl6detail22get_kernel_bundle_implERKNS0_7contextERKSt6vectorINS0_6deviceESaIS6_EERKS5_INS0_9kernel_idESaISB_EENS0_12bundle_stateE _ZN2cl4sycl6detail27getPixelCoordLinearFiltModeENS0_3vecIfLi4EEENS0_15addressing_modeENS0_5rangeILi3EEERS3_ _ZN2cl4sycl6detail28getDeviceFunctionPointerImplERNS0_6deviceERNS0_7programEPKc _ZN2cl4sycl6detail28getPixelCoordNearestFiltModeENS0_3vecIfLi4EEENS0_15addressing_modeENS0_5rangeILi3EEE @@ -3880,8 +3875,6 @@ _ZN2cl4sycl8platformC1Ev _ZN2cl4sycl8platformC2EP15_cl_platform_id _ZN2cl4sycl8platformC2ERKNS0_15device_selectorE _ZN2cl4sycl8platformC2Ev -_ZN2cl4sycl9kernel_idC1EPKc -_ZN2cl4sycl9kernel_idC2EPKc _ZNK2cl4sycl12cpu_selectorclERKNS0_6deviceE _ZNK2cl4sycl12gpu_selectorclERKNS0_6deviceE _ZNK2cl4sycl13host_selectorclERKNS0_6deviceE @@ -3955,22 +3948,6 @@ _ZNK2cl4sycl6detail12sampler_impl19get_addressing_modeEv _ZNK2cl4sycl6detail12sampler_impl33get_coordinate_normalization_modeEv _ZNK2cl4sycl6detail14host_half_impl4halfcvfEv _ZNK2cl4sycl6device11get_backendEv -_ZNK2cl4sycl6detail18device_image_plain10has_kernelERKNS0_9kernel_idE -_ZNK2cl4sycl6detail18device_image_plain10has_kernelERKNS0_9kernel_idERKNS0_6deviceE -_ZNK2cl4sycl6detail19kernel_bundle_plain10get_kernelERKNS0_9kernel_idE -_ZNK2cl4sycl6detail19kernel_bundle_plain10has_kernelERKNS0_9kernel_idE -_ZNK2cl4sycl6detail19kernel_bundle_plain10has_kernelERKNS0_9kernel_idERKNS0_6deviceE -_ZNK2cl4sycl6detail19kernel_bundle_plain11get_backendEv -_ZNK2cl4sycl6detail19kernel_bundle_plain11get_contextEv -_ZNK2cl4sycl6detail19kernel_bundle_plain11get_devicesEv -_ZNK2cl4sycl6detail19kernel_bundle_plain14get_kernel_idsEv -_ZNK2cl4sycl6detail19kernel_bundle_plain27has_specialization_constantEj -_ZNK2cl4sycl6detail19kernel_bundle_plain30native_specialization_constantEv -_ZNK2cl4sycl6detail19kernel_bundle_plain33contains_specialization_constantsEv -_ZNK2cl4sycl6detail19kernel_bundle_plain37get_specialization_constant_raw_valueEjPvm -_ZNK2cl4sycl6detail19kernel_bundle_plain3endEv -_ZNK2cl4sycl6detail19kernel_bundle_plain5beginEv -_ZNK2cl4sycl6detail19kernel_bundle_plain5emptyEv _ZNK2cl4sycl6device12get_platformEv _ZNK2cl4sycl6device13has_extensionERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE _ZNK2cl4sycl6device14is_acceleratorEv @@ -4214,6 +4191,5 @@ _ZNK2cl4sycl9exception11get_cl_codeEv _ZNK2cl4sycl9exception11get_contextEv _ZNK2cl4sycl9exception11has_contextEv _ZNK2cl4sycl9exception4whatEv -_ZNK2cl4sycl9kernel_id8get_nameEv __sycl_register_lib __sycl_unregister_lib From ce3f9ce5d0c51ac9f166edf22433e0cdab1c3441 Mon Sep 17 00:00:00 2001 From: mdimakov Date: Wed, 10 Mar 2021 22:04:29 +0300 Subject: [PATCH 13/19] [SYCL] Clang-format fix Signed-off-by: mdimakov --- sycl/include/CL/sycl/backend.hpp | 2 +- sycl/source/context.cpp | 4 +--- sycl/source/detail/get_backend.hpp | 7 ++----- sycl/source/device.cpp | 4 +--- sycl/source/event.cpp | 4 +--- sycl/source/program.cpp | 4 +--- sycl/source/queue.cpp | 4 +--- 7 files changed, 8 insertions(+), 21 deletions(-) diff --git a/sycl/include/CL/sycl/backend.hpp b/sycl/include/CL/sycl/backend.hpp index 6532651f6c87a..921cba381de38 100644 --- a/sycl/include/CL/sycl/backend.hpp +++ b/sycl/include/CL/sycl/backend.hpp @@ -18,7 +18,7 @@ namespace sycl { template auto get_native(const SyclObjectT &Obj) -> typename interop::type { - // TODO use SYCL 2020 exception when implemented + // TODO use SYCL 2020 exception when implemented if (Obj.get_backend() != BackendName) throw runtime_error("Backends mismatch", PI_INVALID_OPERATION); return Obj.template get_native(); diff --git a/sycl/source/context.cpp b/sycl/source/context.cpp index 1b5365cb8ba2d..b1910f5f2de1b 100644 --- a/sycl/source/context.cpp +++ b/sycl/source/context.cpp @@ -118,9 +118,7 @@ cl_context context::get() const { return impl->get(); } bool context::is_host() const { return impl->is_host(); } -backend context::get_backend() const noexcept { - return getImplBackend(impl); -} +backend context::get_backend() const noexcept { return getImplBackend(impl); } platform context::get_platform() const { return impl->get_info(); diff --git a/sycl/source/detail/get_backend.hpp b/sycl/source/detail/get_backend.hpp index e18574d69cbf3..24a08709798f3 100644 --- a/sycl/source/detail/get_backend.hpp +++ b/sycl/source/detail/get_backend.hpp @@ -1,4 +1,4 @@ -//==------------------ get_backend.hpp - getImplBackend for impls -------------------------==// +//==------------------ get_backend.hpp - get impls backend -------------------------==// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -13,9 +13,7 @@ __SYCL_INLINE_NAMESPACE(cl) { namespace sycl { namespace detail { - -template -backend getImplBackend(const T &Impl) { +template backend getImplBackend(const T &Impl) { backend Result; if (Impl->is_host()) Result = backend::host; @@ -25,7 +23,6 @@ backend getImplBackend(const T &Impl) { return Result; } - } // namespace detail } // namespace sycl } // __SYCL_INLINE_NAMESPACE(cl) diff --git a/sycl/source/device.cpp b/sycl/source/device.cpp index fb7edbc99780a..326d82b3f1af1 100644 --- a/sycl/source/device.cpp +++ b/sycl/source/device.cpp @@ -137,9 +137,7 @@ device::get_info() const { #undef __SYCL_PARAM_TRAITS_SPEC -backend device::get_backend() const noexcept { - return getImplBackend(impl); -} +backend device::get_backend() const noexcept { return getImplBackend(impl); } pi_native_handle device::getNative() const { return impl->getNative(); } diff --git a/sycl/source/event.cpp b/sycl/source/event.cpp index e880b9f40dc4d..78250b9f8464a 100644 --- a/sycl/source/event.cpp +++ b/sycl/source/event.cpp @@ -86,9 +86,7 @@ event::event(shared_ptr_class event_impl) #undef __SYCL_PARAM_TRAITS_SPEC -backend event::get_backend() const noexcept { - return getImplBackend(impl); -} +backend event::get_backend() const noexcept { return getImplBackend(impl); } pi_native_handle event::getNative() const { return impl->getNative(); } diff --git a/sycl/source/program.cpp b/sycl/source/program.cpp index 9f3e81723e437..d3182a8fb0955 100644 --- a/sycl/source/program.cpp +++ b/sycl/source/program.cpp @@ -48,9 +48,7 @@ program::program(const context &context, cl_program clProgram) clRetainProgram(clProgram); } -backend program::get_backend() const noexcept { - return getImplBackend(impl); -} +backend program::get_backend() const noexcept { return getImplBackend(impl); } pi_native_handle program::getNative() const { return impl->getNative(); } diff --git a/sycl/source/queue.cpp b/sycl/source/queue.cpp index cc051fbfd64d3..3b50a5f5e2a73 100644 --- a/sycl/source/queue.cpp +++ b/sycl/source/queue.cpp @@ -139,9 +139,7 @@ bool queue::is_in_order() const { return impl->has_property(); } -backend queue::get_backend() const noexcept { - return getImplBackend(impl); -} +backend queue::get_backend() const noexcept { return getImplBackend(impl); } pi_native_handle queue::getNative() const { return impl->getNative(); } From 78c0c0297b9678bdb12bf58e95345aa5a0ce281b Mon Sep 17 00:00:00 2001 From: mdimakov Date: Wed, 10 Mar 2021 22:07:30 +0300 Subject: [PATCH 14/19] Clang-format fix --- sycl/source/detail/get_backend.hpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sycl/source/detail/get_backend.hpp b/sycl/source/detail/get_backend.hpp index 24a08709798f3..55963e67b6d4d 100644 --- a/sycl/source/detail/get_backend.hpp +++ b/sycl/source/detail/get_backend.hpp @@ -1,4 +1,5 @@ -//==------------------ get_backend.hpp - get impls backend -------------------------==// +//==------------------ get_backend.hpp - get impls backend +//-------------------------==// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. From a9131d9ed753afa4a61e28704d10d5378cd26250 Mon Sep 17 00:00:00 2001 From: mdimakov Date: Wed, 10 Mar 2021 22:26:21 +0300 Subject: [PATCH 15/19] Fix comments --- sycl/source/detail/event_impl.cpp | 10 ---------- sycl/unittests/get_native_interop/test_get_native.cpp | 2 +- 2 files changed, 1 insertion(+), 11 deletions(-) diff --git a/sycl/source/detail/event_impl.cpp b/sycl/source/detail/event_impl.cpp index dc286767c0a6f..2f6ebadb68c05 100644 --- a/sycl/source/detail/event_impl.cpp +++ b/sycl/source/detail/event_impl.cpp @@ -290,16 +290,6 @@ void HostProfilingInfo::start() { StartTime = getTimestamp(); } void HostProfilingInfo::end() { EndTime = getTimestamp(); } -/*backend event_impl::get_backend() const noexcept { - backend Result; - if (is_host()) - Result = backend::host; - else - Result = getPlugin().getBackend(); - - return Result; -}*/ - pi_native_handle event_impl::getNative() const { auto Plugin = getPlugin(); if (Plugin.getBackend() == backend::opencl) diff --git a/sycl/unittests/get_native_interop/test_get_native.cpp b/sycl/unittests/get_native_interop/test_get_native.cpp index 1fa3a3fc5ef85..0dc5241406c07 100644 --- a/sycl/unittests/get_native_interop/test_get_native.cpp +++ b/sycl/unittests/get_native_interop/test_get_native.cpp @@ -1,4 +1,4 @@ -//==----------- test_get_native.cpp --- get_native interop unit test +//==----------- test_get_native.cpp --- get_native interop unit test only for opencl //-------------==// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. From ff97206dadf560bdadb96a545b9d08bd496011b6 Mon Sep 17 00:00:00 2001 From: mdimakov Date: Wed, 10 Mar 2021 22:51:53 +0300 Subject: [PATCH 16/19] Adress review comments --- sycl/source/context.cpp | 2 +- sycl/source/detail/{get_backend.hpp => backend_impl.hpp} | 2 +- sycl/source/device.cpp | 2 +- sycl/source/event.cpp | 2 +- sycl/source/platform.cpp | 2 +- sycl/source/program.cpp | 2 +- sycl/source/queue.cpp | 2 +- sycl/unittests/get_native_interop/test_get_native.cpp | 3 ++- 8 files changed, 9 insertions(+), 8 deletions(-) rename sycl/source/detail/{get_backend.hpp => backend_impl.hpp} (92%) diff --git a/sycl/source/context.cpp b/sycl/source/context.cpp index b1910f5f2de1b..607a4edc44288 100644 --- a/sycl/source/context.cpp +++ b/sycl/source/context.cpp @@ -15,8 +15,8 @@ #include #include #include +#include #include -#include #include #include diff --git a/sycl/source/detail/get_backend.hpp b/sycl/source/detail/backend_impl.hpp similarity index 92% rename from sycl/source/detail/get_backend.hpp rename to sycl/source/detail/backend_impl.hpp index 55963e67b6d4d..f85c20c9cd6ef 100644 --- a/sycl/source/detail/get_backend.hpp +++ b/sycl/source/detail/backend_impl.hpp @@ -1,4 +1,4 @@ -//==------------------ get_backend.hpp - get impls backend +//==------------------ backend_impl.hpp - get impls backend //-------------------------==// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. diff --git a/sycl/source/device.cpp b/sycl/source/device.cpp index 326d82b3f1af1..cc9e0f74ea5c7 100644 --- a/sycl/source/device.cpp +++ b/sycl/source/device.cpp @@ -10,10 +10,10 @@ #include #include #include +#include #include #include #include -#include __SYCL_INLINE_NAMESPACE(cl) { namespace sycl { diff --git a/sycl/source/event.cpp b/sycl/source/event.cpp index 78250b9f8464a..c8b94a5644b13 100644 --- a/sycl/source/event.cpp +++ b/sycl/source/event.cpp @@ -12,8 +12,8 @@ #include #include #include +#include #include -#include #include #include diff --git a/sycl/source/platform.cpp b/sycl/source/platform.cpp index a6256179ba1e8..a70a1b44d9179 100644 --- a/sycl/source/platform.cpp +++ b/sycl/source/platform.cpp @@ -10,8 +10,8 @@ #include #include #include +#include #include -#include #include __SYCL_INLINE_NAMESPACE(cl) { diff --git a/sycl/source/program.cpp b/sycl/source/program.cpp index d3182a8fb0955..793c85954fcfc 100644 --- a/sycl/source/program.cpp +++ b/sycl/source/program.cpp @@ -9,7 +9,7 @@ #include #include #include -#include +#include #include #include diff --git a/sycl/source/queue.cpp b/sycl/source/queue.cpp index 3b50a5f5e2a73..e470a5c845d88 100644 --- a/sycl/source/queue.cpp +++ b/sycl/source/queue.cpp @@ -11,7 +11,7 @@ #include #include #include -#include +#include #include #include diff --git a/sycl/unittests/get_native_interop/test_get_native.cpp b/sycl/unittests/get_native_interop/test_get_native.cpp index 0dc5241406c07..1c714cc78bc4c 100644 --- a/sycl/unittests/get_native_interop/test_get_native.cpp +++ b/sycl/unittests/get_native_interop/test_get_native.cpp @@ -1,4 +1,5 @@ -//==----------- test_get_native.cpp --- get_native interop unit test only for opencl +//==----------- test_get_native.cpp --- get_native interop unit test only for +//opencl //-------------==// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. From e20666b839bd0250c25bee097d06c4997666917d Mon Sep 17 00:00:00 2001 From: mdimakov Date: Wed, 10 Mar 2021 22:55:14 +0300 Subject: [PATCH 17/19] Clang-format fix --- sycl/unittests/get_native_interop/test_get_native.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sycl/unittests/get_native_interop/test_get_native.cpp b/sycl/unittests/get_native_interop/test_get_native.cpp index 1c714cc78bc4c..0930011ff74e6 100644 --- a/sycl/unittests/get_native_interop/test_get_native.cpp +++ b/sycl/unittests/get_native_interop/test_get_native.cpp @@ -1,5 +1,5 @@ //==----------- test_get_native.cpp --- get_native interop unit test only for -//opencl +// opencl //-------------==// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. From 1c62f3fca41e6146181c3576edeee91f0ea1b59e Mon Sep 17 00:00:00 2001 From: mdimakov Date: Thu, 11 Mar 2021 19:28:10 +0300 Subject: [PATCH 18/19] symbols updated --- sycl/test/abi/sycl_symbols_linux.dump | 29 ++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/sycl/test/abi/sycl_symbols_linux.dump b/sycl/test/abi/sycl_symbols_linux.dump index 80e3f11519e9a..eb9608569576c 100644 --- a/sycl/test/abi/sycl_symbols_linux.dump +++ b/sycl/test/abi/sycl_symbols_linux.dump @@ -5,6 +5,7 @@ # RUN: env LLVM_BIN_PATH=%llvm_build_bin_dir python %sycl_tools_src_dir/abi_check.py --mode check_symbols --reference %s %sycl_libs_dir/libsycl.so # REQUIRES: linux +# UNSUPPORTED: libcxx _Z20__spirv_ocl_prefetchPKcm _Z21__spirv_MemoryBarrierN5__spv5ScopeEj @@ -3778,10 +3779,14 @@ _ZN2cl4sycl6detail18stringifyErrorCodeEi _ZN2cl4sycl6detail19convertChannelOrderE23_pi_image_channel_order _ZN2cl4sycl6detail19convertChannelOrderENS0_19image_channel_orderE _ZN2cl4sycl6detail19getImageElementSizeEhNS0_18image_channel_typeE +_ZN2cl4sycl6detail19kernel_bundle_plain37set_specialization_constant_raw_valueEjPKvm _ZN2cl4sycl6detail20associateWithHandlerERNS0_7handlerEPNS1_16AccessorBaseHostENS0_6access6targetE _ZN2cl4sycl6detail20getDeviceFromHandlerERNS0_7handlerE _ZN2cl4sycl6detail22addHostAccessorAndWaitEPNS1_16AccessorImplHostE _ZN2cl4sycl6detail22getImageNumberChannelsENS0_19image_channel_orderE +_ZN2cl4sycl6detail22get_kernel_bundle_implERKNS0_7contextERKSt6vectorINS0_6deviceESaIS6_EENS0_12bundle_stateE +_ZN2cl4sycl6detail22get_kernel_bundle_implERKNS0_7contextERKSt6vectorINS0_6deviceESaIS6_EENS0_12bundle_stateERKSt8functionIFbRKSt10shared_ptrINS1_17device_image_implEEEE +_ZN2cl4sycl6detail22get_kernel_bundle_implERKNS0_7contextERKSt6vectorINS0_6deviceESaIS6_EERKS5_INS0_9kernel_idESaISB_EENS0_12bundle_stateE _ZN2cl4sycl6detail27getPixelCoordLinearFiltModeENS0_3vecIfLi4EEENS0_15addressing_modeENS0_5rangeILi3EEERS3_ _ZN2cl4sycl6detail28getDeviceFunctionPointerImplERNS0_6deviceERNS0_7programEPKc _ZN2cl4sycl6detail28getPixelCoordNearestFiltModeENS0_3vecIfLi4EEENS0_15addressing_modeENS0_5rangeILi3EEE @@ -3875,6 +3880,8 @@ _ZN2cl4sycl8platformC1Ev _ZN2cl4sycl8platformC2EP15_cl_platform_id _ZN2cl4sycl8platformC2ERKNS0_15device_selectorE _ZN2cl4sycl8platformC2Ev +_ZN2cl4sycl9kernel_idC1EPKc +_ZN2cl4sycl9kernel_idC2EPKc _ZNK2cl4sycl12cpu_selectorclERKNS0_6deviceE _ZNK2cl4sycl12gpu_selectorclERKNS0_6deviceE _ZNK2cl4sycl13host_selectorclERKNS0_6deviceE @@ -3890,7 +3897,6 @@ _ZNK2cl4sycl15interop_handler12GetNativeMemEPNS0_6detail16AccessorImplHostE _ZNK2cl4sycl15interop_handler14GetNativeQueueEv _ZNK2cl4sycl16default_selectorclERKNS0_6deviceE _ZNK2cl4sycl20accelerator_selectorclERKNS0_6deviceE -_ZNK2cl4sycl5event11get_backendEv _ZNK2cl4sycl5event18get_profiling_infoILNS0_4info15event_profilingE4737EEENS3_12param_traitsIS4_XT_EE11return_typeEv _ZNK2cl4sycl5event18get_profiling_infoILNS0_4info15event_profilingE4738EEENS3_12param_traitsIS4_XT_EE11return_typeEv _ZNK2cl4sycl5event18get_profiling_infoILNS0_4info15event_profilingE4739EEENS3_12param_traitsIS4_XT_EE11return_typeEv @@ -3902,7 +3908,6 @@ _ZNK2cl4sycl5event9getNativeEv _ZNK2cl4sycl5eventeqERKS1_ _ZNK2cl4sycl5eventneERKS1_ _ZNK2cl4sycl5queue10get_deviceEv -_ZNK2cl4sycl5queue11get_backendEv _ZNK2cl4sycl5queue11get_contextEv _ZNK2cl4sycl5queue11is_in_orderEv _ZNK2cl4sycl5queue12get_propertyINS0_8property5queue16enable_profilingEEET_v @@ -3947,7 +3952,22 @@ _ZNK2cl4sycl6detail12sampler_impl18get_filtering_modeEv _ZNK2cl4sycl6detail12sampler_impl19get_addressing_modeEv _ZNK2cl4sycl6detail12sampler_impl33get_coordinate_normalization_modeEv _ZNK2cl4sycl6detail14host_half_impl4halfcvfEv -_ZNK2cl4sycl6device11get_backendEv +_ZNK2cl4sycl6detail18device_image_plain10has_kernelERKNS0_9kernel_idE +_ZNK2cl4sycl6detail18device_image_plain10has_kernelERKNS0_9kernel_idERKNS0_6deviceE +_ZNK2cl4sycl6detail19kernel_bundle_plain10get_kernelERKNS0_9kernel_idE +_ZNK2cl4sycl6detail19kernel_bundle_plain10has_kernelERKNS0_9kernel_idE +_ZNK2cl4sycl6detail19kernel_bundle_plain10has_kernelERKNS0_9kernel_idERKNS0_6deviceE +_ZNK2cl4sycl6detail19kernel_bundle_plain11get_backendEv +_ZNK2cl4sycl6detail19kernel_bundle_plain11get_contextEv +_ZNK2cl4sycl6detail19kernel_bundle_plain11get_devicesEv +_ZNK2cl4sycl6detail19kernel_bundle_plain14get_kernel_idsEv +_ZNK2cl4sycl6detail19kernel_bundle_plain27has_specialization_constantEj +_ZNK2cl4sycl6detail19kernel_bundle_plain30native_specialization_constantEv +_ZNK2cl4sycl6detail19kernel_bundle_plain33contains_specialization_constantsEv +_ZNK2cl4sycl6detail19kernel_bundle_plain37get_specialization_constant_raw_valueEjPvm +_ZNK2cl4sycl6detail19kernel_bundle_plain3endEv +_ZNK2cl4sycl6detail19kernel_bundle_plain5beginEv +_ZNK2cl4sycl6detail19kernel_bundle_plain5emptyEv _ZNK2cl4sycl6device12get_platformEv _ZNK2cl4sycl6device13has_extensionERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE _ZNK2cl4sycl6device14is_acceleratorEv @@ -4083,7 +4103,6 @@ _ZNK2cl4sycl6stream22get_max_statement_sizeEv _ZNK2cl4sycl6stream8get_sizeEv _ZNK2cl4sycl6streameqERKS1_ _ZNK2cl4sycl6streamneERKS1_ -_ZNK2cl4sycl7context11get_backendEv _ZNK2cl4sycl7context11get_devicesEv _ZNK2cl4sycl7context12get_platformEv _ZNK2cl4sycl7context12get_propertyINS0_3ext6oneapi8property6buffer22use_pinned_host_memoryEEET_v @@ -4116,7 +4135,6 @@ _ZNK2cl4sycl7program10get_kernelENSt7__cxx1112basic_stringIcSt11char_traitsIcESa _ZNK2cl4sycl7program10get_kernelENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEb _ZNK2cl4sycl7program10has_kernelENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE _ZNK2cl4sycl7program10has_kernelENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEb -_ZNK2cl4sycl7program11get_backendEv _ZNK2cl4sycl7program11get_contextEv _ZNK2cl4sycl7program11get_devicesEv _ZNK2cl4sycl7program12get_binariesEv @@ -4191,5 +4209,6 @@ _ZNK2cl4sycl9exception11get_cl_codeEv _ZNK2cl4sycl9exception11get_contextEv _ZNK2cl4sycl9exception11has_contextEv _ZNK2cl4sycl9exception4whatEv +_ZNK2cl4sycl9kernel_id8get_nameEv __sycl_register_lib __sycl_unregister_lib From 1d00c7b997c63aa68286bc87db942716692ee168 Mon Sep 17 00:00:00 2001 From: mdimakov Date: Thu, 11 Mar 2021 20:55:37 +0300 Subject: [PATCH 19/19] Symbols updated --- sycl/test/abi/sycl_symbols_linux.dump | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/sycl/test/abi/sycl_symbols_linux.dump b/sycl/test/abi/sycl_symbols_linux.dump index eb9608569576c..3918605a1d2c4 100644 --- a/sycl/test/abi/sycl_symbols_linux.dump +++ b/sycl/test/abi/sycl_symbols_linux.dump @@ -3897,6 +3897,7 @@ _ZNK2cl4sycl15interop_handler12GetNativeMemEPNS0_6detail16AccessorImplHostE _ZNK2cl4sycl15interop_handler14GetNativeQueueEv _ZNK2cl4sycl16default_selectorclERKNS0_6deviceE _ZNK2cl4sycl20accelerator_selectorclERKNS0_6deviceE +_ZNK2cl4sycl5event11get_backendEv _ZNK2cl4sycl5event18get_profiling_infoILNS0_4info15event_profilingE4737EEENS3_12param_traitsIS4_XT_EE11return_typeEv _ZNK2cl4sycl5event18get_profiling_infoILNS0_4info15event_profilingE4738EEENS3_12param_traitsIS4_XT_EE11return_typeEv _ZNK2cl4sycl5event18get_profiling_infoILNS0_4info15event_profilingE4739EEENS3_12param_traitsIS4_XT_EE11return_typeEv @@ -3908,6 +3909,7 @@ _ZNK2cl4sycl5event9getNativeEv _ZNK2cl4sycl5eventeqERKS1_ _ZNK2cl4sycl5eventneERKS1_ _ZNK2cl4sycl5queue10get_deviceEv +_ZNK2cl4sycl5queue11get_backendEv _ZNK2cl4sycl5queue11get_contextEv _ZNK2cl4sycl5queue11is_in_orderEv _ZNK2cl4sycl5queue12get_propertyINS0_8property5queue16enable_profilingEEET_v @@ -3968,6 +3970,7 @@ _ZNK2cl4sycl6detail19kernel_bundle_plain37get_specialization_constant_raw_valueE _ZNK2cl4sycl6detail19kernel_bundle_plain3endEv _ZNK2cl4sycl6detail19kernel_bundle_plain5beginEv _ZNK2cl4sycl6detail19kernel_bundle_plain5emptyEv +_ZNK2cl4sycl6device11get_backendEv _ZNK2cl4sycl6device12get_platformEv _ZNK2cl4sycl6device13has_extensionERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE _ZNK2cl4sycl6device14is_acceleratorEv @@ -4103,6 +4106,7 @@ _ZNK2cl4sycl6stream22get_max_statement_sizeEv _ZNK2cl4sycl6stream8get_sizeEv _ZNK2cl4sycl6streameqERKS1_ _ZNK2cl4sycl6streamneERKS1_ +_ZNK2cl4sycl7context11get_backendEv _ZNK2cl4sycl7context11get_devicesEv _ZNK2cl4sycl7context12get_platformEv _ZNK2cl4sycl7context12get_propertyINS0_3ext6oneapi8property6buffer22use_pinned_host_memoryEEET_v @@ -4135,6 +4139,7 @@ _ZNK2cl4sycl7program10get_kernelENSt7__cxx1112basic_stringIcSt11char_traitsIcESa _ZNK2cl4sycl7program10get_kernelENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEb _ZNK2cl4sycl7program10has_kernelENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE _ZNK2cl4sycl7program10has_kernelENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEb +_ZNK2cl4sycl7program11get_backendEv _ZNK2cl4sycl7program11get_contextEv _ZNK2cl4sycl7program11get_devicesEv _ZNK2cl4sycl7program12get_binariesEv