• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

IntelPython / dpctl / 31047320341

05 Aug 2026 09:08PM UTC coverage: 74.054% (-0.5%) from 74.579%
31047320341

Pull #2324

github

web-flow
Merge b7661fef8 into f410c8606
Pull Request #2324: Add missing device info queries

964 of 1366 branches covered (70.57%)

Branch coverage included in aggregate %.

288 of 347 new or added lines in 4 files covered. (83.0%)

16 existing lines in 1 file now uncovered.

3654 of 4870 relevant lines covered (75.03%)

286.86 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

72.38
/libsyclinterface/helper/source/dpctl_utils_helper.cpp
1
//===- dpctl_utils_helper.cpp - Implementation of enum to string helpers   ===//
2
//
3
//                      Data Parallel Control (dpctl)
4
//
5
// Copyright 2020 Intel Corporation
6
//
7
// Licensed under the Apache License, Version 2.0 (the "License");
8
// you may not use this file except in compliance with the License.
9
// You may obtain a copy of the License at
10
//
11
//    http://www.apache.org/licenses/LICENSE-2.0
12
//
13
// Unless required by applicable law or agreed to in writing, software
14
// distributed under the License is distributed on an "AS IS" BASIS,
15
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
// See the License for the specific language governing permissions and
17
// limitations under the License.
18
//
19
//===----------------------------------------------------------------------===//
20
///
21
/// \file
22
/// This file implements the helper functions defined in dpctl_utils_helper.h.
23
///
24
//===----------------------------------------------------------------------===//
25

26
#include "dpctl_utils_helper.h"
27
#include "Config/dpctl_config.h"
28
#include <sstream>
29
#include <stdexcept>
30
#include <string>
31

32
using namespace sycl;
33

34
/*!
35
 * Transforms enum info::device_type to string.
36
 */
37
std::string DPCTL_DeviceTypeToStr(info::device_type devTy)
38
{
31✔
39
    std::stringstream ss;
31✔
40
    switch (devTy) {
31✔
41
    case info::device_type::cpu:
27✔
42
        ss << "cpu";
27✔
43
        break;
27✔
44
    case info::device_type::gpu:
1✔
45
        ss << "gpu";
1✔
46
        break;
1✔
47
    case info::device_type::accelerator:
1✔
48
        ss << "accelerator";
1✔
49
        break;
1✔
50
    case info::device_type::custom:
1✔
51
        ss << "custom";
1✔
52
        break;
1✔
53
    default:
1✔
54
        ss << "unknown";
1✔
55
    }
31✔
56
    return ss.str();
31✔
57
}
31✔
58

59
/*!
60
 * Transforms string to enum info::device_type.
61
 */
62
info::device_type DPCTL_StrToDeviceType(const std::string &devTyStr)
63
{
5✔
64
    info::device_type devTy;
5✔
65
    if (devTyStr == "cpu") {
5✔
66
        devTy = info::device_type::cpu;
1✔
67
    }
1✔
68
    else if (devTyStr == "gpu") {
4✔
69
        devTy = info::device_type::gpu;
1✔
70
    }
1✔
71
    else if (devTyStr == "accelerator") {
3✔
72
        devTy = info::device_type::accelerator;
1✔
73
    }
1✔
74
    else if (devTyStr == "custom") {
2✔
75
        devTy = info::device_type::custom;
1✔
76
    }
1✔
77
    else {
1✔
78
        // \todo handle the error
79
        throw std::runtime_error("Unknown device type.");
1✔
80
    }
1✔
81
    return devTy;
4✔
82
}
5✔
83

84
backend DPCTL_DPCTLBackendTypeToSyclBackend(DPCTLSyclBackendType BeTy)
85
{
10✔
86
    switch (BeTy) {
10✔
87
    case DPCTLSyclBackendType::DPCTL_CUDA:
2✔
88
        return backend::ext_oneapi_cuda;
2✔
89
    case DPCTLSyclBackendType::DPCTL_LEVEL_ZERO:
2✔
90
        return backend::ext_oneapi_level_zero;
2✔
91
    case DPCTLSyclBackendType::DPCTL_OPENCL:
2✔
92
        return backend::opencl;
2✔
93
    case DPCTLSyclBackendType::DPCTL_ALL_BACKENDS:
1✔
94
        return backend::all;
1✔
95
    case DPCTLSyclBackendType::DPCTL_HIP:
2✔
96
        return backend::ext_oneapi_hip;
2✔
97
    default:
1✔
98
        throw std::runtime_error("Unsupported backend type");
1✔
99
    }
10✔
100
}
10✔
101

102
DPCTLSyclBackendType DPCTL_SyclBackendToDPCTLBackendType(backend B)
103
{
152✔
104
    switch (B) {
152✔
105
    case backend::ext_oneapi_cuda:
1✔
106
        return DPCTLSyclBackendType::DPCTL_CUDA;
1✔
107
    case backend::ext_oneapi_level_zero:
1✔
108
        return DPCTLSyclBackendType::DPCTL_LEVEL_ZERO;
1✔
109
    case backend::opencl:
148✔
110
        return DPCTLSyclBackendType::DPCTL_OPENCL;
148✔
111
    case backend::ext_oneapi_hip:
1✔
112
        return DPCTLSyclBackendType::DPCTL_HIP;
1✔
113
    default:
1✔
114
        return DPCTLSyclBackendType::DPCTL_UNKNOWN_BACKEND;
1✔
115
    }
152✔
116
}
152✔
117

118
info::device_type DPCTL_DPCTLDeviceTypeToSyclDeviceType(DPCTLSyclDeviceType DTy)
119
{
25✔
120
    switch (DTy) {
25✔
121
    case DPCTLSyclDeviceType::DPCTL_ACCELERATOR:
4✔
122
        return info::device_type::accelerator;
4✔
123
    case DPCTLSyclDeviceType::DPCTL_ALL:
10✔
124
        return info::device_type::all;
10✔
125
    case DPCTLSyclDeviceType::DPCTL_AUTOMATIC:
1✔
126
        return info::device_type::automatic;
1✔
127
    case DPCTLSyclDeviceType::DPCTL_CPU:
5✔
128
        return info::device_type::cpu;
5✔
129
    case DPCTLSyclDeviceType::DPCTL_CUSTOM:
1✔
130
        return info::device_type::custom;
1✔
131
    case DPCTLSyclDeviceType::DPCTL_GPU:
4✔
132
        return info::device_type::gpu;
4✔
133
    default:
×
134
        throw std::runtime_error("Unsupported device type");
×
135
    }
25✔
136
}
25✔
137

138
DPCTLSyclDeviceType DPCTL_SyclDeviceTypeToDPCTLDeviceType(info::device_type D)
139
{
136✔
140
    switch (D) {
136✔
141
    case info::device_type::accelerator:
1✔
142
        return DPCTLSyclDeviceType::DPCTL_ACCELERATOR;
1✔
143
    case info::device_type::all:
1✔
144
        return DPCTLSyclDeviceType::DPCTL_ALL;
1✔
145
    case info::device_type::automatic:
1✔
146
        return DPCTLSyclDeviceType::DPCTL_AUTOMATIC;
1✔
147
    case info::device_type::cpu:
131✔
148
        return DPCTLSyclDeviceType::DPCTL_CPU;
131✔
149
    case info::device_type::custom:
1✔
150
        return DPCTLSyclDeviceType::DPCTL_CUSTOM;
1✔
151
    case info::device_type::gpu:
1✔
152
        return DPCTLSyclDeviceType::DPCTL_GPU;
1✔
153
    default:
×
154
        return DPCTLSyclDeviceType::DPCTL_UNKNOWN_DEVICE;
×
155
    }
136✔
156
}
136✔
157

158
/*!
159
 * Transforms sycl::aspect to string.
160
 */
161
std::string DPCTL_AspectToStr(aspect aspectTy)
162
{
×
163
    std::stringstream ss;
×
164
    switch (aspectTy) {
×
165
    case aspect::cpu:
×
166
        ss << "cpu";
×
167
        break;
×
168
    case aspect::gpu:
×
169
        ss << "gpu";
×
170
        break;
×
171
    case aspect::accelerator:
×
172
        ss << "accelerator";
×
173
        break;
×
174
    case aspect::custom:
×
175
        ss << "custom";
×
176
        break;
×
177
    case aspect::fp16:
×
178
        ss << "fp16";
×
179
        break;
×
180
    case aspect::fp64:
×
181
        ss << "fp64";
×
182
        break;
×
183
    case aspect::atomic64:
×
184
        ss << "atomic64";
×
185
        break;
×
186
    case aspect::image:
×
187
        ss << "image";
×
188
        break;
×
189
    case aspect::online_compiler:
×
190
        ss << "online_compiler";
×
191
        break;
×
192
    case aspect::online_linker:
×
193
        ss << "online_linker";
×
194
        break;
×
195
    case aspect::queue_profiling:
×
196
        ss << "queue_profiling";
×
197
        break;
×
198
    case aspect::usm_device_allocations:
×
199
        ss << "usm_device_allocations";
×
200
        break;
×
201
    case aspect::usm_host_allocations:
×
202
        ss << "usm_host_allocations";
×
203
        break;
×
204
    case aspect::usm_shared_allocations:
×
205
        ss << "usm_shared_allocations";
×
206
        break;
×
207
    case aspect::usm_system_allocations:
×
208
        ss << "usm_system_allocations";
×
209
        break;
×
210
    case aspect::usm_atomic_host_allocations:
×
211
        ss << "usm_atomic_host_allocations";
×
212
        break;
×
213
    case aspect::usm_atomic_shared_allocations:
×
214
        ss << "usm_atomic_shared_allocations";
×
215
        break;
×
216
    case aspect::host_debuggable:
×
217
        ss << "host_debuggable";
×
218
        break;
×
219
    case aspect::emulated:
×
220
        ss << "emulated";
×
221
        break;
×
222
    case aspect::ext_oneapi_is_component:
×
223
        ss << "is_component";
×
224
        break;
×
225
    case aspect::ext_oneapi_is_composite:
×
226
        ss << "is_composite";
×
227
        break;
×
UNCOV
228
#ifdef SYCL_EXT_ONEAPI_INTER_PROCESS_COMMUNICATION
×
UNCOV
229
    case aspect::ext_oneapi_ipc_memory:
×
UNCOV
230
        ss << "ext_oneapi_ipc_memory";
×
UNCOV
231
        break;
×
UNCOV
232
#endif
×
233
    default:
×
234
        throw std::runtime_error("Unsupported aspect type");
×
235
    }
×
236
    return ss.str();
×
237
}
×
238

239
/*!
240
 * Transforms string to sycl::aspect.
241
 */
242
aspect DPCTL_StrToAspectType(const std::string &aspectTyStr)
243
{
133✔
244
    aspect aspectTy;
133✔
245
    if (aspectTyStr == "cpu") {
133✔
246
        aspectTy = aspect::cpu;
1✔
247
    }
1✔
248
    else if (aspectTyStr == "gpu") {
132✔
249
        aspectTy = aspect::gpu;
1✔
250
    }
1✔
251
    else if (aspectTyStr == "accelerator") {
131✔
252
        aspectTy = aspect::accelerator;
1✔
253
    }
1✔
254
    else if (aspectTyStr == "custom") {
130✔
255
        aspectTy = aspect::custom;
1✔
256
    }
1✔
257
    else if (aspectTyStr == "fp16") {
129✔
258
        aspectTy = aspect::fp16;
25✔
259
    }
25✔
260
    else if (aspectTyStr == "fp64") {
104✔
261
        aspectTy = aspect::fp64;
26✔
262
    }
26✔
263
    else if (aspectTyStr == "atomic64") {
78✔
264
        aspectTy = aspect::atomic64;
1✔
265
    }
1✔
266
    else if (aspectTyStr == "image") {
77✔
267
        aspectTy = aspect::image;
64✔
268
    }
64✔
269
    else if (aspectTyStr == "online_compiler") {
13✔
270
        aspectTy = aspect::online_compiler;
1✔
271
    }
1✔
272
    else if (aspectTyStr == "online_linker") {
12✔
273
        aspectTy = aspect::online_linker;
1✔
274
    }
1✔
275
    else if (aspectTyStr == "queue_profiling") {
11✔
276
        aspectTy = aspect::queue_profiling;
1✔
277
    }
1✔
278
    else if (aspectTyStr == "usm_device_allocations") {
10✔
279
        aspectTy = aspect::usm_device_allocations;
1✔
280
    }
1✔
281
    else if (aspectTyStr == "usm_host_allocations") {
9✔
282
        aspectTy = aspect::usm_host_allocations;
1✔
283
    }
1✔
284
    else if (aspectTyStr == "usm_shared_allocations") {
8✔
285
        aspectTy = aspect::usm_shared_allocations;
1✔
286
    }
1✔
287
    else if (aspectTyStr == "usm_system_allocations") {
7✔
288
        aspectTy = aspect::usm_system_allocations;
1✔
289
    }
1✔
290
    else if (aspectTyStr == "usm_atomic_host_allocations") {
6✔
291
        aspectTy = aspect::usm_atomic_host_allocations;
1✔
292
    }
1✔
293
    else if (aspectTyStr == "usm_atomic_shared_allocations") {
5✔
294
        aspectTy = aspect::usm_atomic_shared_allocations;
1✔
295
    }
1✔
296
    else if (aspectTyStr == "host_debuggable") {
4✔
297
        aspectTy = aspect::host_debuggable;
1✔
298
    }
1✔
299
    else if (aspectTyStr == "emulated") {
3✔
300
        aspectTy = aspect::emulated;
1✔
301
    }
1✔
302
    else if (aspectTyStr == "is_component") {
2✔
303
        aspectTy = aspect::ext_oneapi_is_component;
1✔
304
    }
1✔
305
    else if (aspectTyStr == "is_composite") {
1!
306
        aspectTy = aspect::ext_oneapi_is_composite;
1✔
307
    }
1✔
UNCOV
308
#ifdef SYCL_EXT_ONEAPI_INTER_PROCESS_COMMUNICATION
×
UNCOV
309
    else if (aspectTyStr == "ext_oneapi_ipc_memory") {
×
UNCOV
310
        aspectTy = aspect::ext_oneapi_ipc_memory;
×
UNCOV
311
    }
×
UNCOV
312
#endif
×
313
    else {
×
314
        // \todo handle the error
315
        throw std::runtime_error("Unsupported aspect type");
×
316
    }
×
317
    return aspectTy;
133✔
318
}
133✔
319

320
aspect DPCTL_DPCTLAspectTypeToSyclAspect(DPCTLSyclAspectType AspectTy)
321
{
508✔
322
    switch (AspectTy) {
508✔
323
    case DPCTLSyclAspectType::cpu:
21✔
324
        return aspect::cpu;
21✔
325
    case DPCTLSyclAspectType::gpu:
20✔
326
        return aspect::gpu;
20✔
327
    case DPCTLSyclAspectType::accelerator:
18✔
328
        return aspect::accelerator;
18✔
329
    case DPCTLSyclAspectType::custom:
18✔
330
        return aspect::custom;
18✔
331
    case DPCTLSyclAspectType::fp16:
43✔
332
        return aspect::fp16;
43✔
333
    case DPCTLSyclAspectType::fp64:
48✔
334
        return aspect::fp64;
48✔
335
    case DPCTLSyclAspectType::atomic64:
19✔
336
        return aspect::atomic64;
19✔
337
    case DPCTLSyclAspectType::image:
81✔
338
        return aspect::image;
81✔
339
    case DPCTLSyclAspectType::online_compiler:
19✔
340
        return aspect::online_compiler;
19✔
341
    case DPCTLSyclAspectType::online_linker:
19✔
342
        return aspect::online_linker;
19✔
343
    case DPCTLSyclAspectType::queue_profiling:
19✔
344
        return aspect::queue_profiling;
19✔
345
    case DPCTLSyclAspectType::usm_device_allocations:
19✔
346
        return aspect::usm_device_allocations;
19✔
347
    case DPCTLSyclAspectType::usm_host_allocations:
19✔
348
        return aspect::usm_host_allocations;
19✔
349
    case DPCTLSyclAspectType::usm_shared_allocations:
19✔
350
        return aspect::usm_shared_allocations;
19✔
351
    case DPCTLSyclAspectType::usm_system_allocations:
19✔
352
        return aspect::usm_system_allocations;
19✔
353
    case DPCTLSyclAspectType::usm_atomic_host_allocations:
19✔
354
        return aspect::usm_atomic_host_allocations;
19✔
355
    case DPCTLSyclAspectType::usm_atomic_shared_allocations:
19✔
356
        return aspect::usm_atomic_shared_allocations;
19✔
357
    case DPCTLSyclAspectType::host_debuggable:
18✔
358
        return aspect::host_debuggable;
18✔
359
    case DPCTLSyclAspectType::emulated:
18✔
360
        return aspect::emulated;
18✔
361
    case DPCTLSyclAspectType::is_component:
12✔
362
        return aspect::ext_oneapi_is_component;
12✔
363
    case DPCTLSyclAspectType::is_composite:
3✔
364
        return aspect::ext_oneapi_is_composite;
3✔
UNCOV
365
#ifdef SYCL_EXT_ONEAPI_INTER_PROCESS_COMMUNICATION
×
366
    case DPCTLSyclAspectType::ext_oneapi_ipc_memory:
18✔
367
        return aspect::ext_oneapi_ipc_memory;
18✔
UNCOV
368
#endif
×
369
    default:
×
370
        throw std::runtime_error("Unsupported aspect type");
×
371
    }
508✔
372
}
508✔
373

374
DPCTLSyclAspectType DPCTL_SyclAspectToDPCTLAspectType(aspect Aspect)
375
{
133✔
376
    switch (Aspect) {
133✔
377
    case aspect::cpu:
1✔
378
        return DPCTLSyclAspectType::cpu;
1✔
379
    case aspect::gpu:
1✔
380
        return DPCTLSyclAspectType::gpu;
1✔
381
    case aspect::accelerator:
1✔
382
        return DPCTLSyclAspectType::accelerator;
1✔
383
    case aspect::custom:
1✔
384
        return DPCTLSyclAspectType::custom;
1✔
385
    case aspect::fp16:
25✔
386
        return DPCTLSyclAspectType::fp16;
25✔
387
    case aspect::fp64:
26✔
388
        return DPCTLSyclAspectType::fp64;
26✔
389
    case aspect::atomic64:
1✔
390
        return DPCTLSyclAspectType::atomic64;
1✔
391
    case aspect::image:
64✔
392
        return DPCTLSyclAspectType::image;
64✔
393
    case aspect::online_compiler:
1✔
394
        return DPCTLSyclAspectType::online_compiler;
1✔
395
    case aspect::online_linker:
1✔
396
        return DPCTLSyclAspectType::online_linker;
1✔
397
    case aspect::queue_profiling:
1✔
398
        return DPCTLSyclAspectType::queue_profiling;
1✔
399
    case aspect::usm_device_allocations:
1✔
400
        return DPCTLSyclAspectType::usm_device_allocations;
1✔
401
    case aspect::usm_host_allocations:
1✔
402
        return DPCTLSyclAspectType::usm_host_allocations;
1✔
403
    case aspect::usm_shared_allocations:
1✔
404
        return DPCTLSyclAspectType::usm_shared_allocations;
1✔
405
    case aspect::usm_system_allocations:
1✔
406
        return DPCTLSyclAspectType::usm_system_allocations;
1✔
407
    case aspect::usm_atomic_host_allocations:
1✔
408
        return DPCTLSyclAspectType::usm_atomic_host_allocations;
1✔
409
    case aspect::usm_atomic_shared_allocations:
1✔
410
        return DPCTLSyclAspectType::usm_atomic_shared_allocations;
1✔
411
    case aspect::host_debuggable:
1✔
412
        return DPCTLSyclAspectType::host_debuggable;
1✔
413
    case aspect::emulated:
1✔
414
        return DPCTLSyclAspectType::emulated;
1✔
415
    case aspect::ext_oneapi_is_composite:
1✔
416
        return DPCTLSyclAspectType::is_composite;
1✔
417
    case aspect::ext_oneapi_is_component:
1✔
418
        return DPCTLSyclAspectType::is_component;
1✔
UNCOV
419
#ifdef SYCL_EXT_ONEAPI_INTER_PROCESS_COMMUNICATION
×
UNCOV
420
    case aspect::ext_oneapi_ipc_memory:
×
UNCOV
421
        return DPCTLSyclAspectType::ext_oneapi_ipc_memory;
×
UNCOV
422
#endif
×
423
    default:
×
424
        throw std::runtime_error("Unsupported aspect type");
×
425
    }
133✔
426
}
133✔
427

428
info::partition_affinity_domain DPCTL_DPCTLPartitionAffinityDomainTypeToSycl(
429
    DPCTLPartitionAffinityDomainType PartitionAffinityDomainTy)
430
{
×
431
    switch (PartitionAffinityDomainTy) {
×
432
    case DPCTLPartitionAffinityDomainType::not_applicable:
×
433
        return info::partition_affinity_domain::not_applicable;
×
434
    case DPCTLPartitionAffinityDomainType::numa:
×
435
        return info::partition_affinity_domain::numa;
×
436
    case DPCTLPartitionAffinityDomainType::L4_cache:
×
437
        return info::partition_affinity_domain::L4_cache;
×
438
    case DPCTLPartitionAffinityDomainType::L3_cache:
×
439
        return info::partition_affinity_domain::L3_cache;
×
440
    case DPCTLPartitionAffinityDomainType::L2_cache:
×
441
        return info::partition_affinity_domain::L2_cache;
×
442
    case DPCTLPartitionAffinityDomainType::L1_cache:
×
443
        return info::partition_affinity_domain::L1_cache;
×
444
    case DPCTLPartitionAffinityDomainType::next_partitionable:
×
445
        return info::partition_affinity_domain::next_partitionable;
×
446
    default:
×
447
        throw std::runtime_error("Unsupported partition_affinity_domain type");
×
448
    }
×
449
}
×
450

451
DPCTLPartitionAffinityDomainType DPCTL_SyclPartitionAffinityDomainToDPCTLType(
452
    sycl::info::partition_affinity_domain PartitionAffinityDomain)
453
{
79✔
454
    switch (PartitionAffinityDomain) {
79✔
455
    case info::partition_affinity_domain::not_applicable:
31✔
456
        return DPCTLPartitionAffinityDomainType::not_applicable;
31✔
457
    case info::partition_affinity_domain::numa:
8✔
458
        return DPCTLPartitionAffinityDomainType::numa;
8✔
459
    case info::partition_affinity_domain::L4_cache:
8✔
460
        return DPCTLPartitionAffinityDomainType::L4_cache;
8✔
461
    case info::partition_affinity_domain::L3_cache:
8✔
462
        return DPCTLPartitionAffinityDomainType::L3_cache;
8✔
463
    case info::partition_affinity_domain::L2_cache:
8✔
464
        return DPCTLPartitionAffinityDomainType::L2_cache;
8✔
465
    case info::partition_affinity_domain::L1_cache:
8✔
466
        return DPCTLPartitionAffinityDomainType::L1_cache;
8✔
467
    case info::partition_affinity_domain::next_partitionable:
8✔
468
        return DPCTLPartitionAffinityDomainType::next_partitionable;
8✔
469
    default:
×
NEW
470
        return DPCTLPartitionAffinityDomainType::
×
NEW
471
            DPCTL_PARTITION_AFFINITY_DOMAIN_UNKNOWN;
×
472
    }
79✔
473
}
79✔
474

475
DPCTLFPConfigType DPCTL_SyclFPConfigToDPCTLType(info::fp_config FPConfig)
476
{
253✔
477
    switch (FPConfig) {
253✔
478
    case info::fp_config::denorm:
46✔
479
        return DPCTLFPConfigType::DPCTL_FP_DENORM;
46✔
480
    case info::fp_config::inf_nan:
69✔
481
        return DPCTLFPConfigType::DPCTL_FP_INF_NAN;
69✔
482
    case info::fp_config::round_to_nearest:
69✔
483
        return DPCTLFPConfigType::DPCTL_FP_ROUND_TO_NEAREST;
69✔
484
    case info::fp_config::round_to_zero:
23✔
485
        return DPCTLFPConfigType::DPCTL_FP_ROUND_TO_ZERO;
23✔
486
    case info::fp_config::round_to_inf:
23✔
487
        return DPCTLFPConfigType::DPCTL_FP_ROUND_TO_INF;
23✔
488
    case info::fp_config::fma:
23✔
489
        return DPCTLFPConfigType::DPCTL_FP_FMA;
23✔
NEW
490
    case info::fp_config::correctly_rounded_divide_sqrt:
×
NEW
491
        return DPCTLFPConfigType::DPCTL_FP_CORRECTLY_ROUNDED_DIVIDE_SQRT;
×
NEW
492
    case info::fp_config::soft_float:
×
NEW
493
        return DPCTLFPConfigType::DPCTL_FP_SOFT_FLOAT;
×
NEW
494
    default:
×
NEW
495
        return DPCTLFPConfigType::DPCTL_FP_UNKNOWN;
×
496
    }
253✔
497
}
253✔
498

499
DPCTLLocalMemType
500
DPCTL_SyclLocalMemTypeToDPCTLType(info::local_mem_type LocalMemType)
501
{
23✔
502
    switch (LocalMemType) {
23✔
NEW
503
    case info::local_mem_type::none:
×
NEW
504
        return DPCTLLocalMemType::DPCTL_LOCAL_MEM_TYPE_NONE;
×
NEW
505
    case info::local_mem_type::local:
×
NEW
506
        return DPCTLLocalMemType::DPCTL_LOCAL_MEM_TYPE_LOCAL;
×
507
    case info::local_mem_type::global:
23!
508
        return DPCTLLocalMemType::DPCTL_LOCAL_MEM_TYPE_GLOBAL;
23✔
NEW
509
    default:
×
NEW
510
        return DPCTLLocalMemType::DPCTL_LOCAL_MEM_TYPE_UNKNOWN;
×
511
    }
23✔
512
}
23✔
513

514
DPCTLMemoryOrderType DPCTL_SyclMemoryOrderToDPCTLType(memory_order MemoryOrder)
515
{
230✔
516
    switch (MemoryOrder) {
230✔
517
    case memory_order::relaxed:
46✔
518
        return DPCTLMemoryOrderType::DPCTL_MEMORY_ORDER_RELAXED;
46✔
519
    case memory_order::acquire:
46✔
520
        return DPCTLMemoryOrderType::DPCTL_MEMORY_ORDER_ACQUIRE;
46✔
521
    case memory_order::release:
46✔
522
        return DPCTLMemoryOrderType::DPCTL_MEMORY_ORDER_RELEASE;
46✔
523
    case memory_order::acq_rel:
46✔
524
        return DPCTLMemoryOrderType::DPCTL_MEMORY_ORDER_ACQ_REL;
46✔
525
    case memory_order::seq_cst:
46✔
526
        return DPCTLMemoryOrderType::DPCTL_MEMORY_ORDER_SEQ_CST;
46✔
NEW
527
    default:
×
NEW
528
        return DPCTLMemoryOrderType::DPCTL_MEMORY_ORDER_UNKNOWN;
×
529
    }
230✔
530
}
230✔
531

532
DPCTLMemoryScopeType DPCTL_SyclMemoryScopeToDPCTLType(memory_scope MemoryScope)
533
{
230✔
534
    switch (MemoryScope) {
230✔
535
    case memory_scope::work_item:
46✔
536
        return DPCTLMemoryScopeType::DPCTL_MEMORY_SCOPE_WORK_ITEM;
46✔
537
    case memory_scope::sub_group:
46✔
538
        return DPCTLMemoryScopeType::DPCTL_MEMORY_SCOPE_SUB_GROUP;
46✔
539
    case memory_scope::work_group:
46✔
540
        return DPCTLMemoryScopeType::DPCTL_MEMORY_SCOPE_WORK_GROUP;
46✔
541
    case memory_scope::device:
46✔
542
        return DPCTLMemoryScopeType::DPCTL_MEMORY_SCOPE_DEVICE;
46✔
543
    case memory_scope::system:
46✔
544
        return DPCTLMemoryScopeType::DPCTL_MEMORY_SCOPE_SYSTEM;
46✔
NEW
545
    default:
×
NEW
546
        return DPCTLMemoryScopeType::DPCTL_MEMORY_SCOPE_UNKNOWN;
×
547
    }
230✔
548
}
230✔
549

550
DPCTLPartitionPropertyType DPCTL_SyclPartitionPropertyToDPCTLType(
551
    info::partition_property PartitionProperty)
552
{
69✔
553
    switch (PartitionProperty) {
69✔
554
    case info::partition_property::no_partition:
23✔
555
        return DPCTLPartitionPropertyType::DPCTL_PARTITION_NO_PARTITION;
23✔
556
    case info::partition_property::partition_equally:
23✔
557
        return DPCTLPartitionPropertyType::DPCTL_PARTITION_EQUALLY;
23✔
558
    case info::partition_property::partition_by_counts:
23✔
559
        return DPCTLPartitionPropertyType::DPCTL_PARTITION_BY_COUNTS;
23✔
NEW
560
    case info::partition_property::partition_by_affinity_domain:
×
NEW
561
        return DPCTLPartitionPropertyType::DPCTL_PARTITION_BY_AFFINITY_DOMAIN;
×
NEW
562
    default:
×
563
        // TODO: investigate ext_intel_partition_by_cslice extension
NEW
564
        return DPCTLPartitionPropertyType::DPCTL_PARTITION_UNKNOWN;
×
565
    }
69✔
566
}
69✔
567

568
ext::oneapi::peer_access
569
DPCTL_DPCTLPeerAccessTypeToSycl(DPCTLPeerAccessType PeerAccessTy)
570
{
2✔
571
    switch (PeerAccessTy) {
2✔
572
    case DPCTLPeerAccessType::access_supported:
1✔
573
        return ext::oneapi::peer_access::access_supported;
1✔
574
    case DPCTLPeerAccessType::atomics_supported:
1✔
575
        return ext::oneapi::peer_access::atomics_supported;
1✔
576
    default:
×
577
        throw std::runtime_error("Unsupported peer_access type");
×
578
    }
2✔
579
}
2✔
580

581
DPCTLPeerAccessType
582
DPCTL_SyclPeerAccessToDPCTLType(ext::oneapi::peer_access PeerAccess)
583
{
2✔
584
    switch (PeerAccess) {
2✔
585
    case ext::oneapi::peer_access::access_supported:
1✔
586
        return DPCTLPeerAccessType::access_supported;
1✔
587
    case ext::oneapi::peer_access::atomics_supported:
1✔
588
        return DPCTLPeerAccessType::atomics_supported;
1✔
589
    default:
×
590
        throw std::runtime_error("Unsupported peer_access type");
×
591
    }
2✔
592
}
2✔
593

594
int64_t DPCTL_GetRelativeDeviceId(const device &Device)
595
{
28✔
596
    auto relid = -1;
28✔
597
    auto p = Device.get_platform();
28✔
598
    auto be = p.get_backend();
28✔
599
    auto dt = Device.get_info<sycl::info::device::device_type>();
28✔
600
    auto dev_vec = device::get_devices(dt);
28✔
601
    int64_t id = 0;
28✔
602
    for (const auto &d_i : dev_vec) {
28!
603
        if (Device == d_i) {
28!
604
            relid = id;
28✔
605
            break;
28✔
606
        }
28✔
607
        if (d_i.get_platform().get_backend() == be)
×
608
            ++id;
×
609
    }
×
610
    return relid;
28✔
611
}
28✔
612

613
std::string DPCTL_GetDeviceFilterString(const device &Device)
614
{
25✔
615
    std::stringstream ss;
25✔
616
    static constexpr const char *filter_string_separator = ":";
25✔
617

618
    auto be = Device.get_platform().get_backend();
25✔
619

620
    switch (be) {
25✔
621
    case backend::ext_oneapi_level_zero:
×
622
        ss << "level_zero";
×
623
        break;
×
624
    case backend::ext_oneapi_cuda:
×
625
        ss << "cuda";
×
626
        break;
×
627
    case backend::opencl:
25!
628
        ss << "opencl";
25✔
629
        break;
25✔
630
    case backend::ext_oneapi_hip:
×
631
        ss << "hip";
×
632
        break;
×
633
    default:
×
634
        ss << "unknown";
×
635
    };
25✔
636

637
    ss << filter_string_separator;
25✔
638
    ss << DPCTL_DeviceTypeToStr(Device.get_info<info::device::device_type>());
25✔
639
    ss << filter_string_separator;
25✔
640
    ss << DPCTL_GetRelativeDeviceId(Device);
25✔
641

642
    return ss.str();
25✔
643
}
25✔
644

645
DPCTLSyclEventStatusType
646
DPCTL_SyclEventStatusToDPCTLEventStatusType(info::event_command_status E)
647
{
6✔
648
    switch (E) {
6✔
649
    case info::event_command_status::submitted:
3✔
650
        return DPCTLSyclEventStatusType::DPCTL_SUBMITTED;
3✔
651
    case info::event_command_status::running:
×
652
        return DPCTLSyclEventStatusType::DPCTL_RUNNING;
×
653
    case info::event_command_status::complete:
3✔
654
        return DPCTLSyclEventStatusType::DPCTL_COMPLETE;
3✔
655
    default:
×
656
        return DPCTLSyclEventStatusType::DPCTL_UNKNOWN_STATUS;
×
657
    }
6✔
658
}
6✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc