DPC++ Runtime
Runtime libraries for oneAPI DPC++
opencl.hpp
Go to the documentation of this file.
1 
2 //==---------------- opencl.hpp - SYCL OpenCL backend ----------------------==//
3 //
4 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5 // See https://llvm.org/LICENSE.txt for license information.
6 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //
8 //===----------------------------------------------------------------------===//
9 
10 #pragma once
11 
12 #include <CL/sycl/backend.hpp>
13 
15 namespace sycl {
16 namespace opencl {
17 // Implementation of various "make" functions resides in SYCL RT because
18 // creating SYCL objects requires knowing details not accessible here.
19 // Note that they take opaque pi_native_handle that real OpenCL handles
20 // are casted to.
21 //
22 __SYCL_EXPORT platform make_platform(pi_native_handle NativeHandle);
23 __SYCL_EXPORT device make_device(pi_native_handle NativeHandle);
24 __SYCL_EXPORT context make_context(pi_native_handle NativeHandle);
25 #ifdef __SYCL_INTERNAL_API
26 __SYCL_EXPORT program make_program(const context &Context,
27  pi_native_handle NativeHandle);
28 #endif
29 __SYCL_EXPORT queue make_queue(const context &Context,
30  pi_native_handle InteropHandle);
31 
32 // Construction of SYCL platform.
33 template <typename T, typename detail::enable_if_t<
34  std::is_same<T, platform>::value> * = nullptr>
35 __SYCL_DEPRECATED("Use SYCL 2020 sycl::make_platform free function")
36 T make(typename detail::interop<backend::opencl, T>::type Interop) {
37  return make_platform(detail::pi::cast<pi_native_handle>(Interop));
38 }
39 
40 // Construction of SYCL device.
41 template <typename T, typename detail::enable_if_t<
42  std::is_same<T, device>::value> * = nullptr>
43 __SYCL_DEPRECATED("Use SYCL 2020 sycl::make_device free function")
44 T make(typename detail::interop<backend::opencl, T>::type Interop) {
45  return make_device(detail::pi::cast<pi_native_handle>(Interop));
46 }
47 
48 // Construction of SYCL context.
49 template <typename T, typename detail::enable_if_t<
50  std::is_same<T, context>::value> * = nullptr>
51 __SYCL_DEPRECATED("Use SYCL 2020 sycl::make_context free function")
52 T make(typename detail::interop<backend::opencl, T>::type Interop) {
53  return make_context(detail::pi::cast<pi_native_handle>(Interop));
54 }
55 
56 // Construction of SYCL program.
57 #ifdef __SYCL_INTERNAL_API
58 template <typename T, typename detail::enable_if_t<
59  std::is_same<T, program>::value> * = nullptr>
60 __SYCL_DEPRECATED("Use SYCL 2020 sycl::make_program free function")
61 T make(const context &Context,
62  typename detail::interop<backend::opencl, T>::type Interop) {
63  return make_program(Context, detail::pi::cast<pi_native_handle>(Interop));
64 }
65 #endif
66 
67 // Construction of SYCL queue.
68 template <typename T, typename detail::enable_if_t<
69  std::is_same<T, queue>::value> * = nullptr>
70 __SYCL_DEPRECATED("Use SYCL 2020 sycl::make_queue free function")
71 T make(const context &Context,
72  typename detail::interop<backend::opencl, T>::type Interop) {
73  return make_queue(Context, detail::pi::cast<pi_native_handle>(Interop));
74 }
75 } // namespace opencl
76 } // namespace sycl
77 } // __SYCL_INLINE_NAMESPACE(cl)
cl::sycl::backend
backend
Definition: backend_types.hpp:21
T
cl::sycl::opencl::make_platform
platform make_platform(pi_native_handle NativeHandle)
Definition: opencl.cpp:23
cl::sycl::ext::oneapi::level_zero::make_program
program make_program(const context &Context, pi_native_handle NativeHandle)
Definition: level_zero.cpp:72
cl::sycl::backend::opencl
@ opencl
cl::sycl::opencl::make_device
device make_device(pi_native_handle NativeHandle)
Definition: opencl.cpp:29
__SYCL_DEPRECATED
#define __SYCL_DEPRECATED(message)
Definition: defines_elementary.hpp:47
sycl
Definition: invoke_simd.hpp:68
cl::sycl::opencl::make_context
context make_context(pi_native_handle NativeHandle)
Definition: opencl.cpp:35
cl::sycl::queue
Encapsulates a single SYCL queue which schedules kernels on a SYCL device.
Definition: queue.hpp:103
cl::sycl::device
The SYCL device class encapsulates a single SYCL device on which kernels may be executed.
Definition: device.hpp:35
cl
We provide new interfaces for matrix muliply in this patch:
Definition: access.hpp:13
cl::sycl::detail::interop
Definition: backend_traits.hpp:18
pi_native_handle
uintptr_t pi_native_handle
Definition: pi.h:76
cl::sycl::opencl::make_queue
queue make_queue(const context &Context, pi_native_handle InteropHandle)
Definition: opencl.cpp:52
cl::sycl::platform
Encapsulates a SYCL platform on which kernels may be executed.
Definition: platform.hpp:34
backend.hpp
cl::sycl::opencl::make
T make(const context &Context, typename detail::interop< backend::opencl, T >::type Interop)
Definition: opencl.hpp:71
cl::sycl::context
The context class represents a SYCL context on which kernel functions may be executed.
Definition: context.hpp:35
cl::sycl::detail::enable_if_t
typename std::enable_if< B, T >::type enable_if_t
Definition: stl_type_traits.hpp:24
__SYCL_INLINE_NAMESPACE
#define __SYCL_INLINE_NAMESPACE(X)
Definition: defines_elementary.hpp:12