diff --git a/sycl/include/CL/sycl/context.hpp b/sycl/include/CL/sycl/context.hpp index 599ea43e4576f..01706b6697f13 100644 --- a/sycl/include/CL/sycl/context.hpp +++ b/sycl/include/CL/sycl/context.hpp @@ -20,8 +20,10 @@ namespace sycl { class device; class platform; namespace detail { +__SYCL_INLINE_NAMESPACE(sycl_private) { class context_impl; } +} // namespace detail class context { public: @@ -135,9 +137,9 @@ class context { private: /// Constructs a SYCL context object from a valid context_impl instance. - context(shared_ptr_class Impl); + context(shared_ptr_class Impl); - shared_ptr_class impl; + shared_ptr_class impl; template friend decltype(Obj::impl) detail::getSyclObjImpl(const Obj &SyclObject); @@ -156,7 +158,8 @@ class context { namespace std { template <> struct hash { size_t operator()(const cl::sycl::context &Context) const { - return hash>()( + return hash>()( cl::sycl::detail::getSyclObjImpl(Context)); } }; diff --git a/sycl/include/CL/sycl/detail/accessor_impl.hpp b/sycl/include/CL/sycl/detail/accessor_impl.hpp index 83bb2fadbed88..83955dfc8e9a8 100644 --- a/sycl/include/CL/sycl/detail/accessor_impl.hpp +++ b/sycl/include/CL/sycl/detail/accessor_impl.hpp @@ -18,7 +18,10 @@ __SYCL_INLINE_NAMESPACE(cl) { namespace sycl { namespace detail { +__SYCL_INLINE_NAMESPACE(sycl_private) { +struct MemObjRecord; class Command; +} // __SYCL_INLINE_NAMESPACE(sycl_private) // The class describes a requirement to access a SYCL memory object such as // sycl::buffer and sycl::image. For example, each accessor used in a kernel, @@ -37,8 +40,7 @@ template class AccessorImplDevice { range MemRange; bool operator==(const AccessorImplDevice &Rhs) const { - return (Offset == Rhs.Offset && - AccessRange == Rhs.AccessRange && + return (Offset == Rhs.Offset && AccessRange == Rhs.AccessRange && MemRange == Rhs.MemRange); } }; @@ -95,7 +97,7 @@ class AccessorImplHost { void *MData = nullptr; - Command *MBlockedCmd = nullptr; + sycl_private::Command *MBlockedCmd = nullptr; }; using AccessorImplPtr = shared_ptr_class; diff --git a/sycl/include/CL/sycl/detail/cg.hpp b/sycl/include/CL/sycl/detail/cg.hpp index a87daa3e8e154..a9986860c4835 100644 --- a/sycl/include/CL/sycl/detail/cg.hpp +++ b/sycl/include/CL/sycl/detail/cg.hpp @@ -420,14 +420,14 @@ class CGExecKernel : public CG { public: NDRDescT MNDRDesc; unique_ptr_class MHostKernel; - shared_ptr_class MSyclKernel; + shared_ptr_class MSyclKernel; vector_class MArgs; string_class MKernelName; detail::OSModuleHandle MOSModuleHandle; vector_class> MStreams; CGExecKernel(NDRDescT NDRDesc, unique_ptr_class HKernel, - shared_ptr_class SyclKernel, + shared_ptr_class SyclKernel, vector_class> ArgsStorage, vector_class AccStorage, vector_class> SharedPtrStorage, diff --git a/sycl/include/CL/sycl/detail/helpers.hpp b/sycl/include/CL/sycl/detail/helpers.hpp index 44be0771431d1..187ba81742daf 100644 --- a/sycl/include/CL/sycl/detail/helpers.hpp +++ b/sycl/include/CL/sycl/detail/helpers.hpp @@ -41,12 +41,14 @@ inline void memcpy(void *Dst, const void *Src, size_t Size) { } } +__SYCL_INLINE_NAMESPACE(sycl_private) { class context_impl; +} // The function returns list of events that can be passed to OpenCL API as // dependency list and waits for others. -std::vector -getOrWaitEvents(std::vector DepEvents, - std::shared_ptr Context); +std::vector getOrWaitEvents( + std::vector DepEvents, + std::shared_ptr Context); void waitEvents(std::vector DepEvents); diff --git a/sycl/include/CL/sycl/detail/memory_manager.hpp b/sycl/include/CL/sycl/detail/memory_manager.hpp index d161ea283c584..82aae918afaa3 100644 --- a/sycl/include/CL/sycl/detail/memory_manager.hpp +++ b/sycl/include/CL/sycl/detail/memory_manager.hpp @@ -20,13 +20,15 @@ __SYCL_INLINE_NAMESPACE(cl) { namespace sycl { namespace detail { +__SYCL_INLINE_NAMESPACE(sycl_private) { class queue_impl; class event_impl; class context_impl; +} // __SYCL_INLINE_NAMESPACE(sycl_private) -using QueueImplPtr = std::shared_ptr; -using EventImplPtr = std::shared_ptr; -using ContextImplPtr = std::shared_ptr; +using QueueImplPtr = std::shared_ptr; +using EventImplPtr = std::shared_ptr; +using ContextImplPtr = std::shared_ptr; // The class contains methods that work with memory. All operations with // device memory should go through MemoryManager. @@ -133,7 +135,6 @@ class MemoryManager { static void prefetch_usm(void *Ptr, QueueImplPtr Queue, size_t Len, std::vector DepEvents, RT::PiEvent &OutEvent); - }; } // namespace detail } // namespace sycl diff --git a/sycl/include/CL/sycl/detail/pi.hpp b/sycl/include/CL/sycl/detail/pi.hpp index a8105d2cf4acd..ce38f95012aa8 100644 --- a/sycl/include/CL/sycl/detail/pi.hpp +++ b/sycl/include/CL/sycl/detail/pi.hpp @@ -33,7 +33,9 @@ enum class PiApiKind { #define _PI_API(api) api, #include }; +__SYCL_INLINE_NAMESPACE(sycl_private) { class plugin; +} namespace pi { #ifdef SYCL_RT_OS_WINDOWS @@ -116,10 +118,10 @@ template To cast(From value); // Holds the PluginInformation for the plugin that is bound. // Currently a global varaible is used to store OpenCL plugin information to be // used with SYCL Interoperability Constructors. -extern std::shared_ptr GlobalPlugin; +extern std::shared_ptr GlobalPlugin; // Performs PI one-time initialization. -vector_class initialize(); +vector_class initialize(); // Utility Functions to get Function Name for a PI Api. template struct PiFuncInfo {}; diff --git a/sycl/include/CL/sycl/detail/sycl_mem_obj_i.hpp b/sycl/include/CL/sycl/detail/sycl_mem_obj_i.hpp index 5d9eda8c3edd5..87a14c004a945 100644 --- a/sycl/include/CL/sycl/detail/sycl_mem_obj_i.hpp +++ b/sycl/include/CL/sycl/detail/sycl_mem_obj_i.hpp @@ -16,12 +16,15 @@ namespace sycl { namespace detail { +__SYCL_INLINE_NAMESPACE(sycl_private) { class event_impl; class context_impl; struct MemObjRecord; +class Scheduler; +} // __SYCL_INLINE_NAMESPACE(sycl_private) -using EventImplPtr = shared_ptr_class; -using ContextImplPtr = shared_ptr_class; +using EventImplPtr = shared_ptr_class; +using ContextImplPtr = shared_ptr_class; // The class serves as an interface in the scheduler for all SYCL memory // objects. @@ -67,8 +70,8 @@ class SYCLMemObjI { // fixme replace with unique_ptr_class once it is implemented. Standard // unique_ptr requires knowlege of sizeof(MemObjRecord) at compile time // which is unavailable. - shared_ptr_class MRecord; - friend class Scheduler; + shared_ptr_class MRecord; + friend class sycl_private::Scheduler; }; } // namespace detail diff --git a/sycl/include/CL/sycl/detail/sycl_mem_obj_t.hpp b/sycl/include/CL/sycl/detail/sycl_mem_obj_t.hpp index 4bd7641953099..f766f1af28e70 100644 --- a/sycl/include/CL/sycl/detail/sycl_mem_obj_t.hpp +++ b/sycl/include/CL/sycl/detail/sycl_mem_obj_t.hpp @@ -24,15 +24,16 @@ namespace sycl { namespace detail { // Forward declarations +__SYCL_INLINE_NAMESPACE(sycl_private) { class context_impl; class event_impl; class plugin; +} // __SYCL_INLINE_NAMESPACE(sycl_private) -using ContextImplPtr = shared_ptr_class; -using EventImplPtr = shared_ptr_class; +using ContextImplPtr = shared_ptr_class; +using EventImplPtr = shared_ptr_class; -template -class aligned_allocator; +template class aligned_allocator; using sycl_memory_object_allocator = aligned_allocator; // The class serves as a base for all SYCL memory objects. @@ -83,7 +84,7 @@ class SYCLMemObjT : public SYCLMemObjI { virtual ~SYCLMemObjT() = default; - const plugin &getPlugin() const; + const sycl_private::plugin &getPlugin() const; size_t getSize() const override { return MSizeInBytes; } size_t get_count() const { @@ -149,9 +150,7 @@ class SYCLMemObjT : public SYCLMemObjI { if (!FinalData) MUploadDataFunctor = nullptr; else - MUploadDataFunctor = [this, FinalData]() { - updateHostMemory(FinalData); - }; + MUploadDataFunctor = [this, FinalData]() { updateHostMemory(FinalData); }; } template diff --git a/sycl/include/CL/sycl/device.hpp b/sycl/include/CL/sycl/device.hpp index 7c78adf7cd417..8f866008bc94a 100644 --- a/sycl/include/CL/sycl/device.hpp +++ b/sycl/include/CL/sycl/device.hpp @@ -20,8 +20,10 @@ namespace sycl { // Forward declarations class device_selector; namespace detail { +__SYCL_INLINE_NAMESPACE(sycl_private) { class device_impl; } +} // namespace detail class device { public: /// Constructs a SYCL device instance as a host device. @@ -164,8 +166,9 @@ class device { get_devices(info::device_type deviceType = info::device_type::all); private: - shared_ptr_class impl; - device(shared_ptr_class impl) : impl(impl) {} + shared_ptr_class impl; + device(shared_ptr_class impl) + : impl(impl) {} template friend decltype(Obj::impl) detail::getSyclObjImpl(const Obj &SyclObject); @@ -185,7 +188,8 @@ class device { namespace std { template <> struct hash { size_t operator()(const cl::sycl::device &Device) const { - return hash>()( + return hash>()( cl::sycl::detail::getSyclObjImpl(Device)); } }; diff --git a/sycl/include/CL/sycl/event.hpp b/sycl/include/CL/sycl/event.hpp index 86e24dda794fc..0c73d10cf7872 100644 --- a/sycl/include/CL/sycl/event.hpp +++ b/sycl/include/CL/sycl/event.hpp @@ -19,8 +19,10 @@ namespace sycl { // Forward declaration class context; namespace detail { +__SYCL_INLINE_NAMESPACE(sycl_private) { class event_impl; } +} // namespace detail class event { public: @@ -113,9 +115,9 @@ class event { get_profiling_info() const; private: - event(shared_ptr_class EventImpl); + event(shared_ptr_class EventImpl); - shared_ptr_class impl; + shared_ptr_class impl; template friend decltype(Obj::impl) detail::getSyclObjImpl(const Obj &SyclObject); @@ -130,7 +132,8 @@ class event { namespace std { template <> struct hash { size_t operator()(const cl::sycl::event &e) const { - return hash>()( + return hash>()( cl::sycl::detail::getSyclObjImpl(e)); } }; diff --git a/sycl/include/CL/sycl/exception_list.hpp b/sycl/include/CL/sycl/exception_list.hpp index 9470ba14848ff..38bf6c1569d36 100644 --- a/sycl/include/CL/sycl/exception_list.hpp +++ b/sycl/include/CL/sycl/exception_list.hpp @@ -20,8 +20,10 @@ namespace sycl { // Forward declaration namespace detail { +__SYCL_INLINE_NAMESPACE(sycl_private) { class queue_impl; } +} // namespace detail class exception_list { public: @@ -39,9 +41,9 @@ class exception_list { iterator end() const; private: - friend class detail::queue_impl; + friend class detail::sycl_private::queue_impl; void PushBack(const_reference Value); - void PushBack(value_type&& Value); + void PushBack(value_type &&Value); void Clear() noexcept; vector_class MList; }; diff --git a/sycl/include/CL/sycl/handler.hpp b/sycl/include/CL/sycl/handler.hpp index 2ea4e4e83db66..a1c0cee199d9c 100644 --- a/sycl/include/CL/sycl/handler.hpp +++ b/sycl/include/CL/sycl/handler.hpp @@ -66,8 +66,10 @@ namespace detail { /// invocation APIs such as single_task. class auto_name {}; +__SYCL_INLINE_NAMESPACE(sycl_private) { class kernel_impl; class queue_impl; +} // __SYCL_INLINE_NAMESPACE(sycl_private) class stream_impl; template @@ -140,7 +142,7 @@ class handler { /// /// \param Queue is a SYCL queue. /// \param IsHost indicates if this handler is created for SYCL host device. - handler(shared_ptr_class Queue, bool IsHost) + handler(shared_ptr_class Queue, bool IsHost) : MQueue(std::move(Queue)), MIsHost(IsHost) {} /// Stores copy of Arg passed to the MArgsStorage. @@ -1242,7 +1244,7 @@ class handler { } private: - shared_ptr_class MQueue; + shared_ptr_class MQueue; /// The storage for the arguments passed. /// We need to store a copy of values that are passed explicitly through /// set_arg, require and so on, because we need them to be alive after @@ -1264,7 +1266,7 @@ class handler { detail::NDRDescT MNDRDesc; string_class MKernelName; /// Storage for a sycl::kernel object. - shared_ptr_class MKernel; + shared_ptr_class MKernel; /// Type of the command group, e.g. kernel, fill. detail::CG::CGTYPE MCGType = detail::CG::NONE; /// Pointer to the source host memory or accessor(depending on command type). @@ -1286,7 +1288,7 @@ class handler { bool MIsHost = false; // Make queue_impl class friend to be able to call finalize method. - friend class detail::queue_impl; + friend class detail::sycl_private::queue_impl; // Make accessor class friend to keep the list of associated accessors. template diff --git a/sycl/include/CL/sycl/kernel.hpp b/sycl/include/CL/sycl/kernel.hpp index 1aa8afec7703e..98d488f96b838 100644 --- a/sycl/include/CL/sycl/kernel.hpp +++ b/sycl/include/CL/sycl/kernel.hpp @@ -20,8 +20,10 @@ namespace sycl { class program; class context; namespace detail { +__SYCL_INLINE_NAMESPACE(sycl_private) { class kernel_impl; } +} // namespace detail class kernel { public: @@ -117,9 +119,9 @@ class kernel { private: /// Constructs a SYCL kernel object from a valid kernel_impl instance. - kernel(std::shared_ptr Impl); + kernel(std::shared_ptr Impl); - shared_ptr_class impl; + shared_ptr_class impl; template friend decltype(Obj::impl) detail::getSyclObjImpl(const Obj &SyclObject); @@ -132,7 +134,7 @@ class kernel { namespace std { template <> struct hash { size_t operator()(const cl::sycl::kernel &Kernel) const { - return hash>()( + return hash>()( cl::sycl::detail::getSyclObjImpl(Kernel)); } }; diff --git a/sycl/include/CL/sycl/ordered_queue.hpp b/sycl/include/CL/sycl/ordered_queue.hpp index 240d780645e8b..4de00329d1b03 100644 --- a/sycl/include/CL/sycl/ordered_queue.hpp +++ b/sycl/include/CL/sycl/ordered_queue.hpp @@ -25,8 +25,10 @@ namespace sycl { class context; class device; namespace detail { +__SYCL_INLINE_NAMESPACE(sycl_private) { class queue_impl; } +} // namespace detail class __SYCL_DEPRECATED__ ordered_queue { @@ -246,7 +248,7 @@ class __SYCL_DEPRECATED__ ordered_queue { } private: - shared_ptr_class impl; + shared_ptr_class impl; template friend decltype(Obj::impl) detail::getSyclObjImpl(const Obj &SyclObject); @@ -265,7 +267,8 @@ class __SYCL_DEPRECATED__ ordered_queue { namespace std { template <> struct hash { size_t operator()(const cl::sycl::ordered_queue &q) const { - return std::hash>()( + return std::hash< + std::shared_ptr>()( cl::sycl::detail::getSyclObjImpl(q)); } }; diff --git a/sycl/include/CL/sycl/platform.hpp b/sycl/include/CL/sycl/platform.hpp index 5841a0bbfd1d6..a209717dfdf2b 100644 --- a/sycl/include/CL/sycl/platform.hpp +++ b/sycl/include/CL/sycl/platform.hpp @@ -20,8 +20,10 @@ namespace sycl { class device_selector; class device; namespace detail { +__SYCL_INLINE_NAMESPACE(sycl_private) { class platform_impl; } +} // namespace detail class platform { public: @@ -99,8 +101,9 @@ class platform { static vector_class get_platforms(); private: - shared_ptr_class impl; - platform(shared_ptr_class impl) : impl(impl) {} + shared_ptr_class impl; + platform(shared_ptr_class impl) + : impl(impl) {} template friend T detail::createSyclObjFromImpl(decltype(T::impl) ImplObj); @@ -114,7 +117,8 @@ class platform { namespace std { template <> struct hash { size_t operator()(const cl::sycl::platform &p) const { - return hash>()( + return hash>()( cl::sycl::detail::getSyclObjImpl(p)); } }; diff --git a/sycl/include/CL/sycl/program.hpp b/sycl/include/CL/sycl/program.hpp index 491ba1fdcc933..cd61394858f7b 100644 --- a/sycl/include/CL/sycl/program.hpp +++ b/sycl/include/CL/sycl/program.hpp @@ -22,8 +22,10 @@ namespace sycl { class context; class device; namespace detail { +__SYCL_INLINE_NAMESPACE(sycl_private) { class program_impl; } +} // namespace detail enum class program_state { none, compiled, linked }; @@ -294,7 +296,7 @@ class program { program_state get_state() const; private: - program(shared_ptr_class impl); + program(shared_ptr_class impl); /// Template-free version of get_kernel. /// @@ -330,7 +332,7 @@ class program { string_class buildOptions, detail::OSModuleHandle M); - shared_ptr_class impl; + shared_ptr_class impl; template friend decltype(Obj::impl) detail::getSyclObjImpl(const Obj &SyclObject); @@ -343,7 +345,8 @@ class program { namespace std { template <> struct hash { size_t operator()(const cl::sycl::program &prg) const { - return hash>()( + return hash>()( cl::sycl::detail::getSyclObjImpl(prg)); } }; diff --git a/sycl/include/CL/sycl/queue.hpp b/sycl/include/CL/sycl/queue.hpp index 2b0fae897fa88..f2281cdf2bf2f 100644 --- a/sycl/include/CL/sycl/queue.hpp +++ b/sycl/include/CL/sycl/queue.hpp @@ -27,8 +27,10 @@ namespace sycl { class context; class device; namespace detail { +__SYCL_INLINE_NAMESPACE(sycl_private) { class queue_impl; } +} // namespace detail class queue { public: @@ -298,7 +300,7 @@ class queue { /// /// \param Ptr is a USM pointer to the memory to be prefetched to the device. /// \param Count is a number of bytes to be prefetched. - event prefetch(const void* Ptr, size_t Count) { + event prefetch(const void *Ptr, size_t Count) { return submit([=](handler &CGH) { CGH.prefetch(Ptr, Count); }); } @@ -638,7 +640,7 @@ class queue { bool is_in_order() const; private: - shared_ptr_class impl; + shared_ptr_class impl; template friend decltype(Obj::impl) detail::getSyclObjImpl(const Obj &SyclObject); @@ -656,8 +658,8 @@ class queue { namespace std { template <> struct hash { size_t operator()(const cl::sycl::queue &q) const { - return std::hash< - cl::sycl::shared_ptr_class>()( + return std::hash>()( cl::sycl::detail::getSyclObjImpl(q)); } }; diff --git a/sycl/source/detail/context_impl.hpp b/sycl/source/detail/context_impl.hpp index 99b74b3e252ac..3341d9a49147e 100644 --- a/sycl/source/detail/context_impl.hpp +++ b/sycl/source/detail/context_impl.hpp @@ -27,6 +27,7 @@ namespace sycl { // Forward declaration class device; namespace detail { +__SYCL_INLINE_NAMESPACE(sycl_private) { using PlatformImplPtr = std::shared_ptr; class context_impl { public: @@ -157,6 +158,7 @@ class context_impl { mutable KernelProgramCache MKernelProgramCache; }; +} // __SYCL_INLINE_NAMESPACE(sycl_private) } // namespace detail } // namespace sycl } // __SYCL_INLINE_NAMESPACE(cl) diff --git a/sycl/source/detail/context_info.hpp b/sycl/source/detail/context_info.hpp index cead0d2e09c2f..6174aa1ad7e4e 100644 --- a/sycl/source/detail/context_info.hpp +++ b/sycl/source/detail/context_info.hpp @@ -15,6 +15,7 @@ __SYCL_INLINE_NAMESPACE(cl) { namespace sycl { namespace detail { +__SYCL_INLINE_NAMESPACE(sycl_private) { template struct get_context_info { using RetType = @@ -30,6 +31,7 @@ template struct get_context_info { } }; +} // __SYCL_INLINE_NAMESPACE(sycl_private) } // namespace detail } // namespace sycl } // __SYCL_INLINE_NAMESPACE(cl) diff --git a/sycl/source/detail/device_impl.cpp b/sycl/source/detail/device_impl.cpp index efce61d181a2d..18698a441c291 100644 --- a/sycl/source/detail/device_impl.cpp +++ b/sycl/source/detail/device_impl.cpp @@ -14,6 +14,7 @@ __SYCL_INLINE_NAMESPACE(cl) { namespace sycl { namespace detail { +__SYCL_INLINE_NAMESPACE(sycl_private) { device_impl::device_impl() : MIsHostDevice(true), @@ -34,8 +35,9 @@ device_impl::device_impl(RT::PiDevice Device, PlatformImplPtr Platform, RT::PiDevice parent = nullptr; // TODO catch an exception and put it to list of asynchronous exceptions - Plugin.call( - MDevice, PI_DEVICE_INFO_PARENT_DEVICE, sizeof(RT::PiDevice), &parent, nullptr); + Plugin.call(MDevice, PI_DEVICE_INFO_PARENT_DEVICE, + sizeof(RT::PiDevice), &parent, + nullptr); MIsRootDevice = (nullptr == parent); if (!MIsRootDevice) { @@ -161,13 +163,11 @@ device_impl::create_sub_devices(const vector_class &Counts) const { "Partitioning to subdevices of the host device is not implemented yet", PI_INVALID_DEVICE); - if (!is_partition_supported( - info::partition_property::partition_by_counts)) { + if (!is_partition_supported(info::partition_property::partition_by_counts)) { throw cl::sycl::feature_not_supported(); } static const cl_device_partition_property P[] = { - CL_DEVICE_PARTITION_BY_COUNTS, CL_DEVICE_PARTITION_BY_COUNTS_LIST_END, - 0}; + CL_DEVICE_PARTITION_BY_COUNTS, CL_DEVICE_PARTITION_BY_COUNTS_LIST_END, 0}; vector_class Properties(P, P + 3); Properties.insert(Properties.begin() + 1, Counts.begin(), Counts.end()); return create_sub_devices(Properties.data(), Counts.size()); @@ -190,11 +190,11 @@ vector_class device_impl::create_sub_devices( const cl_device_partition_property Properties[3] = { CL_DEVICE_PARTITION_BY_AFFINITY_DOMAIN, (cl_device_partition_property)AffinityDomain, 0}; - size_t SubDevicesCount = - get_info(); + size_t SubDevicesCount = get_info(); return create_sub_devices(Properties, SubDevicesCount); } +} // __SYCL_INLINE_NAMESPACE(sycl_private) } // namespace detail } // namespace sycl } // __SYCL_INLINE_NAMESPACE(cl) diff --git a/sycl/source/detail/device_impl.hpp b/sycl/source/detail/device_impl.hpp index 26bc59587b31a..b2ad9a99c4895 100644 --- a/sycl/source/detail/device_impl.hpp +++ b/sycl/source/detail/device_impl.hpp @@ -22,6 +22,7 @@ namespace sycl { class platform; namespace detail { +__SYCL_INLINE_NAMESPACE(sycl_private) { // Forward declaration class platform_impl; @@ -205,6 +206,7 @@ class device_impl { PlatformImplPtr MPlatform; }; // class device_impl +} // __SYCL_INLINE_NAMESPACE(sycl_private) } // namespace detail } // namespace sycl } // __SYCL_INLINE_NAMESPACE(cl) diff --git a/sycl/source/detail/device_info.cpp b/sycl/source/detail/device_info.cpp index 9135f0b1c9c92..cbda7cf7ca652 100644 --- a/sycl/source/detail/device_info.cpp +++ b/sycl/source/detail/device_info.cpp @@ -23,6 +23,7 @@ __SYCL_INLINE_NAMESPACE(cl) { namespace sycl { namespace detail { +__SYCL_INLINE_NAMESPACE(sycl_private) { // Specialization for parent device template <> @@ -488,8 +489,8 @@ template <> cl_uint get_device_info_host() { PI_INVALID_DEVICE); } -template <> vector_class -get_device_info_host() { +template <> +vector_class get_device_info_host() { // TODO update once subgroups are enabled throw runtime_error("Sub-group feature is not supported on HOST device.", PI_INVALID_DEVICE); @@ -529,6 +530,7 @@ template <> bool get_device_info_host() { return true; } +} // __SYCL_INLINE_NAMESPACE(sycl_private) } // namespace detail } // namespace sycl } // __SYCL_INLINE_NAMESPACE(cl) diff --git a/sycl/source/detail/device_info.hpp b/sycl/source/detail/device_info.hpp index 322201fe242a8..92ad4a8d2e716 100644 --- a/sycl/source/detail/device_info.hpp +++ b/sycl/source/detail/device_info.hpp @@ -17,6 +17,7 @@ __SYCL_INLINE_NAMESPACE(cl) { namespace sycl { namespace detail { +__SYCL_INLINE_NAMESPACE(sycl_private) { vector_class read_fp_bitfield(cl_device_fp_config bits); @@ -427,6 +428,7 @@ template <> struct get_device_info { } }; +} // __SYCL_INLINE_NAMESPACE(sycl_private) } // namespace detail } // namespace sycl } // __SYCL_INLINE_NAMESPACE(cl) diff --git a/sycl/source/detail/event_impl.cpp b/sycl/source/detail/event_impl.cpp index b4678181df937..217ebc2b7153d 100644 --- a/sycl/source/detail/event_impl.cpp +++ b/sycl/source/detail/event_impl.cpp @@ -29,6 +29,7 @@ namespace detail { #ifdef XPTI_ENABLE_INSTRUMENTATION extern xpti::trace_event_data_t *GSYCLGraphEvent; #endif +__SYCL_INLINE_NAMESPACE(sycl_private) { // Threat all devices that don't support interoperability as host devices to // avoid attempts to call method get on such events. @@ -254,10 +255,11 @@ static uint64_t getTimestamp() { .count(); } +} // __SYCL_INLINE_NAMESPACE(sycl_private) + void HostProfilingInfo::start() { StartTime = getTimestamp(); } void HostProfilingInfo::end() { EndTime = getTimestamp(); } - } // namespace detail } // namespace sycl } // __SYCL_INLINE_NAMESPACE(cl) diff --git a/sycl/source/detail/event_impl.hpp b/sycl/source/detail/event_impl.hpp index d21c84c6b1a96..e400a884cba1b 100644 --- a/sycl/source/detail/event_impl.hpp +++ b/sycl/source/detail/event_impl.hpp @@ -20,10 +20,14 @@ __SYCL_INLINE_NAMESPACE(cl) { namespace sycl { class context; namespace detail { +__SYCL_INLINE_NAMESPACE(sycl_private) { + +// Forward declarations class plugin; class context_impl; -using ContextImplPtr = std::shared_ptr; class queue_impl; + +using ContextImplPtr = std::shared_ptr; using QueueImplPtr = std::shared_ptr; using QueueImplWPtr = std::weak_ptr; @@ -163,6 +167,7 @@ class event_impl { void *MCommand = nullptr; }; +} // __SYCL_INLINE_NAMESPACE(sycl_private) } // namespace detail } // namespace sycl } // __SYCL_INLINE_NAMESPACE(cl) diff --git a/sycl/source/detail/event_info.hpp b/sycl/source/detail/event_info.hpp index e3f487f063ce7..b0cff2237a034 100644 --- a/sycl/source/detail/event_info.hpp +++ b/sycl/source/detail/event_info.hpp @@ -16,6 +16,7 @@ __SYCL_INLINE_NAMESPACE(cl) { namespace sycl { namespace detail { +__SYCL_INLINE_NAMESPACE(sycl_private) { template struct get_event_profiling_info { using RetType = @@ -42,6 +43,7 @@ template struct get_event_info { } }; +} // __SYCL_INLINE_NAMESPACE(sycl_private) } // namespace detail } // namespace sycl } // __SYCL_INLINE_NAMESPACE(cl) diff --git a/sycl/source/detail/kernel_impl.cpp b/sycl/source/detail/kernel_impl.cpp index 9b66422978eb1..afd654dc415ff 100644 --- a/sycl/source/detail/kernel_impl.cpp +++ b/sycl/source/detail/kernel_impl.cpp @@ -18,6 +18,7 @@ __SYCL_INLINE_NAMESPACE(cl) { namespace sycl { namespace detail { +__SYCL_INLINE_NAMESPACE(sycl_private) { kernel_impl::kernel_impl(RT::PiKernel Kernel, ContextImplPtr Context) : kernel_impl(Kernel, Context, @@ -25,8 +26,7 @@ kernel_impl::kernel_impl(RT::PiKernel Kernel, ContextImplPtr Context) /*IsCreatedFromSource*/ true) {} kernel_impl::kernel_impl(RT::PiKernel Kernel, ContextImplPtr ContextImpl, - ProgramImplPtr ProgramImpl, - bool IsCreatedFromSource) + ProgramImplPtr ProgramImpl, bool IsCreatedFromSource) : MKernel(Kernel), MContext(ContextImpl), MProgramImpl(std::move(ProgramImpl)), MCreatedFromSource(IsCreatedFromSource) { @@ -42,8 +42,7 @@ kernel_impl::kernel_impl(RT::PiKernel Kernel, ContextImplPtr ContextImpl, getPlugin().call(MKernel); } -kernel_impl::kernel_impl(ContextImplPtr Context, - ProgramImplPtr ProgramImpl) +kernel_impl::kernel_impl(ContextImplPtr Context, ProgramImplPtr ProgramImpl) : MContext(Context), MProgramImpl(std::move(ProgramImpl)) {} kernel_impl::~kernel_impl() { @@ -159,6 +158,7 @@ bool kernel_impl::isCreatedFromSource() const { return MCreatedFromSource; } +} // __SYCL_INLINE_NAMESPACE(sycl_private) } // namespace detail } // namespace sycl } // __SYCL_INLINE_NAMESPACE(cl) diff --git a/sycl/source/detail/kernel_impl.hpp b/sycl/source/detail/kernel_impl.hpp index bab3d4749508d..d0c1c14dc1877 100644 --- a/sycl/source/detail/kernel_impl.hpp +++ b/sycl/source/detail/kernel_impl.hpp @@ -25,6 +25,7 @@ namespace sycl { class program; namespace detail { +__SYCL_INLINE_NAMESPACE(sycl_private) { class program_impl; using ContextImplPtr = std::shared_ptr; @@ -147,6 +148,7 @@ class kernel_impl { bool MCreatedFromSource = true; }; +} // __SYCL_INLINE_NAMESPACE(sycl_private) } // namespace detail } // namespace sycl } // __SYCL_INLINE_NAMESPACE(cl) diff --git a/sycl/source/detail/kernel_info.cpp b/sycl/source/detail/kernel_info.cpp index bced197de0cb6..9833470f54001 100644 --- a/sycl/source/detail/kernel_info.cpp +++ b/sycl/source/detail/kernel_info.cpp @@ -12,6 +12,8 @@ __SYCL_INLINE_NAMESPACE(cl) { namespace sycl { namespace detail { +__SYCL_INLINE_NAMESPACE(sycl_private) { + template <> cl::sycl::range<3> get_kernel_work_group_info_host( @@ -49,6 +51,7 @@ get_kernel_work_group_info_host( return 0; } +} // __SYCL_INLINE_NAMESPACE(sycl_private) } // namespace detail } // namespace sycl } // __SYCL_INLINE_NAMESPACE(cl) diff --git a/sycl/source/detail/kernel_info.hpp b/sycl/source/detail/kernel_info.hpp index 66a65bafec6aa..434f55437865e 100644 --- a/sycl/source/detail/kernel_info.hpp +++ b/sycl/source/detail/kernel_info.hpp @@ -17,6 +17,7 @@ __SYCL_INLINE_NAMESPACE(cl) { namespace sycl { namespace detail { +__SYCL_INLINE_NAMESPACE(sycl_private) { // OpenCL kernel information methods template struct get_kernel_info {}; @@ -58,8 +59,8 @@ struct get_kernel_work_group_info { T Result; // TODO catch an exception and put it to list of asynchronous exceptions Plugin.call( - Kernel, Device, pi::cast(Param), sizeof(T), &Result, - nullptr); + Kernel, Device, pi::cast(Param), sizeof(T), + &Result, nullptr); return Result; } }; @@ -160,6 +161,7 @@ struct get_kernel_sub_group_info_with_input> { return Result; } }; +} // __SYCL_INLINE_NAMESPACE(sycl_private) } // namespace detail } // namespace sycl } // __SYCL_INLINE_NAMESPACE(cl) diff --git a/sycl/source/detail/kernel_program_cache.cpp b/sycl/source/detail/kernel_program_cache.cpp index 18b13f3fd589c..a33604f63e7e6 100644 --- a/sycl/source/detail/kernel_program_cache.cpp +++ b/sycl/source/detail/kernel_program_cache.cpp @@ -13,6 +13,7 @@ __SYCL_INLINE_NAMESPACE(cl) { namespace sycl { namespace detail { +__SYCL_INLINE_NAMESPACE(sycl_private) { KernelProgramCache::~KernelProgramCache() { for (auto &ProgIt : MCachedPrograms) { ProgramWithBuildStateT &ProgWithState = ProgIt.second; @@ -40,6 +41,7 @@ KernelProgramCache::~KernelProgramCache() { Plugin.call(ToBeDeleted); } } -} -} -} +} // __SYCL_INLINE_NAMESPACE(sycl_private) +} // namespace detail +} // namespace sycl +} // __SYCL_INLINE_NAMESPACE(cl) diff --git a/sycl/source/detail/kernel_program_cache.hpp b/sycl/source/detail/kernel_program_cache.hpp index fff2c223743c6..ef0d8dad7641a 100644 --- a/sycl/source/detail/kernel_program_cache.hpp +++ b/sycl/source/detail/kernel_program_cache.hpp @@ -22,6 +22,8 @@ __SYCL_INLINE_NAMESPACE(cl) { namespace sycl { namespace detail { +__SYCL_INLINE_NAMESPACE(sycl_private) { + class context_impl; class KernelProgramCache { public: @@ -31,21 +33,19 @@ class KernelProgramCache { std::string Msg; pi_int32 Code; - bool isFilledIn() const { - return !Msg.empty(); - } + bool isFilledIn() const { return !Msg.empty(); } }; /// Denotes pointer to some entity with its general state and build error. /// The pointer is not null if and only if the entity is usable. /// State of the entity is provided by the user of cache instance. /// Currently there is only a single user - ProgramManager class. - template struct BuildResult { + template struct BuildResult { std::atomic Ptr; std::atomic State; BuildError Error; - BuildResult(T* P, int S) : Ptr{P}, State{S}, Error{"", 0} {} + BuildResult(T *P, int S) : Ptr{P}, State{S}, Error{"", 0} {} }; using PiProgramT = std::remove_pointer::type; @@ -91,6 +91,7 @@ class KernelProgramCache { KernelCacheT MKernelsPerProgramCache; ContextPtr MParentContext; }; +} // __SYCL_INLINE_NAMESPACE(sycl_private) } // namespace detail } // namespace sycl } // __SYCL_INLINE_NAMESPACE(cl) diff --git a/sycl/source/detail/platform_impl.cpp b/sycl/source/detail/platform_impl.cpp index ac0274c0bd4c7..7f99d989ab2b3 100644 --- a/sycl/source/detail/platform_impl.cpp +++ b/sycl/source/detail/platform_impl.cpp @@ -19,6 +19,7 @@ __SYCL_INLINE_NAMESPACE(cl) { namespace sycl { namespace detail { +__SYCL_INLINE_NAMESPACE(sycl_private) { vector_class platform_impl::get_platforms() { vector_class Platforms; @@ -146,8 +147,7 @@ static std::vector getWhiteListDesc() { } static void filterWhiteList(vector_class &PiDevices, - RT::PiPlatform PiPlatform, - const plugin &Plugin) { + RT::PiPlatform PiPlatform, const plugin &Plugin) { const std::vector WhiteList(getWhiteListDesc()); if (WhiteList.empty()) return; @@ -270,6 +270,7 @@ platform_impl::get_info() const { #include #undef PARAM_TRAITS_SPEC +} // __SYCL_INLINE_NAMESPACE(sycl_private) } // 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 8b9fd17e84ba1..60935d7a35f3f 100644 --- a/sycl/source/detail/platform_impl.hpp +++ b/sycl/source/detail/platform_impl.hpp @@ -12,8 +12,8 @@ #include #include #include -#include #include +#include __SYCL_INLINE_NAMESPACE(cl) { namespace sycl { @@ -23,6 +23,7 @@ class device_selector; class device; namespace detail { +__SYCL_INLINE_NAMESPACE(sycl_private) { // TODO: implement extension management for host device // TODO: implement parameters treatment for host device @@ -125,6 +126,7 @@ class platform_impl { RT::PiPlatform MPlatform = 0; std::shared_ptr MPlugin; }; +} // __SYCL_INLINE_NAMESPACE(sycl_private) } // namespace detail } // namespace sycl } // __SYCL_INLINE_NAMESPACE(cl) diff --git a/sycl/source/detail/platform_info.cpp b/sycl/source/detail/platform_info.cpp index 8f32d50432561..5ccf259b6b713 100644 --- a/sycl/source/detail/platform_info.cpp +++ b/sycl/source/detail/platform_info.cpp @@ -1,4 +1,5 @@ -//==----------- platform_info.cpp -----------------------------------------------==// +//==----------- platform_info.cpp +//-----------------------------------------------==// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -11,6 +12,7 @@ __SYCL_INLINE_NAMESPACE(cl) { namespace sycl { namespace detail { +__SYCL_INLINE_NAMESPACE(sycl_private) { template <> string_class get_platform_info_host() { return "FULL PROFILE"; @@ -35,6 +37,7 @@ get_platform_info_host() { return {}; } +} // __SYCL_INLINE_NAMESPACE(sycl_private) } // namespace detail } // namespace sycl } // __SYCL_INLINE_NAMESPACE(cl) diff --git a/sycl/source/detail/platform_info.hpp b/sycl/source/detail/platform_info.hpp index e9caa58db140d..298b5d5a0589e 100644 --- a/sycl/source/detail/platform_info.hpp +++ b/sycl/source/detail/platform_info.hpp @@ -16,6 +16,7 @@ __SYCL_INLINE_NAMESPACE(cl) { namespace sycl { namespace detail { +__SYCL_INLINE_NAMESPACE(sycl_private) { // The platform information methods template struct get_platform_info {}; @@ -66,6 +67,7 @@ template <> string_class get_platform_info_host(); template <> vector_class get_platform_info_host(); +} // __SYCL_INLINE_NAMESPACE(sycl_private) } // namespace detail } // namespace sycl } // __SYCL_INLINE_NAMESPACE(cl) diff --git a/sycl/source/detail/platform_util.cpp b/sycl/source/detail/platform_util.cpp index 068650692c8db..879c876ebc05f 100644 --- a/sycl/source/detail/platform_util.cpp +++ b/sycl/source/detail/platform_util.cpp @@ -19,6 +19,7 @@ __SYCL_INLINE_NAMESPACE(cl) { namespace sycl { namespace detail { +__SYCL_INLINE_NAMESPACE(sycl_private) { // Used by methods that duplicate OpenCL behaviour in order to get CPU info static void cpuid(uint32_t *CPUInfo, uint32_t Type, uint32_t SubType = 0) { @@ -131,8 +132,8 @@ void PlatformUtil::prefetch(const char *Ptr, size_t NumBytes) { const char *PtrEnd = Ptr + NumBytes; // Set the pointer to the beginning of the current cache line. - Ptr = reinterpret_cast( - reinterpret_cast(Ptr) & CacheLineMask); + Ptr = reinterpret_cast(reinterpret_cast(Ptr) & + CacheLineMask); for (; Ptr < PtrEnd; Ptr += CacheLineSize) { #if defined(SYCL_RT_OS_LINUX) __builtin_prefetch(Ptr); @@ -142,6 +143,7 @@ void PlatformUtil::prefetch(const char *Ptr, size_t NumBytes) { } } +} // __SYCL_INLINE_NAMESPACE(sycl_private) } // namespace detail } // namespace sycl } // __SYCL_INLINE_NAMESPACE(cl) diff --git a/sycl/source/detail/platform_util.hpp b/sycl/source/detail/platform_util.hpp index bf7a445d349ae..bb83dcc2b8a84 100644 --- a/sycl/source/detail/platform_util.hpp +++ b/sycl/source/detail/platform_util.hpp @@ -19,6 +19,7 @@ __SYCL_INLINE_NAMESPACE(cl) { namespace sycl { namespace detail { +__SYCL_INLINE_NAMESPACE(sycl_private) { struct PlatformUtil { enum class TypeIndex : unsigned int { @@ -43,6 +44,7 @@ struct PlatformUtil { static void prefetch(const char *Ptr, size_t NumBytes); }; +} // __SYCL_INLINE_NAMESPACE(sycl_private) } // namespace detail } // namespace sycl } // __SYCL_INLINE_NAMESPACE(cl) diff --git a/sycl/source/detail/plugin.hpp b/sycl/source/detail/plugin.hpp index e5451dfa79a37..35248323199cc 100644 --- a/sycl/source/detail/plugin.hpp +++ b/sycl/source/detail/plugin.hpp @@ -14,6 +14,7 @@ __SYCL_INLINE_NAMESPACE(cl) { namespace sycl { namespace detail { +__SYCL_INLINE_NAMESPACE(sycl_private) { class plugin { public: @@ -71,6 +72,7 @@ class plugin { bool MPiEnableTrace; }; // class plugin +} // __SYCL_INLINE_NAMESPACE(sycl_private) } // namespace detail } // namespace sycl } // __SYCL_INLINE_NAMESPACE(cl) diff --git a/sycl/source/detail/program_impl.cpp b/sycl/source/detail/program_impl.cpp index 6cd2f6b0380e8..145b8fbed9576 100644 --- a/sycl/source/detail/program_impl.cpp +++ b/sycl/source/detail/program_impl.cpp @@ -18,6 +18,7 @@ __SYCL_INLINE_NAMESPACE(cl) { namespace sycl { namespace detail { +__SYCL_INLINE_NAMESPACE(sycl_private) { program_impl::program_impl(ContextImplPtr Context) : program_impl(Context, Context->get_info()) {} @@ -429,6 +430,7 @@ vector_class program_impl::get_info() const { return get_devices(); } +} // __SYCL_INLINE_NAMESPACE(sycl_private) } // namespace detail } // namespace sycl } // __SYCL_INLINE_NAMESPACE(cl) diff --git a/sycl/source/detail/program_impl.hpp b/sycl/source/detail/program_impl.hpp index f185b471df0a2..46acc7079682c 100644 --- a/sycl/source/detail/program_impl.hpp +++ b/sycl/source/detail/program_impl.hpp @@ -28,6 +28,7 @@ namespace sycl { class kernel; namespace detail { +__SYCL_INLINE_NAMESPACE(sycl_private) { using ContextImplPtr = std::shared_ptr; @@ -390,6 +391,7 @@ template <> context program_impl::get_info() const; template <> vector_class program_impl::get_info() const; +} // __SYCL_INLINE_NAMESPACE(sycl_private) } // namespace detail } // namespace sycl } // __SYCL_INLINE_NAMESPACE(cl) diff --git a/sycl/source/detail/program_manager/program_manager.cpp b/sycl/source/detail/program_manager/program_manager.cpp index 0d95d886b5061..ed19d2a37f389 100644 --- a/sycl/source/detail/program_manager/program_manager.cpp +++ b/sycl/source/detail/program_manager/program_manager.cpp @@ -30,6 +30,7 @@ __SYCL_INLINE_NAMESPACE(cl) { namespace sycl { namespace detail { +__SYCL_INLINE_NAMESPACE(sycl_private) { using ContextImplPtr = std::shared_ptr; @@ -89,14 +90,15 @@ static RT::PiProgram createBinaryProgram(const ContextImplPtr Context, // All devices in a context are from the same platform. RT::PiDevice Device = getFirstDevice(Context); RT::PiPlatform Platform = nullptr; - Plugin.call(Device, PI_DEVICE_INFO_PLATFORM, sizeof(Platform), - &Platform, nullptr); + Plugin.call(Device, PI_DEVICE_INFO_PLATFORM, + sizeof(Platform), &Platform, nullptr); size_t PlatformNameSize = 0u; - Plugin.call(Platform, PI_PLATFORM_INFO_NAME, 0u, nullptr, - &PlatformNameSize); + Plugin.call(Platform, PI_PLATFORM_INFO_NAME, 0u, + nullptr, &PlatformNameSize); std::vector PlatformName(PlatformNameSize, '\0'); Plugin.call(Platform, PI_PLATFORM_INFO_NAME, - PlatformName.size(), PlatformName.data(), nullptr); + PlatformName.size(), + PlatformName.data(), nullptr); if (PlatformNameSize > 0u && std::strncmp(PlatformName.data(), "NVIDIA CUDA", PlatformNameSize) == 0) { IsCUDA = true; @@ -106,14 +108,15 @@ static RT::PiProgram createBinaryProgram(const ContextImplPtr Context, if (IsCUDA) { // TODO: Reemplace CreateWithSource with CreateWithBinary in CUDA backend const char *SignedData = reinterpret_cast(Data); - Plugin.call(Context->getHandleRef(), 1 /*one binary*/, &SignedData, - &DataLen, &Program); + Plugin.call( + Context->getHandleRef(), 1 /*one binary*/, &SignedData, &DataLen, + &Program); } else { RT::PiDevice Device = getFirstDevice(Context); pi_int32 BinaryStatus = CL_SUCCESS; - Plugin.call(Context->getHandleRef(), 1 /*one binary*/, &Device, - &DataLen, &Data, &BinaryStatus, - &Program); + Plugin.call( + Context->getHandleRef(), 1 /*one binary*/, &Device, &DataLen, &Data, + &BinaryStatus, &Program); } return Program; @@ -203,7 +206,7 @@ RetT *getOrBuild(KernelProgramCache &KPCache, const KeyT &CacheKey, RetT *Result = waitUntilBuilt(KPCache, BuildResult); if (Result) - return Result; + return Result; // Previous build is failed. There was no SYCL exception though. // We might try to build once more. @@ -358,7 +361,7 @@ ProgramManager::getBuiltPIProgram(OSModuleHandle M, const context &Context, auto AcquireF = [](KernelProgramCache &Cache) { return Cache.acquireCachedPrograms(); }; - auto GetF = [](const Locked &LockedCache) -> ProgramCacheT& { + auto GetF = [](const Locked &LockedCache) -> ProgramCacheT & { return LockedCache.get(); }; auto BuildF = [this, &M, &KSId, &Context] { @@ -377,9 +380,10 @@ ProgramManager::getBuiltPIProgram(OSModuleHandle M, const context &Context, const std::vector &Devices = ContextImpl->getDevices(); std::vector PiDevices(Devices.size()); - std::transform( - Devices.begin(), Devices.end(), PiDevices.begin(), - [](const device Dev) { return getRawSyclObjImpl(Dev)->getHandleRef(); }); + std::transform(Devices.begin(), Devices.end(), PiDevices.begin(), + [](const device Dev) { + return getRawSyclObjImpl(Dev)->getHandleRef(); + }); ProgramPtr BuiltProgram = build(std::move(ProgramManaged), ContextImpl, Img.CompileOptions, @@ -410,10 +414,11 @@ RT::PiKernel ProgramManager::getOrCreateKernel(OSModuleHandle M, KernelProgramCache &Cache = Ctx->getKernelProgramCache(); - auto AcquireF = [] (KernelProgramCache &Cache) { + auto AcquireF = [](KernelProgramCache &Cache) { return Cache.acquireKernelsPerProgramCache(); }; - auto GetF = [&Program] (const Locked &LockedCache) -> KernelByNameT& { + auto GetF = + [&Program](const Locked &LockedCache) -> KernelByNameT & { return LockedCache.get()[Program]; }; auto BuildF = [this, &Program, &KernelName, &Ctx] { @@ -428,8 +433,8 @@ RT::PiKernel ProgramManager::getOrCreateKernel(OSModuleHandle M, return Result; }; - return getOrBuild( - Cache, KernelName, AcquireF, GetF, BuildF); + return getOrBuild(Cache, KernelName, + AcquireF, GetF, BuildF); } RT::PiProgram @@ -493,7 +498,7 @@ static bool loadDeviceLib(const ContextImplPtr Context, const char *Name, return Prog != nullptr; } -static const char* getDeviceLibFilename(DeviceLibExt Extension) { +static const char *getDeviceLibFilename(DeviceLibExt Extension) { switch (Extension) { case cl_intel_devicelib_assert: return "libsycl-fallback-cassert.spv"; @@ -510,7 +515,7 @@ static const char* getDeviceLibFilename(DeviceLibExt Extension) { PI_INVALID_OPERATION); } -static const char* getDeviceLibExtensionStr(DeviceLibExt Extension) { +static const char *getDeviceLibExtensionStr(DeviceLibExt Extension) { switch (Extension) { case cl_intel_devicelib_assert: return "cl_intel_devicelib_assert"; @@ -680,18 +685,17 @@ getDeviceLibPrograms(const ContextImplPtr Context, {cl_intel_devicelib_math, false}, {cl_intel_devicelib_math_fp64, false}, {cl_intel_devicelib_complex, false}, - {cl_intel_devicelib_complex_fp64, false} - }; + {cl_intel_devicelib_complex_fp64, false}}; // Disable all devicelib extensions requiring fp64 support if at least // one underlying device doesn't support cl_khr_fp64. bool fp64Support = true; for (RT::PiDevice Dev : Devices) { std::string DevExtList = - get_device_info::get( + get_device_info::get( Dev, Context->getPlugin()); - fp64Support = fp64Support && - (DevExtList.npos != DevExtList.find("cl_khr_fp64")); + fp64Support = + fp64Support && (DevExtList.npos != DevExtList.find("cl_khr_fp64")); } // Load a fallback library for an extension if at least one device does not @@ -709,11 +713,12 @@ getDeviceLibPrograms(const ContextImplPtr Context, } if ((Ext == cl_intel_devicelib_math_fp64 || - Ext == cl_intel_devicelib_complex_fp64) && !fp64Support) { + Ext == cl_intel_devicelib_complex_fp64) && + !fp64Support) { continue; } - const char* ExtStr = getDeviceLibExtensionStr(Ext); + const char *ExtStr = getDeviceLibExtensionStr(Ext); bool InhibitNativeImpl = false; if (const char *Env = getenv("SYCL_DEVICELIB_INHIBIT_NATIVE")) { @@ -829,8 +834,7 @@ void ProgramManager::addImages(pi_device_binaries DeviceBinary) { KernelSetId KSId = getNextKernelSetId(); for (_pi_offload_entry EntriesIt = EntriesB; EntriesIt != EntriesE; ++EntriesIt) { - auto Result = - KSIdMap.insert(std::make_pair(EntriesIt->name, KSId)); + auto Result = KSIdMap.insert(std::make_pair(EntriesIt->name, KSId)); (void)Result; assert(Result.second && "Kernel sets are not disjoint"); } @@ -967,6 +971,7 @@ void ProgramManager::dumpImage(const DeviceImage &Img, KernelSetId KSId) const { F.close(); } +} // __SYCL_INLINE_NAMESPACE(sycl_private) } // namespace detail } // namespace sycl } // __SYCL_INLINE_NAMESPACE(cl) diff --git a/sycl/source/detail/program_manager/program_manager.hpp b/sycl/source/detail/program_manager/program_manager.hpp index 826ab66d8e187..d7af68d4c1151 100644 --- a/sycl/source/detail/program_manager/program_manager.hpp +++ b/sycl/source/detail/program_manager/program_manager.hpp @@ -34,8 +34,10 @@ __SYCL_INLINE_NAMESPACE(cl) { namespace sycl { class context; namespace detail { +__SYCL_INLINE_NAMESPACE(sycl_private) { class context_impl; + using ContextImplPtr = std::shared_ptr; using DeviceImage = pi_device_binary_struct; @@ -142,6 +144,7 @@ class ProgramManager { /// True iff a SPIRV file has been specified with an environment variable bool m_UseSpvFile = false; }; +} // __SYCL_INLINE_NAMESPACE(sycl_private) } // namespace detail } // namespace sycl } // __SYCL_INLINE_NAMESPACE(cl) diff --git a/sycl/source/detail/queue_impl.cpp b/sycl/source/detail/queue_impl.cpp index 317e6efde46a8..02ce93d3ec235 100644 --- a/sycl/source/detail/queue_impl.cpp +++ b/sycl/source/detail/queue_impl.cpp @@ -24,6 +24,8 @@ __SYCL_INLINE_NAMESPACE(cl) { namespace sycl { namespace detail { +__SYCL_INLINE_NAMESPACE(sycl_private) { + template <> cl_uint queue_impl::get_info() const { RT::PiResult result = PI_SUCCESS; if (!is_host()) @@ -186,6 +188,7 @@ void queue_impl::wait(const detail::code_location &CodeLoc) { #endif } +} // __SYCL_INLINE_NAMESPACE(sycl_private) } // namespace detail } // namespace sycl } // __SYCL_INLINE_NAMESPACE(cl) diff --git a/sycl/source/detail/queue_impl.hpp b/sycl/source/detail/queue_impl.hpp index faf58914f2354..85fc228776c53 100644 --- a/sycl/source/detail/queue_impl.hpp +++ b/sycl/source/detail/queue_impl.hpp @@ -25,6 +25,7 @@ __SYCL_INLINE_NAMESPACE(cl) { namespace sycl { namespace detail { +__SYCL_INLINE_NAMESPACE(sycl_private) { using ContextImplPtr = std::shared_ptr; using DeviceImplPtr = shared_ptr_class; @@ -400,6 +401,7 @@ class queue_impl { bool MSupportOOO = true; }; +} // __SYCL_INLINE_NAMESPACE(sycl_private) } // namespace detail } // namespace sycl } // __SYCL_INLINE_NAMESPACE(cl) diff --git a/sycl/source/detail/scheduler/commands.cpp b/sycl/source/detail/scheduler/commands.cpp index a845e9362f7b2..3bc3694f5bc04 100644 --- a/sycl/source/detail/scheduler/commands.cpp +++ b/sycl/source/detail/scheduler/commands.cpp @@ -45,6 +45,7 @@ namespace detail { // Global graph for the application extern xpti::trace_event_data_t *GSYCLGraphEvent; #endif +__SYCL_INLINE_NAMESPACE(sycl_private) { #ifdef __GNUG__ struct DemangleHandle { @@ -634,7 +635,6 @@ void AllocaCommand::printDot(std::ostream &Stream) const { Stream << " Link : " << this->MLinkedAllocaCmd << "\\n"; Stream << "\"];" << std::endl; - for (const auto &Dep : MDeps) { if (Dep.MDepCommand == nullptr) continue; @@ -759,7 +759,6 @@ cl_int ReleaseCommand::enqueueImp() { // 3. Device alloca in the pair should be in active state in order to be // correctly released. - // There is no actual memory allocation if a host alloca command is created // being linked to a device allocation. SkipRelease |= CurAllocaIsHost && !MAllocaCmd->MIsLeaderAlloca; @@ -1641,7 +1640,8 @@ cl_int ExecCGCommand::enqueueImp() { AllocaCommandBase *AllocaCmd = getAllocaForReq(Req); #if USE_PI_CUDA pi_mem MemArg = (pi_mem)AllocaCmd->getMemAllocation(); - Plugin.call(Kernel, Arg.MIndex, &MemArg); + Plugin.call(Kernel, Arg.MIndex, + &MemArg); #else RT::PiMem MemArg = (RT::PiMem)AllocaCmd->getMemAllocation(); Plugin.call(Kernel, Arg.MIndex, @@ -1731,22 +1731,25 @@ cl_int ExecCGCommand::enqueueImp() { Plugin.call(RawEvents.size(), &RawEvents[0]); } std::vector ReqMemObjs; - // Extract the Mem Objects for all Requirements, to ensure they are available if - // a user ask for them inside the interop task scope - const auto& HandlerReq = ExecInterop->MRequirements; - std::for_each(std::begin(HandlerReq), std::end(HandlerReq), [&](Requirement* Req) { - AllocaCommandBase *AllocaCmd = getAllocaForReq(Req); - auto MemArg = reinterpret_cast(AllocaCmd->getMemAllocation()); - interop_handler::ReqToMem ReqToMem = std::make_pair(Req, MemArg); - ReqMemObjs.emplace_back(ReqToMem); - }); + // Extract the Mem Objects for all Requirements, to ensure they are + // available if a user ask for them inside the interop task scope + const auto &HandlerReq = ExecInterop->MRequirements; + std::for_each( + std::begin(HandlerReq), std::end(HandlerReq), [&](Requirement *Req) { + AllocaCommandBase *AllocaCmd = getAllocaForReq(Req); + auto MemArg = reinterpret_cast(AllocaCmd->getMemAllocation()); + interop_handler::ReqToMem ReqToMem = std::make_pair(Req, MemArg); + ReqMemObjs.emplace_back(ReqToMem); + }); auto interop_queue = MQueue->get(); std::sort(std::begin(ReqMemObjs), std::end(ReqMemObjs)); interop_handler InteropHandler(std::move(ReqMemObjs), interop_queue); ExecInterop->MInteropTask->call(InteropHandler); - Plugin.call(MQueue->getHandleRef(), 0, nullptr, &Event); - Plugin.call(reinterpret_cast(interop_queue)); + Plugin.call(MQueue->getHandleRef(), 0, + nullptr, &Event); + Plugin.call( + reinterpret_cast(interop_queue)); return CL_SUCCESS; } case CG::CGTYPE::NONE: @@ -1755,6 +1758,7 @@ cl_int ExecCGCommand::enqueueImp() { } } +} // __SYCL_INLINE_NAMESPACE(sycl_private) } // namespace detail } // namespace sycl } // __SYCL_INLINE_NAMESPACE(cl) diff --git a/sycl/source/detail/scheduler/commands.hpp b/sycl/source/detail/scheduler/commands.hpp index 13763cc77a8d3..f5d7553966d25 100644 --- a/sycl/source/detail/scheduler/commands.hpp +++ b/sycl/source/detail/scheduler/commands.hpp @@ -22,6 +22,7 @@ __SYCL_INLINE_NAMESPACE(cl) { namespace sycl { namespace detail { +__SYCL_INLINE_NAMESPACE(sycl_private) { class queue_impl; class event_impl; @@ -429,6 +430,7 @@ class UpdateHostRequirementCommand : public Command { void **MDstPtr = nullptr; }; +} // __SYCL_INLINE_NAMESPACE(sycl_private) } // namespace detail } // namespace sycl } // __SYCL_INLINE_NAMESPACE(cl) diff --git a/sycl/source/detail/scheduler/graph_builder.cpp b/sycl/source/detail/scheduler/graph_builder.cpp index 62db768e40dfc..c7937006dfd7a 100644 --- a/sycl/source/detail/scheduler/graph_builder.cpp +++ b/sycl/source/detail/scheduler/graph_builder.cpp @@ -26,6 +26,7 @@ __SYCL_INLINE_NAMESPACE(cl) { namespace sycl { namespace detail { +__SYCL_INLINE_NAMESPACE(sycl_private) { // The function checks whether two requirements overlaps or not. This // information can be used to prove that executing two kernels that @@ -340,7 +341,7 @@ Command *Scheduler::GraphBuilder::addCopyBack(Requirement *Req) { // The function implements SYCL host accessor logic: host accessor // should provide access to the buffer in user space. Command *Scheduler::GraphBuilder::addHostAccessor(Requirement *Req, - const bool destructor) { + const bool destructor) { const QueueImplPtr &HostQueue = getInstance().getDefaultHostQueue(); @@ -545,8 +546,8 @@ AllocaCommandBase *Scheduler::GraphBuilder::getOrCreateAllocaForReq( // To ensure that the leader allocation is removed first AllocaCmd->getReleaseCmd()->addDep( - DepDesc(LinkedAllocaCmd->getReleaseCmd(), AllocaCmd->getRequirement(), - LinkedAllocaCmd)); + DepDesc(LinkedAllocaCmd->getReleaseCmd(), + AllocaCmd->getRequirement(), LinkedAllocaCmd)); // Device allocation takes ownership of the host ptr during // construction, host allocation doesn't. So, device allocation should @@ -767,6 +768,7 @@ void Scheduler::GraphBuilder::removeRecordForMemObj(SYCLMemObjI *MemObject) { MemObject->MRecord.reset(); } +} // __SYCL_INLINE_NAMESPACE(sycl_private) } // namespace detail } // namespace sycl } // __SYCL_INLINE_NAMESPACE(cl) diff --git a/sycl/source/detail/scheduler/graph_processor.cpp b/sycl/source/detail/scheduler/graph_processor.cpp index 95f393afaff8f..6df7fc94078e0 100644 --- a/sycl/source/detail/scheduler/graph_processor.cpp +++ b/sycl/source/detail/scheduler/graph_processor.cpp @@ -16,6 +16,7 @@ __SYCL_INLINE_NAMESPACE(cl) { namespace sycl { namespace detail { +__SYCL_INLINE_NAMESPACE(sycl_private) { static Command *getCommand(const EventImplPtr &Event) { return (Command *)Event->getCommand(); @@ -88,6 +89,7 @@ bool Scheduler::GraphProcessor::enqueueCommand(Command *Cmd, return Cmd->enqueue(EnqueueResult, Blocking); } +} // __SYCL_INLINE_NAMESPACE(sycl_private) } // namespace detail } // namespace sycl } // __SYCL_INLINE_NAMESPACE(cl) diff --git a/sycl/source/detail/scheduler/scheduler.cpp b/sycl/source/detail/scheduler/scheduler.cpp index 9a5f02fab02c8..6ba1b54e45909 100644 --- a/sycl/source/detail/scheduler/scheduler.cpp +++ b/sycl/source/detail/scheduler/scheduler.cpp @@ -19,11 +19,12 @@ __SYCL_INLINE_NAMESPACE(cl) { namespace sycl { namespace detail { +__SYCL_INLINE_NAMESPACE(sycl_private) { EventImplPtr addHostAccessorToSchedulerInstance(Requirement *Req, const bool destructor) { - return cl::sycl::detail::Scheduler::getInstance(). - addHostAccessor(Req, destructor); + return cl::sycl::detail::Scheduler::getInstance().addHostAccessor(Req, + destructor); } void Scheduler::waitForRecordToFinish(MemObjRecord *Record) { @@ -121,14 +122,12 @@ EventImplPtr Scheduler::addCopyBack(Requirement *Req) { // else that has no priority set, or has a priority higher than 2000). Scheduler Scheduler::instance __attribute__((init_priority(2000))); #else -#pragma warning(disable:4073) +#pragma warning(disable : 4073) #pragma init_seg(lib) Scheduler Scheduler::instance; #endif -Scheduler &Scheduler::getInstance() { - return instance; -} +Scheduler &Scheduler::getInstance() { return instance; } std::vector Scheduler::getWaitList(EventImplPtr Event) { std::lock_guard lock(MGraphLock); @@ -178,7 +177,7 @@ EventImplPtr Scheduler::addHostAccessor(Requirement *Req, void Scheduler::releaseHostAccessor(Requirement *Req) { Req->MBlockedCmd->MCanEnqueue = true; - MemObjRecord* Record = Req->MSYCLMemObj->MRecord.get(); + MemObjRecord *Record = Req->MSYCLMemObj->MRecord.get(); auto EnqueueLeaves = [](CircularBuffer &Leaves) { for (Command *Cmd : Leaves) { EnqueueResultT Res; @@ -193,11 +192,12 @@ void Scheduler::releaseHostAccessor(Requirement *Req) { Scheduler::Scheduler() { sycl::device HostDevice; - DefaultHostQueue = QueueImplPtr(new queue_impl( - detail::getSyclObjImpl(HostDevice), /*AsyncHandler=*/{}, - QueueOrder::Ordered, /*PropList=*/{})); + DefaultHostQueue = QueueImplPtr( + new queue_impl(detail::getSyclObjImpl(HostDevice), /*AsyncHandler=*/{}, + QueueOrder::Ordered, /*PropList=*/{})); } +} // __SYCL_INLINE_NAMESPACE(sycl_private) } // namespace detail } // namespace sycl } // __SYCL_INLINE_NAMESPACE(cl) diff --git a/sycl/source/detail/scheduler/scheduler.hpp b/sycl/source/detail/scheduler/scheduler.hpp index 90000f6ab558c..2a72fc7ec654c 100644 --- a/sycl/source/detail/scheduler/scheduler.hpp +++ b/sycl/source/detail/scheduler/scheduler.hpp @@ -22,6 +22,7 @@ __SYCL_INLINE_NAMESPACE(cl) { namespace sycl { namespace detail { +__SYCL_INLINE_NAMESPACE(sycl_private) { class queue_impl; class event_impl; @@ -234,6 +235,7 @@ class Scheduler { QueueImplPtr DefaultHostQueue; }; +} // __SYCL_INLINE_NAMESPACE(sycl_private) } // namespace detail } // namespace sycl } // __SYCL_INLINE_NAMESPACE(cl)