Skip to content
Merged
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
4 changes: 2 additions & 2 deletions sycl/include/sycl/context.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ class __SYCL_EXPORT context : public detail::OwnerLessBase<context> {
/// \param ClContext is an instance of OpenCL cl_context.
/// \param AsyncHandler is an instance of async_handler.
#ifdef __SYCL_INTERNAL_API
context(cl_context ClContext, async_handler AsyncHandler = {});
context(OpenCLContextT ClContext, async_handler AsyncHandler = {});
#endif

/// Queries this SYCL context for information.
Expand Down Expand Up @@ -230,7 +230,7 @@ class __SYCL_EXPORT context : public detail::OwnerLessBase<context> {
///
/// \return a valid instance of OpenCL cl_context.
#ifdef __SYCL_INTERNAL_API
cl_context get() const;
OpenCLContextT get() const;
#endif

/// Returns the backend associated with this context.
Expand Down
54 changes: 27 additions & 27 deletions sycl/include/sycl/detail/backend_traits_opencl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,92 +42,92 @@ namespace detail {
// may be removed after removing the deprecated 'get_native()' methods
// from the corresponding classes.
template <> struct interop<backend::opencl, context> {
using type = cl_context;
using type = OpenCLContextT;
};

template <> struct interop<backend::opencl, device> {
using type = cl_device_id;
using type = OpenCLDeviceIdT;
};

template <> struct interop<backend::opencl, queue> {
using type = cl_command_queue;
using type = OpenCLCommandQueueT;
};

template <> struct interop<backend::opencl, platform> {
using type = cl_platform_id;
using type = OpenCLPlatformT;
};

template <typename DataT, int Dimensions, typename AllocatorT>
struct BackendInput<backend::opencl, buffer<DataT, Dimensions, AllocatorT>> {
using type = cl_mem;
using type = OpenCLMemT;
};

template <typename DataT, int Dimensions, typename AllocatorT>
struct BackendReturn<backend::opencl, buffer<DataT, Dimensions, AllocatorT>> {
using type = std::vector<cl_mem>;
using type = std::vector<OpenCLMemT>;
};

template <> struct BackendInput<backend::opencl, context> {
using type = cl_context;
using type = OpenCLContextT;
};

template <> struct BackendReturn<backend::opencl, context> {
using type = cl_context;
using type = OpenCLContextT;
};

template <> struct BackendInput<backend::opencl, device> {
using type = cl_device_id;
using type = OpenCLDeviceIdT;
};

template <> struct BackendReturn<backend::opencl, device> {
using type = cl_device_id;
using type = OpenCLDeviceIdT;
};

template <> struct interop<backend::opencl, event> {
using type = std::vector<cl_event>;
using value_type = cl_event;
using type = std::vector<OpenCLEventT>;
using value_type = OpenCLEventT;
};
template <> struct BackendInput<backend::opencl, event> {
using type = std::vector<cl_event>;
using value_type = cl_event;
using type = std::vector<OpenCLEventT>;
using value_type = OpenCLEventT;
};
template <> struct BackendReturn<backend::opencl, event> {
using type = std::vector<cl_event>;
using value_type = cl_event;
using type = std::vector<OpenCLEventT>;
using value_type = OpenCLEventT;
};

template <> struct BackendInput<backend::opencl, queue> {
using type = cl_command_queue;
using type = OpenCLCommandQueueT;
};

template <> struct BackendReturn<backend::opencl, queue> {
using type = cl_command_queue;
using type = OpenCLCommandQueueT;
};

template <> struct BackendInput<backend::opencl, platform> {
using type = cl_platform_id;
using type = OpenCLPlatformT;
};

template <> struct BackendReturn<backend::opencl, platform> {
using type = cl_platform_id;
using type = OpenCLPlatformT;
};

template <bundle_state State>
struct BackendInput<backend::opencl, kernel_bundle<State>> {
using type = cl_program;
using type = OpenCLProgramT;
};

template <bundle_state State>
struct BackendReturn<backend::opencl, kernel_bundle<State>> {
using type = std::vector<cl_program>;
using type = std::vector<OpenCLProgramT>;
};

template <> struct BackendInput<backend::opencl, kernel> {
using type = cl_kernel;
using type = OpenCLKernelT;
};

template <> struct BackendReturn<backend::opencl, kernel> {
using type = cl_kernel;
using type = OpenCLKernelT;
};

using graph = ext::oneapi::experimental::command_graph<
Expand Down Expand Up @@ -156,7 +156,7 @@ template <> struct InteropFeatureSupportMap<backend::opencl> {
namespace ur {
// Cast for std::vector<cl_event>, according to the spec, make_event
// should create one(?) event from a vector of cl_event
template <class To> inline To cast(std::vector<cl_event> value) {
template <class To> inline To cast(std::vector<OpenCLEventT> value) {
assert(value.size() == 1 &&
"Temporary workaround requires that the "
"size of the input vector for make_event be equal to one.");
Expand All @@ -166,11 +166,11 @@ template <class To> inline To cast(std::vector<cl_event> value) {
// These conversions should use UR interop API.
template <>
inline ur_program_handle_t
cast(cl_program) = delete; // Use urProgramCreateWithNativeHandle
cast(OpenCLProgramT) = delete; // Use urProgramCreateWithNativeHandle

template <>
inline ur_device_handle_t
cast(cl_device_id) = delete; // Use urDeviceCreateWithNativeHandle
cast(OpenCLDeviceIdT) = delete; // Use urDeviceCreateWithNativeHandle
} // namespace ur
} // namespace detail
} // namespace _V1
Expand Down
75 changes: 62 additions & 13 deletions sycl/include/sycl/detail/cl.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
//===----------------------------------------------------------------------===//

#pragma once
#include <sycl/detail/ur.hpp>
Comment thread
uditagarwal97 marked this conversation as resolved.

// Suppress a compiler message about undefined CL_TARGET_OPENCL_VERSION
// and define all symbols up to OpenCL 3.0
Expand All @@ -19,20 +20,68 @@
#define CL_ENABLE_BETA_EXTENSIONS
#endif

#if !defined(__SYCL_DEVICE_ONLY__) || !defined(__SYCL_JIT__)
#include <CL/cl.h>
#include <CL/cl_ext.h>
#endif

namespace sycl {
inline namespace _V1 {
#if defined(__SYCL_DEVICE_ONLY__) && defined(__SYCL_JIT__)
// Don't include the OpenCL headers when compiling for SYCL device, as they only
// define the host-side API. Instead, define the necessary types as opaque
// pointers to not break the SYCL headers that include this header.
using cl_command_queue = void *;
using cl_context = void *;
using cl_device_id = void *;
using cl_event = void *;
using cl_kernel = void *;
using cl_mem = void *;
using cl_platform_id = void *;
using cl_program = void *;
using cl_sampler = void *;
#else // !defined(__SYCL_DEVICE_ONLY__) || !defined(__SYCL_JIT__)
#include <CL/cl.h>
#include <CL/cl_ext.h>
#endif // defined(__SYCL_DEVICE_ONLY__) && defined(__SYCL_JIT__)
using OpenCLCommandQueueT = void *;
Comment thread
uditagarwal97 marked this conversation as resolved.
using OpenCLContextT = void *;
using OpenCLDeviceIdT = void *;
using OpenCLEventT = void *;
using OpenCLKernelT = void *;
using OpenCLMemT = void *;
using OpenCLPlatformT = void *;
using OpenCLProgramT = void *;
using OpenCLSamplerT = void *;
namespace detail {
inline void retainOpenCLCommandQueue(ur_native_handle_t) {}
inline void retainOpenCLContext(ur_native_handle_t) {}
inline void retainOpenCLDevice(ur_native_handle_t) {}
inline void retainOpenCLEvent(ur_native_handle_t) {}
inline void retainOpenCLKernel(ur_native_handle_t) {}
inline void retainOpenCLMemObject(ur_native_handle_t) {}
inline void retainOpenCLProgram(ur_native_handle_t) {}
} // namespace detail
#else // !defined(__SYCL_DEVICE_ONLY__)
using OpenCLCommandQueueT = cl_command_queue;
using OpenCLContextT = cl_context;
using OpenCLDeviceIdT = cl_device_id;
using OpenCLEventT = cl_event;
using OpenCLKernelT = cl_kernel;
using OpenCLMemT = cl_mem;
using OpenCLPlatformT = cl_platform_id;
using OpenCLProgramT = cl_program;
using OpenCLSamplerT = cl_sampler;
namespace detail {
inline void retainOpenCLCommandQueue(ur_native_handle_t Queue) {
__SYCL_OCL_CALL(clRetainCommandQueue, ur::cast<OpenCLCommandQueueT>(Queue));
}
inline void retainOpenCLContext(ur_native_handle_t Context) {
__SYCL_OCL_CALL(clRetainContext, ur::cast<OpenCLContextT>(Context));
}
inline void retainOpenCLDevice(ur_native_handle_t Device) {
__SYCL_OCL_CALL(clRetainDevice, ur::cast<OpenCLDeviceIdT>(Device));
}
inline void retainOpenCLEvent(ur_native_handle_t Event) {
__SYCL_OCL_CALL(clRetainEvent, ur::cast<OpenCLEventT>(Event));
}
inline void retainOpenCLKernel(ur_native_handle_t Kernel) {
__SYCL_OCL_CALL(clRetainKernel, ur::cast<OpenCLKernelT>(Kernel));
}
inline void retainOpenCLMemObject(ur_native_handle_t MemObject) {
__SYCL_OCL_CALL(clRetainMemObject, ur::cast<OpenCLMemT>(MemObject));
}
inline void retainOpenCLProgram(ur_native_handle_t Program) {
__SYCL_OCL_CALL(clRetainProgram, ur::cast<OpenCLProgramT>(Program));
}
} // namespace detail
#endif // defined(__SYCL_DEVICE_ONLY__)
} // namespace _V1
} // namespace sycl
4 changes: 2 additions & 2 deletions sycl/include/sycl/device.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class __SYCL_STANDALONE_DEBUG __SYCL_EXPORT device {
///
/// \param DeviceId is OpenCL device represented with cl_device_id
#ifdef __SYCL_INTERNAL_API
explicit device(cl_device_id DeviceId);
explicit device(OpenCLDeviceIdT DeviceId);
#endif

/// Constructs a SYCL device instance using the device selected
Expand Down Expand Up @@ -134,7 +134,7 @@ class __SYCL_STANDALONE_DEBUG __SYCL_EXPORT device {
/// \return a valid cl_device_id instance in accordance with the requirements
/// described in 4.3.1.
#ifdef __SYCL_INTERNAL_API
cl_device_id get() const;
OpenCLDeviceIdT get() const;
#endif

/// Check if device is a CPU device
Expand Down
2 changes: 1 addition & 1 deletion sycl/include/sycl/event.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class __SYCL_EXPORT event : public detail::OwnerLessBase<event> {
/// \param ClEvent is a valid instance of OpenCL cl_event.
/// \param SyclContext is an instance of SYCL context.
#ifdef __SYCL_INTERNAL_API
event(cl_event ClEvent, const context &SyclContext);
event(OpenCLEventT ClEvent, const context &SyclContext);
#endif

event(const event &rhs) = default;
Expand Down
6 changes: 3 additions & 3 deletions sycl/include/sycl/handler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,7 @@ class __SYCL_EXPORT handler {
template <typename T> void setArgHelper(int ArgIndex, T &&Arg) {
void *StoredArg = storePlainArg(Arg);

if (!std::is_same<cl_mem, T>::value && std::is_pointer<T>::value) {
if (!std::is_same<OpenCLMemT, T>::value && std::is_pointer<T>::value) {
addArg(detail::kernel_param_kind_t::kind_pointer, StoredArg, sizeof(T),
ArgIndex);
} else if (ext::oneapi::experimental::detail::is_struct_with_special_type<
Expand Down Expand Up @@ -1150,9 +1150,9 @@ class __SYCL_EXPORT handler {
&& std::is_standard_layout<std::remove_reference_t<T>>::value
#endif
|| is_same_type<sampler, T>::value // Sampler
|| (!is_same_type<cl_mem, T>::value &&
|| (!is_same_type<OpenCLMemT, T>::value &&
std::is_pointer_v<remove_cv_ref_t<T>>) // USM
|| is_same_type<cl_mem, T>::value // Interop
|| is_same_type<OpenCLMemT, T>::value // Interop
|| is_same_type<stream, T>::value // Stream
|| sycl::is_device_copyable_v<remove_cv_ref_t<T>>;
};
Expand Down
4 changes: 2 additions & 2 deletions sycl/include/sycl/image.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ class __SYCL_EXPORT image_plain {
uint8_t Dimensions, const property_list &PropList);

#ifdef __SYCL_INTERNAL_API
image_plain(cl_mem ClMemObject, const context &SyclContext,
image_plain(OpenCLMemT ClMemObject, const context &SyclContext,
event AvailableEvent,
std::unique_ptr<SYCLMemObjAllocator> Allocator,
uint8_t Dimensions);
Expand Down Expand Up @@ -583,7 +583,7 @@ class __SYCL2020_DEPRECATED(
Dimensions, PropList, /*IsConstPtr*/ false) {}

#ifdef __SYCL_INTERNAL_API
image(cl_mem ClMemObject, const context &SyclContext,
image(OpenCLMemT ClMemObject, const context &SyclContext,
event AvailableEvent = {})
: common_base(ClMemObject, SyclContext, AvailableEvent,
std::make_unique<
Expand Down
4 changes: 2 additions & 2 deletions sycl/include/sycl/kernel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ class __SYCL_EXPORT kernel : public detail::OwnerLessBase<kernel> {
/// \param ClKernel is a valid OpenCL cl_kernel instance
/// \param SyclContext is a valid SYCL context
#ifdef __SYCL_INTERNAL_API
kernel(cl_kernel ClKernel, const context &SyclContext);
kernel(OpenCLKernelT ClKernel, const context &SyclContext);
#endif

kernel() = delete;
Expand Down Expand Up @@ -114,7 +114,7 @@ class __SYCL_EXPORT kernel : public detail::OwnerLessBase<kernel> {
///
/// \return a valid cl_kernel instance
#ifdef __SYCL_INTERNAL_API
cl_kernel get() const;
OpenCLKernelT get() const;
#endif

/// Get the context that this kernel is defined for.
Expand Down
4 changes: 2 additions & 2 deletions sycl/include/sycl/platform.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class __SYCL_EXPORT platform : public detail::OwnerLessBase<platform> {
///
/// \param PlatformId is an OpenCL cl_platform_id instance.
#ifdef __SYCL_INTERNAL_API
explicit platform(cl_platform_id PlatformId);
explicit platform(OpenCLPlatformT PlatformId);
#endif

/// Constructs a SYCL platform instance using a device_selector.
Expand Down Expand Up @@ -132,7 +132,7 @@ class __SYCL_EXPORT platform : public detail::OwnerLessBase<platform> {
///
/// \return an instance of OpenCL cl_platform_id.
#ifdef __SYCL_INTERNAL_API
cl_platform_id get() const;
OpenCLPlatformT get() const;
#endif

/// Checks if platform supports specified extension.
Expand Down
4 changes: 2 additions & 2 deletions sycl/include/sycl/queue.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ class __SYCL_EXPORT queue : public detail::OwnerLessBase<queue> {
/// \param SyclContext is a valid SYCL context.
/// \param AsyncHandler is a SYCL asynchronous exception handler.
#ifdef __SYCL_INTERNAL_API
queue(cl_command_queue ClQueue, const context &SyclContext,
queue(OpenCLCommandQueueT ClQueue, const context &SyclContext,
const async_handler &AsyncHandler = {});
#endif

Expand Down Expand Up @@ -393,7 +393,7 @@ class __SYCL_EXPORT queue : public detail::OwnerLessBase<queue> {
/// \return a valid instance of OpenCL queue, which is retained before being
/// returned.
#ifdef __SYCL_INTERNAL_API
cl_command_queue get() const;
OpenCLCommandQueueT get() const;
#endif

/// \return an associated SYCL context.
Expand Down
2 changes: 1 addition & 1 deletion sycl/include/sycl/sampler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class __SYCL_EXPORT __SYCL_SPECIAL_CLASS __SYCL_TYPE(sampler) sampler {
const property_list &propList = {});

#ifdef __SYCL_INTERNAL_API
sampler(cl_sampler clSampler, const context &syclContext);
sampler(OpenCLSamplerT clSampler, const context &syclContext);
#endif

sampler(const sampler &rhs) = default;
Expand Down
Loading
Loading