@@ -103,53 +103,161 @@ void DPPLDevice_Delete (__dppl_take DPPLSyclDeviceRef DRef)
103
103
104
104
bool DPPLDevice_IsAccelerator (__dppl_keep const DPPLSyclDeviceRef DRef)
105
105
{
106
- return unwrap (DRef)->is_accelerator ();
106
+ auto D = unwrap (DRef);
107
+ if (D) {
108
+ return D->is_accelerator ();
109
+ }
110
+ return false ;
107
111
}
108
112
109
113
bool DPPLDevice_IsCPU (__dppl_keep const DPPLSyclDeviceRef DRef)
110
114
{
111
- return unwrap (DRef)->is_cpu ();
115
+ auto D = unwrap (DRef);
116
+ if (D) {
117
+ return D->is_cpu ();
118
+ }
119
+ return false ;
112
120
}
113
121
114
122
bool DPPLDevice_IsGPU (__dppl_keep const DPPLSyclDeviceRef DRef)
115
123
{
116
- return unwrap (DRef)->is_gpu ();
124
+ auto D = unwrap (DRef);
125
+ if (D) {
126
+ return D->is_gpu ();
127
+ }
128
+ return false ;
117
129
}
118
130
119
131
120
132
bool DPPLDevice_IsHost (__dppl_keep const DPPLSyclDeviceRef DRef)
121
133
{
122
- return unwrap (DRef)->is_host ();
134
+ auto D = unwrap (DRef);
135
+ if (D) {
136
+ return D->is_host ();
137
+ }
138
+ return false ;
139
+ }
140
+
141
+
142
+ uint32_t
143
+ DPPLDevice_GetMaxComputeUnits (__dppl_keep const DPPLSyclDeviceRef DRef)
144
+ {
145
+ auto D = unwrap (DRef);
146
+ if (D) {
147
+ return D->get_info <info::device::max_compute_units>();
148
+ }
149
+ return 0 ;
150
+ }
151
+
152
+ uint32_t
153
+ DPPLDevice_GetMaxWorkItemDims (__dppl_keep const DPPLSyclDeviceRef DRef)
154
+ {
155
+ auto D = unwrap (DRef);
156
+ if (D) {
157
+ return D->get_info <info::device::max_work_item_dimensions>();
158
+ }
159
+ return 0 ;
160
+ }
161
+
162
+ __dppl_keep size_t *
163
+ DPPLDevice_GetMaxWorkItemSizes (__dppl_keep const DPPLSyclDeviceRef DRef)
164
+ {
165
+ size_t *sizes = nullptr ;
166
+ auto D = unwrap (DRef);
167
+ if (D) {
168
+ auto id_sizes = D->get_info <info::device::max_work_item_sizes>();
169
+ sizes = new size_t [3 ];
170
+ for (auto i = 0ul ; i < 3 ; ++i) {
171
+ sizes[i] = id_sizes[i];
172
+ }
173
+ }
174
+ return sizes;
175
+ }
176
+
177
+ size_t
178
+ DPPLDevice_GetMaxWorkGroupSize (__dppl_keep const DPPLSyclDeviceRef DRef)
179
+ {
180
+ auto D = unwrap (DRef);
181
+ if (D) {
182
+ return D->get_info <info::device::max_work_group_size>();
183
+ }
184
+ return 0 ;
185
+ }
186
+
187
+ uint32_t
188
+ DPPLDevice_GetMaxNumSubGroups (__dppl_keep const DPPLSyclDeviceRef DRef)
189
+ {
190
+ auto D = unwrap (DRef);
191
+ if (D) {
192
+ return D->get_info <info::device::max_num_sub_groups>();
193
+ }
194
+ return 0 ;
195
+ }
196
+
197
+ bool
198
+ DPPLDevice_HasInt64BaseAtomics (__dppl_keep const DPPLSyclDeviceRef DRef)
199
+ {
200
+ auto D = unwrap (DRef);
201
+ if (D) {
202
+ return D->has (aspect::int64_base_atomics);
203
+ }
204
+ return false ;
205
+ }
206
+
207
+ bool
208
+ DPPLDevice_HasInt64ExtendedAtomics (__dppl_keep const DPPLSyclDeviceRef DRef)
209
+ {
210
+ auto D = unwrap (DRef);
211
+ if (D) {
212
+ return D->has (aspect::int64_extended_atomics);
213
+ }
214
+ return false ;
123
215
}
124
216
125
217
__dppl_give const char *
126
218
DPPLDevice_GetName (__dppl_keep const DPPLSyclDeviceRef DRef)
127
219
{
128
- auto name = unwrap (DRef)->get_info <info::device::name>();
129
- auto cstr_name = new char [name.length ()+1 ];
130
- std::strcpy (cstr_name, name.c_str ());
131
- return cstr_name;
220
+ auto D = unwrap (DRef);
221
+ if (D) {
222
+ auto name = D->get_info <info::device::name>();
223
+ auto cstr_name = new char [name.length ()+1 ];
224
+ std::strcpy (cstr_name, name.c_str ());
225
+ return cstr_name;
226
+ }
227
+ return nullptr ;
132
228
}
133
229
134
230
__dppl_give const char *
135
231
DPPLDevice_GetVendorName (__dppl_keep const DPPLSyclDeviceRef DRef)
136
232
{
137
- auto vendor = unwrap (DRef)->get_info <info::device::name>();
138
- auto cstr_vendor = new char [vendor.length ()+1 ];
139
- std::strcpy (cstr_vendor, vendor.c_str ());
140
- return cstr_vendor;
233
+ auto D = unwrap (DRef);
234
+ if (D) {
235
+ auto vendor = D->get_info <info::device::vendor>();
236
+ auto cstr_vendor = new char [vendor.length ()+1 ];
237
+ std::strcpy (cstr_vendor, vendor.c_str ());
238
+ return cstr_vendor;
239
+ }
240
+ return nullptr ;
141
241
}
142
242
143
243
__dppl_give const char *
144
244
DPPLDevice_GetDriverInfo (__dppl_keep const DPPLSyclDeviceRef DRef)
145
245
{
146
- auto driver = unwrap (DRef)->get_info <info::device::driver_version>();
147
- auto cstr_driver = new char [driver.length ()+1 ];
148
- std::strcpy (cstr_driver, driver.c_str ());
149
- return cstr_driver;
246
+ auto D = unwrap (DRef);
247
+ if (D) {
248
+ auto driver = D->get_info <info::device::driver_version>();
249
+ auto cstr_driver = new char [driver.length ()+1 ];
250
+ std::strcpy (cstr_driver, driver.c_str ());
251
+ return cstr_driver;
252
+ }
253
+ return nullptr ;
150
254
}
151
255
152
256
bool DPPLDevice_IsHostUnifiedMemory (__dppl_keep const DPPLSyclDeviceRef DRef)
153
257
{
154
- return unwrap (DRef)->get_info <info::device::host_unified_memory>();
258
+ auto D = unwrap (DRef);
259
+ if (D) {
260
+ return D->get_info <info::device::host_unified_memory>();
261
+ }
262
+ return false ;
155
263
}
0 commit comments