@@ -160,3 +160,225 @@ DPCTLSyclDeviceType DPCTL_SyclDeviceTypeToDPCTLDeviceType(info::device_type D)
160
160
return DPCTLSyclDeviceType::DPCTL_UNKNOWN_DEVICE;
161
161
}
162
162
}
163
+
164
+ /* !
165
+ * Transforms cl::sycl::aspect to string.
166
+ */
167
+ std::string DPCTL_AspectToStr (aspect aspectTy)
168
+ {
169
+ std::stringstream ss;
170
+ switch (aspectTy) {
171
+ case aspect::host:
172
+ ss << " host" << ' \n ' ;
173
+ break ;
174
+ case aspect::cpu:
175
+ ss << " cpu" << ' \n ' ;
176
+ break ;
177
+ case aspect::gpu:
178
+ ss << " gpu" << ' \n ' ;
179
+ break ;
180
+ case aspect::accelerator:
181
+ ss << " accelerator" << ' \n ' ;
182
+ break ;
183
+ case aspect::custom:
184
+ ss << " custom" << ' \n ' ;
185
+ break ;
186
+ case aspect::fp16:
187
+ ss << " fp16" << ' \n ' ;
188
+ break ;
189
+ case aspect::fp64:
190
+ ss << " fp64" << ' \n ' ;
191
+ break ;
192
+ case aspect::int64_base_atomics:
193
+ ss << " int64_base_atomics" << ' \n ' ;
194
+ break ;
195
+ case aspect::int64_extended_atomics:
196
+ ss << " int64_extended_atomics" << ' \n ' ;
197
+ break ;
198
+ case aspect::image:
199
+ ss << " image" << ' \n ' ;
200
+ break ;
201
+ case aspect::online_compiler:
202
+ ss << " online_compiler" << ' \n ' ;
203
+ break ;
204
+ case aspect::online_linker:
205
+ ss << " online_linker" << ' \n ' ;
206
+ break ;
207
+ case aspect::queue_profiling:
208
+ ss << " queue_profiling" << ' \n ' ;
209
+ break ;
210
+ case aspect::usm_device_allocations:
211
+ ss << " usm_device_allocations" << ' \n ' ;
212
+ break ;
213
+ case aspect::usm_host_allocations:
214
+ ss << " usm_host_allocations" << ' \n ' ;
215
+ break ;
216
+ case aspect::usm_shared_allocations:
217
+ ss << " usm_shared_allocations" << ' \n ' ;
218
+ break ;
219
+ case aspect::usm_restricted_shared_allocations:
220
+ ss << " usm_restricted_shared_allocations" << ' \n ' ;
221
+ break ;
222
+ case aspect::usm_system_allocator:
223
+ ss << " usm_system_allocator" << ' \n ' ;
224
+ break ;
225
+ default :
226
+ throw runtime_error (" Unsupported aspect type" , -1 );
227
+ }
228
+ return ss.str ();
229
+ }
230
+
231
+ /* !
232
+ * Transforms string to cl::sycl::aspect.
233
+ */
234
+ aspect DPCTL_StrToAspectType (const std::string &aspectTyStr)
235
+ {
236
+ aspect aspectTy;
237
+ if (aspectTyStr == " host" ) {
238
+ aspectTy = aspect::host;
239
+ }
240
+ else if (aspectTyStr == " cpu" ) {
241
+ aspectTy = aspect::cpu;
242
+ }
243
+ else if (aspectTyStr == " gpu" ) {
244
+ aspectTy = aspect::gpu;
245
+ }
246
+ else if (aspectTyStr == " accelerator" ) {
247
+ aspectTy = aspect::accelerator;
248
+ }
249
+ else if (aspectTyStr == " custom" ) {
250
+ aspectTy = aspect::custom;
251
+ }
252
+ else if (aspectTyStr == " fp16" ) {
253
+ aspectTy = aspect::fp16;
254
+ }
255
+ else if (aspectTyStr == " fp64" ) {
256
+ aspectTy = aspect::fp64;
257
+ }
258
+ else if (aspectTyStr == " int64_base_atomics" ) {
259
+ aspectTy = aspect::int64_base_atomics;
260
+ }
261
+ else if (aspectTyStr == " int64_extended_atomics" ) {
262
+ aspectTy = aspect::int64_extended_atomics;
263
+ }
264
+ else if (aspectTyStr == " image" ) {
265
+ aspectTy = aspect::image;
266
+ }
267
+ else if (aspectTyStr == " online_compiler" ) {
268
+ aspectTy = aspect::online_compiler;
269
+ }
270
+ else if (aspectTyStr == " online_linker" ) {
271
+ aspectTy = aspect::online_linker;
272
+ }
273
+ else if (aspectTyStr == " queue_profiling" ) {
274
+ aspectTy = aspect::queue_profiling;
275
+ }
276
+ else if (aspectTyStr == " usm_device_allocations" ) {
277
+ aspectTy = aspect::usm_device_allocations;
278
+ }
279
+ else if (aspectTyStr == " usm_host_allocations" ) {
280
+ aspectTy = aspect::usm_host_allocations;
281
+ }
282
+ else if (aspectTyStr == " usm_shared_allocations" ) {
283
+ aspectTy = aspect::usm_shared_allocations;
284
+ }
285
+ else if (aspectTyStr == " usm_restricted_shared_allocations" ) {
286
+ aspectTy = aspect::usm_restricted_shared_allocations;
287
+ }
288
+ else if (aspectTyStr == " usm_system_allocator" ) {
289
+ aspectTy = aspect::usm_system_allocator;
290
+ }
291
+ else {
292
+ // \todo handle the error
293
+ throw runtime_error (" Unsupported aspect type" , -1 );
294
+ }
295
+ return aspectTy;
296
+ }
297
+
298
+ aspect DPCTL_DPCTLAspectTypeToSyclAspect (DPCTLSyclAspectType AspectTy)
299
+ {
300
+ switch (AspectTy) {
301
+ case DPCTLSyclAspectType::host:
302
+ return aspect::host;
303
+ case DPCTLSyclAspectType::cpu:
304
+ return aspect::cpu;
305
+ case DPCTLSyclAspectType::gpu:
306
+ return aspect::gpu;
307
+ case DPCTLSyclAspectType::accelerator:
308
+ return aspect::accelerator;
309
+ case DPCTLSyclAspectType::custom:
310
+ return aspect::custom;
311
+ case DPCTLSyclAspectType::fp16:
312
+ return aspect::fp16;
313
+ case DPCTLSyclAspectType::fp64:
314
+ return aspect::fp64;
315
+ case DPCTLSyclAspectType::int64_base_atomics:
316
+ return aspect::int64_base_atomics;
317
+ case DPCTLSyclAspectType::int64_extended_atomics:
318
+ return aspect::int64_extended_atomics;
319
+ case DPCTLSyclAspectType::image:
320
+ return aspect::image;
321
+ case DPCTLSyclAspectType::online_compiler:
322
+ return aspect::online_compiler;
323
+ case DPCTLSyclAspectType::online_linker:
324
+ return aspect::online_linker;
325
+ case DPCTLSyclAspectType::queue_profiling:
326
+ return aspect::queue_profiling;
327
+ case DPCTLSyclAspectType::usm_device_allocations:
328
+ return aspect::usm_device_allocations;
329
+ case DPCTLSyclAspectType::usm_host_allocations:
330
+ return aspect::usm_host_allocations;
331
+ case DPCTLSyclAspectType::usm_shared_allocations:
332
+ return aspect::usm_shared_allocations;
333
+ case DPCTLSyclAspectType::usm_restricted_shared_allocations:
334
+ return aspect::usm_restricted_shared_allocations;
335
+ case DPCTLSyclAspectType::usm_system_allocator:
336
+ return aspect::usm_system_allocator;
337
+ default :
338
+ throw runtime_error (" Unsupported aspect type" , -1 );
339
+ }
340
+ }
341
+
342
+ DPCTLSyclAspectType DPCTL_SyclAspectToDPCTLAspectType (aspect Aspect)
343
+ {
344
+ switch (Aspect) {
345
+ case aspect::host:
346
+ return DPCTLSyclAspectType::host;
347
+ case aspect::cpu:
348
+ return DPCTLSyclAspectType::cpu;
349
+ case aspect::gpu:
350
+ return DPCTLSyclAspectType::gpu;
351
+ case aspect::accelerator:
352
+ return DPCTLSyclAspectType::accelerator;
353
+ case aspect::custom:
354
+ return DPCTLSyclAspectType::custom;
355
+ case aspect::fp16:
356
+ return DPCTLSyclAspectType::fp16;
357
+ case aspect::fp64:
358
+ return DPCTLSyclAspectType::fp64;
359
+ case aspect::int64_base_atomics:
360
+ return DPCTLSyclAspectType::int64_base_atomics;
361
+ case aspect::int64_extended_atomics:
362
+ return DPCTLSyclAspectType::int64_extended_atomics;
363
+ case aspect::image:
364
+ return DPCTLSyclAspectType::image;
365
+ case aspect::online_compiler:
366
+ return DPCTLSyclAspectType::online_compiler;
367
+ case aspect::online_linker:
368
+ return DPCTLSyclAspectType::online_linker;
369
+ case aspect::queue_profiling:
370
+ return DPCTLSyclAspectType::queue_profiling;
371
+ case aspect::usm_device_allocations:
372
+ return DPCTLSyclAspectType::usm_device_allocations;
373
+ case aspect::usm_host_allocations:
374
+ return DPCTLSyclAspectType::usm_host_allocations;
375
+ case aspect::usm_shared_allocations:
376
+ return DPCTLSyclAspectType::usm_shared_allocations;
377
+ case aspect::usm_restricted_shared_allocations:
378
+ return DPCTLSyclAspectType::usm_restricted_shared_allocations;
379
+ case aspect::usm_system_allocator:
380
+ return DPCTLSyclAspectType::usm_system_allocator;
381
+ default :
382
+ throw runtime_error (" Unsupported aspect type" , -1 );
383
+ }
384
+ }
0 commit comments