Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
52 changes: 27 additions & 25 deletions sycl/include/sycl/detail/cl.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,36 +20,28 @@
#define CL_ENABLE_BETA_EXTENSIONS
#endif

#if !defined(__SYCL_DEVICE_ONLY__) || !defined(__SYCL_JIT__)
#ifndef __SYCL_DEVICE_ONLY__
#include <CL/cl.h>
#include <CL/cl_ext.h>
#else
// On the SYCL device pass we don't need to include the OpenCL headers.
// Just forward declare the opaque handle types used by SYCL headers.
// We should not do "using cl_command_queue = void*" because that
// can cause redifinition errors if the user application also
// includes OpenCL headers.
typedef struct _cl_command_queue *cl_command_queue;
typedef struct _cl_context *cl_context;
typedef struct _cl_device_id *cl_device_id;
typedef struct _cl_event *cl_event;
typedef struct _cl_kernel *cl_kernel;
typedef struct _cl_mem *cl_mem;
typedef struct _cl_platform_id *cl_platform_id;
typedef struct _cl_program *cl_program;
typedef struct _cl_sampler *cl_sampler;
#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 OpenCLCommandQueueT = void *;
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;
Expand All @@ -59,7 +51,17 @@ using OpenCLMemT = cl_mem;
using OpenCLPlatformT = cl_platform_id;
using OpenCLProgramT = cl_program;
using OpenCLSamplerT = cl_sampler;

namespace detail {
#ifdef __SYCL_DEVICE_ONLY__
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) {}
#else // __SYCL_DEVICE_ONLY__
inline void retainOpenCLCommandQueue(ur_native_handle_t Queue) {
__SYCL_OCL_CALL(clRetainCommandQueue, ur::cast<OpenCLCommandQueueT>(Queue));
}
Expand All @@ -81,7 +83,7 @@ inline void retainOpenCLMemObject(ur_native_handle_t 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 detail
} // namespace _V1
} // namespace sycl
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

// CHECK-ONE-CMDLIST: zeCommandListCreateImmediate = 2
// CHECK-PER-THREAD-CMDLIST: zeCommandListCreateImmediate = 4
#include <CL/cl.h>
#include <iostream>

#include <sycl/detail/core.hpp>
Expand Down
1 change: 1 addition & 0 deletions sycl/test-e2e/Basic/buffer/buffer_create.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
// UNSUPPORTED: linux && arch-intel_gpu_mtl_u
// UNSUPPORTED-TRACKER: https://github.com/intel/llvm/issues/22405

#include <CL/cl.h>
#include <iostream>
#include <level_zero/ze_api.h>
#include <sycl/detail/core.hpp>
Expand Down
1 change: 1 addition & 0 deletions sycl/test-e2e/Basic/kernel_info.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
//
//===----------------------------------------------------------------------===//

#include <CL/cl.h>
#include <cassert>
#include <sycl/detail/core.hpp>
#include <sycl/kernel_bundle.hpp>
Expand Down
1 change: 1 addition & 0 deletions sycl/test-e2e/KernelCompiler/opencl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
// -- Test the kernel_compiler with OpenCL source.
// RUN: %{build} -o %t.out
// RUN: %{l0_leak_check} %{run} %t.out
#include <CL/cl.h>
#include <iostream>

#include <sycl/detail/core.hpp>
Expand Down
1 change: 1 addition & 0 deletions sycl/test-e2e/KernelCompiler/opencl_cache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
// CHECK-READ-FROM-CACHE: [Persistent Cache]: enabled
// CHECK-READ-FROM-CACHE-NOT: [kernel_compiler Persistent Cache]: binary has been cached
// CHECK-READ-FROM-CACHE: [kernel_compiler Persistent Cache]: using cached binary
#include <CL/cl.h>
#include <iostream>

#include <sycl/detail/core.hpp>
Expand Down
1 change: 1 addition & 0 deletions sycl/test-e2e/KernelCompiler/opencl_capabilities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
// so long as ocloc is installed and should be able to
// successfully run and pass these tests.

#include <CL/cl.h>
#include <sycl/detail/core.hpp>
#include <sycl/kernel_bundle.hpp>
#include <sycl/usm.hpp>
Expand Down
1 change: 1 addition & 0 deletions sycl/test-e2e/KernelCompiler/spirv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
// loads pre-compiled kernels from a SPIR-V file and runs them.
#include <iostream>

#include <CL/cl.h>
#include <array>
#include <cassert>
#include <fstream>
Expand Down
1 change: 1 addition & 0 deletions sycl/test-e2e/Regression/local-arg-align.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
//
//===----------------------------------------------------------------------===//

#include <CL/cl.h>
#include <iostream>

#include <sycl/detail/core.hpp>
Expand Down
Loading