8
8
9
9
#pragma once
10
10
11
+ #include < CL/sycl/detail/pi.hpp>
11
12
#include < CL/sycl/detail/device_info.hpp>
12
13
#include < CL/sycl/stl.hpp>
13
14
#include < algorithm>
@@ -34,10 +35,8 @@ class device_impl {
34
35
// It can also be safely passed to the underlying native runtime API.
35
36
// Warning. Returned reference will be invalid if device_impl was destroyed.
36
37
//
37
- // TODO: change all uses of getHandleRef to get_handle, and remove the
38
- // getHandleRef after that.
39
- virtual cl_device_id &getHandleRef () = 0;
40
- virtual RT::pi_device get_handle () const = 0;
38
+ virtual RT::PiDevice &getHandleRef () = 0;
39
+ virtual const RT::PiDevice &getHandleRef () const = 0;
41
40
42
41
virtual bool is_host () const = 0;
43
42
@@ -68,7 +67,7 @@ class device_impl {
68
67
}
69
68
return get_device_info<
70
69
typename info::param_traits<info::device, param>::return_type,
71
- param>::_ (this ->get_handle ());
70
+ param>::_ (this ->getHandleRef ());
72
71
}
73
72
74
73
bool is_partition_supported (info::partition_property Prop) const {
@@ -93,15 +92,15 @@ class device_impl {
93
92
// TODO: Make code thread-safe
94
93
class device_impl_pi : public device_impl {
95
94
public:
96
- explicit device_impl_pi (RT::pi_device a_device) : m_device(a_device) {
95
+ explicit device_impl_pi (RT::PiDevice a_device) : m_device(a_device) {
97
96
// TODO catch an exception and put it to list of asynchronous exceptions
98
97
PI_CALL (RT::piDeviceGetInfo (
99
- m_device, PI_DEVICE_INFO_TYPE, sizeof (RT::pi_device_type ), &m_type, 0 ));
98
+ m_device, PI_DEVICE_INFO_TYPE, sizeof (RT::PiDeviceType ), &m_type, 0 ));
100
99
101
- RT::pi_device parent;
100
+ RT::PiDevice parent;
102
101
// TODO catch an exception and put it to list of asynchronous exceptions
103
102
PI_CALL (RT::piDeviceGetInfo (
104
- m_device, PI_DEVICE_INFO_PARENT, sizeof (RT::pi_device ), &parent, 0 ));
103
+ m_device, PI_DEVICE_INFO_PARENT, sizeof (RT::PiDevice ), &parent, 0 ));
105
104
106
105
m_isRootDevice = (nullptr == parent);
107
106
if (!m_isRootDevice) {
@@ -126,14 +125,8 @@ class device_impl_pi : public device_impl {
126
125
return pi_cast<cl_device_id >(m_device);
127
126
}
128
127
129
- cl_device_id &getHandleRef () override {
130
- // TODO: check that device is an OpenCL interop one before cast, or just
131
- // remove when all the users are moved to get_handle.
132
- return (cl_device_id &)(m_device);
133
- }
134
- RT::pi_device get_handle () const override {
135
- return m_device;
136
- }
128
+ RT::PiDevice &getHandleRef () override { return m_device; }
129
+ const RT::PiDevice &getHandleRef () const override { return m_device; }
137
130
138
131
bool is_host () const override { return false ; }
139
132
@@ -146,7 +139,7 @@ class device_impl_pi : public device_impl {
146
139
}
147
140
148
141
platform get_platform () const override {
149
- RT::pi_platform plt;
142
+ RT::PiPlatform plt;
150
143
// TODO catch an exception and put it to list of asynchronous exceptions
151
144
PI_CALL (RT::piDeviceGetInfo (
152
145
m_device, PI_DEVICE_INFO_PLATFORM, sizeof (plt), &plt, 0 ));
@@ -178,8 +171,8 @@ class device_impl_pi : public device_impl {
178
171
create_sub_devices (info::partition_affinity_domain AffinityDomain) const override ;
179
172
180
173
private:
181
- RT::pi_device m_device = 0 ;
182
- RT::pi_device_type m_type;
174
+ RT::PiDevice m_device = 0 ;
175
+ RT::PiDeviceType m_type;
183
176
bool m_isRootDevice = false ;
184
177
}; // class device_impl_pi
185
178
@@ -192,11 +185,11 @@ class device_host : public device_impl {
192
185
cl_device_id get () const override {
193
186
throw invalid_object_error (" This instance of device is a host instance" );
194
187
}
195
- cl_device_id &getHandleRef () override {
188
+ RT::PiDevice &getHandleRef () override {
196
189
throw invalid_object_error (" This instance of device is a host instance" );
197
190
}
198
- RT::pi_device get_handle () const override {
199
- pi_die (" This instance of device is a host instance" );
191
+ const RT::PiDevice & getHandleRef () const override {
192
+ throw invalid_object_error (" This instance of device is a host instance" );
200
193
}
201
194
202
195
bool is_host () const override { return true ; }
0 commit comments