Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
12 changes: 6 additions & 6 deletions sycl/include/sycl/context.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,16 +161,16 @@ class __SYCL_EXPORT context : public detail::OwnerLessBase<context> {
async_handler AsyncHandler,
const property_list &PropList = {});

/// Constructs a SYCL context instance from OpenCL cl_context.
/// Constructs a SYCL context instance from OpenCL OpenCLContextT.
Comment thread
uditagarwal97 marked this conversation as resolved.
Outdated
///
/// ClContext is retained on SYCL context instantiation.
/// The constructed SYCL context will use the AsyncHandler parameter to handle
/// exceptions.
///
/// \param ClContext is an instance of OpenCL cl_context.
/// \param ClContext is an instance of OpenCL OpenCLContextT.
/// \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 @@ -217,11 +217,11 @@ class __SYCL_EXPORT context : public detail::OwnerLessBase<context> {

/// Gets OpenCL interoperability context.
///
/// The OpenCL cl_context handle is retained on return.
/// The OpenCL OpenCLContextT handle is retained on return.
///
/// \return a valid instance of OpenCL cl_context.
/// \return a valid instance of OpenCL OpenCLContextT.
#ifdef __SYCL_INTERNAL_API
cl_context get() const;
OpenCLContextT get() const;
#endif

/// Returns the backend associated with this context.
Expand Down
60 changes: 30 additions & 30 deletions sycl/include/sycl/detail/backend_traits_opencl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

#include <sycl/backend_types.hpp> // for backend
#include <sycl/detail/backend_traits.hpp> // for BackendInput, BackendReturn
#include <sycl/detail/cl.h> // for _cl_event, cl_event, cl_de...
#include <sycl/detail/cl.h> // for _cl_event, OpenCLEventT, cl_de...
#include <sycl/detail/fwd/buffer.hpp> // for buffer (fwd)
#include <sycl/detail/ur.hpp> // for assertion and ur handles
#include <sycl/device.hpp> // for device
Expand All @@ -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 All @@ -154,9 +154,9 @@ 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) {
// Cast for std::vector<OpenCLEventT>, according to the spec, make_event
Comment thread
uditagarwal97 marked this conversation as resolved.
Outdated
// should create one(?) event from a vector of OpenCLEventT
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
14 changes: 7 additions & 7 deletions sycl/include/sycl/device.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,12 @@ class __SYCL_STANDALONE_DEBUG __SYCL_EXPORT device {
/// Constructs a SYCL device instance using the default device.
device();

/// Constructs a SYCL device instance from an OpenCL cl_device_id
/// Constructs a SYCL device instance from an OpenCL OpenCLDeviceIdT
/// in accordance with the requirements described in 4.3.1.
///
/// \param DeviceId is OpenCL device represented with cl_device_id
/// \param DeviceId is OpenCL device represented with OpenCLDeviceIdT
#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 @@ -122,10 +122,10 @@ class __SYCL_STANDALONE_DEBUG __SYCL_EXPORT device {

/// Get instance of device
///
/// \return a valid cl_device_id instance in accordance with the requirements
/// described in 4.3.1.
/// \return a valid OpenCLDeviceIdT 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 All @@ -147,7 +147,7 @@ class __SYCL_STANDALONE_DEBUG __SYCL_EXPORT device {
///
/// If this SYCL device is an OpenCL device then the SYCL platform
/// must encapsulate the OpenCL cl_plaform_id associated with the
/// underlying OpenCL cl_device_id of this SYCL device.
/// underlying OpenCL OpenCLDeviceIdT of this SYCL device.
/// The value returned must be equal to that returned by
/// get_info<info::device::platform>().
///
Expand Down
6 changes: 3 additions & 3 deletions sycl/include/sycl/event.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,14 @@ class __SYCL_EXPORT event : public detail::OwnerLessBase<event> {
/// If the constructed SYCL event is waited on it will complete immediately.
event();

/// Constructs a SYCL event instance from an OpenCL cl_event.
/// Constructs a SYCL event instance from an OpenCL OpenCLEventT.
///
/// The SyclContext must match the OpenCL context associated with the ClEvent.
///
/// \param ClEvent is a valid instance of OpenCL cl_event.
/// \param ClEvent is a valid instance of OpenCL OpenCLEventT.
/// \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 @@ -1147,9 +1147,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
Loading
Loading