Skip to content

[SYCL] Move implementation details under sycl_private namespace #1311

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions sycl/include/CL/sycl/context.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -135,9 +137,9 @@ class context {

private:
/// Constructs a SYCL context object from a valid context_impl instance.
context(shared_ptr_class<detail::context_impl> Impl);
context(shared_ptr_class<detail::sycl_private::context_impl> Impl);

shared_ptr_class<detail::context_impl> impl;
shared_ptr_class<detail::sycl_private::context_impl> impl;
template <class Obj>
friend decltype(Obj::impl) detail::getSyclObjImpl(const Obj &SyclObject);

Expand All @@ -156,7 +158,8 @@ class context {
namespace std {
template <> struct hash<cl::sycl::context> {
size_t operator()(const cl::sycl::context &Context) const {
return hash<cl::sycl::shared_ptr_class<cl::sycl::detail::context_impl>>()(
return hash<cl::sycl::shared_ptr_class<
cl::sycl::detail::sycl_private::context_impl>>()(
cl::sycl::detail::getSyclObjImpl(Context));
}
};
Expand Down
8 changes: 5 additions & 3 deletions sycl/include/CL/sycl/detail/accessor_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -37,8 +40,7 @@ template <int Dims> class AccessorImplDevice {
range<Dims> MemRange;

bool operator==(const AccessorImplDevice &Rhs) const {
return (Offset == Rhs.Offset &&
AccessRange == Rhs.AccessRange &&
return (Offset == Rhs.Offset && AccessRange == Rhs.AccessRange &&
MemRange == Rhs.MemRange);
}
};
Expand Down Expand Up @@ -95,7 +97,7 @@ class AccessorImplHost {

void *MData = nullptr;

Command *MBlockedCmd = nullptr;
sycl_private::Command *MBlockedCmd = nullptr;
};

using AccessorImplPtr = shared_ptr_class<AccessorImplHost>;
Expand Down
4 changes: 2 additions & 2 deletions sycl/include/CL/sycl/detail/cg.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -420,14 +420,14 @@ class CGExecKernel : public CG {
public:
NDRDescT MNDRDesc;
unique_ptr_class<HostKernelBase> MHostKernel;
shared_ptr_class<detail::kernel_impl> MSyclKernel;
shared_ptr_class<detail::sycl_private::kernel_impl> MSyclKernel;
vector_class<ArgDesc> MArgs;
string_class MKernelName;
detail::OSModuleHandle MOSModuleHandle;
vector_class<shared_ptr_class<detail::stream_impl>> MStreams;

CGExecKernel(NDRDescT NDRDesc, unique_ptr_class<HostKernelBase> HKernel,
shared_ptr_class<detail::kernel_impl> SyclKernel,
shared_ptr_class<detail::sycl_private::kernel_impl> SyclKernel,
vector_class<vector_class<char>> ArgsStorage,
vector_class<detail::AccessorImplPtr> AccStorage,
vector_class<shared_ptr_class<const void>> SharedPtrStorage,
Expand Down
8 changes: 5 additions & 3 deletions sycl/include/CL/sycl/detail/helpers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<RT::PiEvent>
getOrWaitEvents(std::vector<cl::sycl::event> DepEvents,
std::shared_ptr<cl::sycl::detail::context_impl> Context);
std::vector<RT::PiEvent> getOrWaitEvents(
std::vector<cl::sycl::event> DepEvents,
std::shared_ptr<cl::sycl::detail::sycl_private::context_impl> Context);

void waitEvents(std::vector<cl::sycl::event> DepEvents);

Expand Down
9 changes: 5 additions & 4 deletions sycl/include/CL/sycl/detail/memory_manager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<detail::queue_impl>;
using EventImplPtr = std::shared_ptr<detail::event_impl>;
using ContextImplPtr = std::shared_ptr<detail::context_impl>;
using QueueImplPtr = std::shared_ptr<detail::sycl_private::queue_impl>;
using EventImplPtr = std::shared_ptr<detail::sycl_private::event_impl>;
using ContextImplPtr = std::shared_ptr<detail::sycl_private::context_impl>;

// The class contains methods that work with memory. All operations with
// device memory should go through MemoryManager.
Expand Down Expand Up @@ -133,7 +135,6 @@ class MemoryManager {
static void prefetch_usm(void *Ptr, QueueImplPtr Queue, size_t Len,
std::vector<RT::PiEvent> DepEvents,
RT::PiEvent &OutEvent);

};
} // namespace detail
} // namespace sycl
Expand Down
6 changes: 4 additions & 2 deletions sycl/include/CL/sycl/detail/pi.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ enum class PiApiKind {
#define _PI_API(api) api,
#include <CL/sycl/detail/pi.def>
};
__SYCL_INLINE_NAMESPACE(sycl_private) {
class plugin;
}
namespace pi {

#ifdef SYCL_RT_OS_WINDOWS
Expand Down Expand Up @@ -116,10 +118,10 @@ template <class To, class From> 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<plugin> GlobalPlugin;
extern std::shared_ptr<sycl_private::plugin> GlobalPlugin;

// Performs PI one-time initialization.
vector_class<plugin> initialize();
vector_class<sycl_private::plugin> initialize();

// Utility Functions to get Function Name for a PI Api.
template <PiApiKind PiApiOffset> struct PiFuncInfo {};
Expand Down
11 changes: 7 additions & 4 deletions sycl/include/CL/sycl/detail/sycl_mem_obj_i.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<detail::event_impl>;
using ContextImplPtr = shared_ptr_class<detail::context_impl>;
using EventImplPtr = shared_ptr_class<detail::sycl_private::event_impl>;
using ContextImplPtr = shared_ptr_class<detail::sycl_private::context_impl>;

// The class serves as an interface in the scheduler for all SYCL memory
// objects.
Expand Down Expand Up @@ -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<MemObjRecord> MRecord;
friend class Scheduler;
shared_ptr_class<sycl_private::MemObjRecord> MRecord;
friend class sycl_private::Scheduler;
};

} // namespace detail
Expand Down
15 changes: 7 additions & 8 deletions sycl/include/CL/sycl/detail/sycl_mem_obj_t.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<context_impl>;
using EventImplPtr = shared_ptr_class<event_impl>;
using ContextImplPtr = shared_ptr_class<sycl_private::context_impl>;
using EventImplPtr = shared_ptr_class<sycl_private::event_impl>;

template <typename T>
class aligned_allocator;
template <typename T> class aligned_allocator;
using sycl_memory_object_allocator = aligned_allocator<char>;

// The class serves as a base for all SYCL memory objects.
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -149,9 +150,7 @@ class SYCLMemObjT : public SYCLMemObjI {
if (!FinalData)
MUploadDataFunctor = nullptr;
else
MUploadDataFunctor = [this, FinalData]() {
updateHostMemory(FinalData);
};
MUploadDataFunctor = [this, FinalData]() { updateHostMemory(FinalData); };
}

template <typename Destination>
Expand Down
10 changes: 7 additions & 3 deletions sycl/include/CL/sycl/device.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -164,8 +166,9 @@ class device {
get_devices(info::device_type deviceType = info::device_type::all);

private:
shared_ptr_class<detail::device_impl> impl;
device(shared_ptr_class<detail::device_impl> impl) : impl(impl) {}
shared_ptr_class<detail::sycl_private::device_impl> impl;
device(shared_ptr_class<detail::sycl_private::device_impl> impl)
: impl(impl) {}

template <class Obj>
friend decltype(Obj::impl) detail::getSyclObjImpl(const Obj &SyclObject);
Expand All @@ -185,7 +188,8 @@ class device {
namespace std {
template <> struct hash<cl::sycl::device> {
size_t operator()(const cl::sycl::device &Device) const {
return hash<cl::sycl::shared_ptr_class<cl::sycl::detail::device_impl>>()(
return hash<cl::sycl::shared_ptr_class<
cl::sycl::detail::sycl_private::device_impl>>()(
cl::sycl::detail::getSyclObjImpl(Device));
}
};
Expand Down
9 changes: 6 additions & 3 deletions sycl/include/CL/sycl/event.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -113,9 +115,9 @@ class event {
get_profiling_info() const;

private:
event(shared_ptr_class<detail::event_impl> EventImpl);
event(shared_ptr_class<detail::sycl_private::event_impl> EventImpl);

shared_ptr_class<detail::event_impl> impl;
shared_ptr_class<detail::sycl_private::event_impl> impl;

template <class Obj>
friend decltype(Obj::impl) detail::getSyclObjImpl(const Obj &SyclObject);
Expand All @@ -130,7 +132,8 @@ class event {
namespace std {
template <> struct hash<cl::sycl::event> {
size_t operator()(const cl::sycl::event &e) const {
return hash<cl::sycl::shared_ptr_class<cl::sycl::detail::event_impl>>()(
return hash<cl::sycl::shared_ptr_class<
cl::sycl::detail::sycl_private::event_impl>>()(
cl::sycl::detail::getSyclObjImpl(e));
}
};
Expand Down
6 changes: 4 additions & 2 deletions sycl/include/CL/sycl/exception_list.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ namespace sycl {

// Forward declaration
namespace detail {
__SYCL_INLINE_NAMESPACE(sycl_private) {
class queue_impl;
}
} // namespace detail

class exception_list {
public:
Expand All @@ -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<exception_ptr_class> MList;
};
Expand Down
10 changes: 6 additions & 4 deletions sycl/include/CL/sycl/handler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <typename DataT, int Dimensions, access::mode AccessMode,
access::target AccessTarget, access::placeholder IsPlaceholder>
Expand Down Expand Up @@ -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<detail::queue_impl> Queue, bool IsHost)
handler(shared_ptr_class<detail::sycl_private::queue_impl> Queue, bool IsHost)
: MQueue(std::move(Queue)), MIsHost(IsHost) {}

/// Stores copy of Arg passed to the MArgsStorage.
Expand Down Expand Up @@ -1242,7 +1244,7 @@ class handler {
}

private:
shared_ptr_class<detail::queue_impl> MQueue;
shared_ptr_class<detail::sycl_private::queue_impl> 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
Expand All @@ -1264,7 +1266,7 @@ class handler {
detail::NDRDescT MNDRDesc;
string_class MKernelName;
/// Storage for a sycl::kernel object.
shared_ptr_class<detail::kernel_impl> MKernel;
shared_ptr_class<detail::sycl_private::kernel_impl> 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).
Expand All @@ -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 <typename DataT, int Dims, access::mode AccMode,
access::target AccTarget, access::placeholder isPlaceholder>
Expand Down
8 changes: 5 additions & 3 deletions sycl/include/CL/sycl/kernel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -117,9 +119,9 @@ class kernel {

private:
/// Constructs a SYCL kernel object from a valid kernel_impl instance.
kernel(std::shared_ptr<detail::kernel_impl> Impl);
kernel(std::shared_ptr<detail::sycl_private::kernel_impl> Impl);

shared_ptr_class<detail::kernel_impl> impl;
shared_ptr_class<detail::sycl_private::kernel_impl> impl;

template <class Obj>
friend decltype(Obj::impl) detail::getSyclObjImpl(const Obj &SyclObject);
Expand All @@ -132,7 +134,7 @@ class kernel {
namespace std {
template <> struct hash<cl::sycl::kernel> {
size_t operator()(const cl::sycl::kernel &Kernel) const {
return hash<std::shared_ptr<cl::sycl::detail::kernel_impl>>()(
return hash<std::shared_ptr<cl::sycl::detail::sycl_private::kernel_impl>>()(
cl::sycl::detail::getSyclObjImpl(Kernel));
}
};
Expand Down
Loading