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

IntelPython / dpctl / 28596131537

02 Jul 2026 02:03PM UTC coverage: 75.411% (-0.3%) from 75.677%
28596131537

Pull #2331

github

web-flow
Merge 89ec05ee8 into 7e85c9dfb
Pull Request #2331: Add Python bindings for SYCL IPC memory via dpctl

834 of 1158 branches covered (72.02%)

Branch coverage included in aggregate %.

0 of 19 new or added lines in 2 files covered. (0.0%)

1 existing line in 1 file now uncovered.

3245 of 4251 relevant lines covered (76.33%)

272.55 hits per line

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

73.27
/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 <string>
30

31
using namespace sycl;
32

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

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

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

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

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

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

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

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

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

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

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

450
DPCTLPartitionAffinityDomainType DPCTL_SyclPartitionAffinityDomainToDPCTLType(
451
    sycl::info::partition_affinity_domain PartitionAffinityDomain)
452
{
56✔
453
    switch (PartitionAffinityDomain) {
56✔
454
    case info::partition_affinity_domain::not_applicable:
8✔
455
        return DPCTLPartitionAffinityDomainType::not_applicable;
8✔
456
    case info::partition_affinity_domain::numa:
8✔
457
        return DPCTLPartitionAffinityDomainType::numa;
8✔
458
    case info::partition_affinity_domain::L4_cache:
8✔
459
        return DPCTLPartitionAffinityDomainType::L4_cache;
8✔
460
    case info::partition_affinity_domain::L3_cache:
8✔
461
        return DPCTLPartitionAffinityDomainType::L3_cache;
8✔
462
    case info::partition_affinity_domain::L2_cache:
8✔
463
        return DPCTLPartitionAffinityDomainType::L2_cache;
8✔
464
    case info::partition_affinity_domain::L1_cache:
8✔
465
        return DPCTLPartitionAffinityDomainType::L1_cache;
8✔
466
    case info::partition_affinity_domain::next_partitionable:
8✔
467
        return DPCTLPartitionAffinityDomainType::next_partitionable;
8✔
468
    default:
×
469
        throw std::runtime_error("Unsupported partition_affinity_domain type");
×
470
    }
56✔
471
}
56✔
472

473
ext::oneapi::peer_access
474
DPCTL_DPCTLPeerAccessTypeToSycl(DPCTLPeerAccessType PeerAccessTy)
475
{
2✔
476
    switch (PeerAccessTy) {
2✔
477
    case DPCTLPeerAccessType::access_supported:
1✔
478
        return ext::oneapi::peer_access::access_supported;
1✔
479
    case DPCTLPeerAccessType::atomics_supported:
1✔
480
        return ext::oneapi::peer_access::atomics_supported;
1✔
481
    default:
×
482
        throw std::runtime_error("Unsupported peer_access type");
×
483
    }
2✔
484
}
2✔
485

486
DPCTLPeerAccessType
487
DPCTL_SyclPeerAccessToDPCTLType(ext::oneapi::peer_access PeerAccess)
488
{
2✔
489
    switch (PeerAccess) {
2✔
490
    case ext::oneapi::peer_access::access_supported:
1✔
491
        return DPCTLPeerAccessType::access_supported;
1✔
492
    case ext::oneapi::peer_access::atomics_supported:
1✔
493
        return DPCTLPeerAccessType::atomics_supported;
1✔
494
    default:
×
495
        throw std::runtime_error("Unsupported peer_access type");
×
496
    }
2✔
497
}
2✔
498

499
int64_t DPCTL_GetRelativeDeviceId(const device &Device)
500
{
28✔
501
    auto relid = -1;
28✔
502
    auto p = Device.get_platform();
28✔
503
    auto be = p.get_backend();
28✔
504
    auto dt = Device.get_info<sycl::info::device::device_type>();
28✔
505
    auto dev_vec = device::get_devices(dt);
28✔
506
    int64_t id = 0;
28✔
507
    for (const auto &d_i : dev_vec) {
28!
508
        if (Device == d_i) {
28!
509
            relid = id;
28✔
510
            break;
28✔
511
        }
28✔
512
        if (d_i.get_platform().get_backend() == be)
×
513
            ++id;
×
514
    }
×
515
    return relid;
28✔
516
}
28✔
517

518
std::string DPCTL_GetDeviceFilterString(const device &Device)
519
{
25✔
520
    std::stringstream ss;
25✔
521
    static constexpr const char *filter_string_separator = ":";
25✔
522

523
    auto be = Device.get_platform().get_backend();
25✔
524

525
    switch (be) {
25✔
526
    case backend::ext_oneapi_level_zero:
×
527
        ss << "level_zero";
×
528
        break;
×
529
    case backend::ext_oneapi_cuda:
×
530
        ss << "cuda";
×
531
        break;
×
532
    case backend::opencl:
25!
533
        ss << "opencl";
25✔
534
        break;
25✔
535
    case backend::ext_oneapi_hip:
×
536
        ss << "hip";
×
537
        break;
×
538
    default:
×
539
        ss << "unknown";
×
540
    };
25✔
541

542
    ss << filter_string_separator;
25✔
543
    ss << DPCTL_DeviceTypeToStr(Device.get_info<info::device::device_type>());
25✔
544
    ss << filter_string_separator;
25✔
545
    ss << DPCTL_GetRelativeDeviceId(Device);
25✔
546

547
    return ss.str();
25✔
548
}
25✔
549

550
DPCTLSyclEventStatusType
551
DPCTL_SyclEventStatusToDPCTLEventStatusType(info::event_command_status E)
552
{
6✔
553
    switch (E) {
6✔
554
    case info::event_command_status::submitted:
3✔
555
        return DPCTLSyclEventStatusType::DPCTL_SUBMITTED;
3✔
556
    case info::event_command_status::running:
×
557
        return DPCTLSyclEventStatusType::DPCTL_RUNNING;
×
558
    case info::event_command_status::complete:
3✔
559
        return DPCTLSyclEventStatusType::DPCTL_COMPLETE;
3✔
560
    default:
×
561
        return DPCTLSyclEventStatusType::DPCTL_UNKNOWN_STATUS;
×
562
    }
6✔
563
}
6✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc