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

IntelPython / dpctl / 32240679733

19 Aug 2026 10:02AM UTC coverage: 74.729%. First build
32240679733

Pull #2365

github

web-flow
Merge 88a939abb into 6b3c5888e
Pull Request #2365: Add `dpctl.SyclQueue.fill()` method

1034 of 1462 branches covered (70.73%)

Branch coverage included in aggregate %.

122 of 137 new or added lines in 1 file covered. (89.05%)

3999 of 5273 relevant lines covered (75.84%)

279.47 hits per line

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

86.9
/libsyclinterface/source/dpctl_sycl_queue_interface.cpp
1
//===----- dpctl_sycl_queue_interface.cpp - Implements C API for sycl::queue =//
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 data types and functions declared in
23
/// dpctl_sycl_queue_interface.h.
24
///
25
//===----------------------------------------------------------------------===//
26

27
#include "dpctl_sycl_queue_interface.h"
28
#include "Config/dpctl_config.h"
29
#include "dpctl_error_handlers.h"
30
#include "dpctl_sycl_context_interface.h"
31
#include "dpctl_sycl_device_interface.h"
32
#include "dpctl_sycl_device_manager.h"
33
#include "dpctl_sycl_type_casters.hpp"
34

35
#include <stddef.h>
36
#include <stdint.h>
37

38
#include <cstdint>
39
#include <exception>
40
#include <sstream>
41
#include <stdexcept>
42
#include <sycl/sycl.hpp> /* SYCL headers   */
43
#include <utility>
44
#include <vector>
45

46
#if defined(SYCL_EXT_ONEAPI_WORK_GROUP_MEMORY) ||                              \
47
    defined(SYCL_EXT_ONEAPI_RAW_KERNEL_ARG)
48
#include "dpctl_sycl_extension_interface.h"
49
#endif
50

51
using namespace sycl;
52

53
#define SET_LOCAL_ACCESSOR_ARG(CGH, NDIM, ARGTY, R, IDX)                       \
54
    do {                                                                       \
31✔
55
        switch ((ARGTY)) {                                                     \
31✔
56
        case DPCTL_INT8_T:                                                     \
3✔
57
        {                                                                      \
3✔
58
            auto la = local_accessor<std::int8_t, NDIM>(R, CGH);               \
3✔
59
            CGH.set_arg(IDX, la);                                              \
3✔
60
            return true;                                                       \
3✔
61
        }                                                                      \
×
62
        case DPCTL_UINT8_T:                                                    \
3✔
63
        {                                                                      \
3✔
64
            auto la = local_accessor<std::uint8_t, NDIM>(R, CGH);              \
3✔
65
            CGH.set_arg(IDX, la);                                              \
3✔
66
            return true;                                                       \
3✔
67
        }                                                                      \
×
68
        case DPCTL_INT16_T:                                                    \
3✔
69
        {                                                                      \
3✔
70
            auto la = local_accessor<std::int16_t, NDIM>(R, CGH);              \
3✔
71
            CGH.set_arg(IDX, la);                                              \
3✔
72
            return true;                                                       \
3✔
73
        }                                                                      \
×
74
        case DPCTL_UINT16_T:                                                   \
3✔
75
        {                                                                      \
3✔
76
            auto la = local_accessor<std::uint16_t, NDIM>(R, CGH);             \
3✔
77
            CGH.set_arg(IDX, la);                                              \
3✔
78
            return true;                                                       \
3✔
79
        }                                                                      \
×
80
        case DPCTL_INT32_T:                                                    \
3✔
81
        {                                                                      \
3✔
82
            auto la = local_accessor<std::int32_t, NDIM>(R, CGH);              \
3✔
83
            CGH.set_arg(IDX, la);                                              \
3✔
84
            return true;                                                       \
3✔
85
        }                                                                      \
×
86
        case DPCTL_UINT32_T:                                                   \
3✔
87
        {                                                                      \
3✔
88
            auto la = local_accessor<std::uint32_t, NDIM>(R, CGH);             \
3✔
89
            CGH.set_arg(IDX, la);                                              \
3✔
90
            return true;                                                       \
3✔
91
        }                                                                      \
×
92
        case DPCTL_INT64_T:                                                    \
3✔
93
        {                                                                      \
3✔
94
            auto la = local_accessor<std::int64_t, NDIM>(R, CGH);              \
3✔
95
            CGH.set_arg(IDX, la);                                              \
3✔
96
            return true;                                                       \
3✔
97
        }                                                                      \
×
98
        case DPCTL_UINT64_T:                                                   \
3✔
99
        {                                                                      \
3✔
100
            auto la = local_accessor<std::uint64_t, NDIM>(R, CGH);             \
3✔
101
            CGH.set_arg(IDX, la);                                              \
3✔
102
            return true;                                                       \
3✔
103
        }                                                                      \
×
104
        case DPCTL_FLOAT32_T:                                                  \
3✔
105
        {                                                                      \
3✔
106
            auto la = local_accessor<float, NDIM>(R, CGH);                     \
3✔
107
            CGH.set_arg(IDX, la);                                              \
3✔
108
            return true;                                                       \
3✔
109
        }                                                                      \
×
110
        case DPCTL_FLOAT64_T:                                                  \
3✔
111
        {                                                                      \
3✔
112
            auto la = local_accessor<double, NDIM>(R, CGH);                    \
3✔
113
            CGH.set_arg(IDX, la);                                              \
3✔
114
            return true;                                                       \
3✔
115
        }                                                                      \
×
116
        default:                                                               \
1✔
117
            error_handler("Kernel argument could not be created.", __FILE__,   \
1✔
118
                          __func__, __LINE__, error_level::error);             \
1✔
119
            return false;                                                      \
1✔
120
        }                                                                      \
31✔
121
    } while (0);
31!
122

123
namespace
124
{
125
static_assert(__SYCL_COMPILER_VERSION >= __SYCL_COMPILER_VERSION_REQUIRED,
126
              "The compiler does not meet minimum version requirement");
127

128
using namespace dpctl::syclinterface;
129

130
typedef struct complex
131
{
132
    std::uint64_t real;
133
    std::uint64_t imag;
134
} complexNumber;
135

136
void set_dependent_events(handler &cgh,
137
                          __dpctl_keep const DPCTLSyclEventRef *DepEvents,
138
                          size_t NDepEvents)
139
{
177✔
140
    for (auto i = 0ul; i < NDepEvents; ++i) {
333✔
141
        auto ei = unwrap<event>(DepEvents[i]);
156✔
142
        if (ei)
156!
143
            cgh.depends_on(*ei);
156✔
144
    }
156✔
145
}
177✔
146

147
bool set_local_accessor_arg(handler &cgh,
148
                            size_t idx,
149
                            const MDLocalAccessor *mdstruct)
150
{
31✔
151
    switch (mdstruct->ndim) {
31✔
152
    case 1:
11✔
153
    {
11✔
154
        auto r = range<1>(mdstruct->dim0);
11✔
155
        SET_LOCAL_ACCESSOR_ARG(cgh, 1, mdstruct->dpctl_type_id, r, idx);
11✔
156
    }
×
157
    case 2:
10✔
158
    {
10✔
159
        auto r = range<2>(mdstruct->dim0, mdstruct->dim1);
10✔
160
        SET_LOCAL_ACCESSOR_ARG(cgh, 2, mdstruct->dpctl_type_id, r, idx);
10✔
161
    }
×
162
    case 3:
10✔
163
    {
10✔
164
        auto r = range<3>(mdstruct->dim0, mdstruct->dim1, mdstruct->dim2);
10✔
165
        SET_LOCAL_ACCESSOR_ARG(cgh, 3, mdstruct->dpctl_type_id, r, idx);
10✔
166
    }
×
167
    default:
×
168
        return false;
×
169
    }
31✔
170
}
31✔
171
/*!
172
 * @brief Set the kernel arg object
173
 *
174
 * @param cgh   SYCL command group handler using which a kernel is going to
175
 *              be submitted.
176
 * @param idx   The position of the argument in the list of arguments passed
177
 * to a kernel.
178
 * @param Arg   A void* representing a kernel argument.
179
 * @param Argty A typeid specifying the C++ type of the Arg parameter.
180
 */
181
bool set_kernel_arg(handler &cgh,
182
                    size_t idx,
183
                    __dpctl_keep void *Arg,
184
                    DPCTLKernelArgType ArgTy)
185
{
502✔
186
    bool arg_set = true;
502✔
187

188
    switch (ArgTy) {
502✔
189
    case DPCTL_INT8_T:
3✔
190
        cgh.set_arg(idx, *(std::int8_t *)Arg);
3✔
191
        break;
3✔
192
    case DPCTL_UINT8_T:
3✔
193
        cgh.set_arg(idx, *(std::uint8_t *)Arg);
3✔
194
        break;
3✔
195
    case DPCTL_INT16_T:
9✔
196
        cgh.set_arg(idx, *(std::int16_t *)Arg);
9✔
197
        break;
9✔
198
    case DPCTL_UINT16_T:
3✔
199
        cgh.set_arg(idx, *(std::uint16_t *)Arg);
3✔
200
        break;
3✔
201
    case DPCTL_INT32_T:
9✔
202
        cgh.set_arg(idx, *(std::int32_t *)Arg);
9✔
203
        break;
9✔
204
    case DPCTL_UINT32_T:
11✔
205
        cgh.set_arg(idx, *(std::uint32_t *)Arg);
11✔
206
        break;
11✔
207
    case DPCTL_INT64_T:
9✔
208
        cgh.set_arg(idx, *(std::int64_t *)Arg);
9✔
209
        break;
9✔
210
    case DPCTL_UINT64_T:
14✔
211
        cgh.set_arg(idx, *(std::uint64_t *)Arg);
14✔
212
        break;
14✔
213
    case DPCTL_FLOAT32_T:
9✔
214
        cgh.set_arg(idx, *(float *)Arg);
9✔
215
        break;
9✔
216
    case DPCTL_FLOAT64_T:
9✔
217
        cgh.set_arg(idx, *(double *)Arg);
9✔
218
        break;
9✔
219
    case DPCTL_VOID_PTR:
330✔
220
        cgh.set_arg(idx, Arg);
330✔
221
        break;
330✔
222
    case DPCTL_LOCAL_ACCESSOR:
31✔
223
        arg_set = set_local_accessor_arg(cgh, idx, (MDLocalAccessor *)Arg);
31✔
224
        break;
31✔
225
#ifdef SYCL_EXT_ONEAPI_WORK_GROUP_MEMORY
×
226
    case DPCTL_WORK_GROUP_MEMORY:
31✔
227
    {
31✔
228
        auto ref = static_cast<DPCTLSyclWorkGroupMemoryRef>(Arg);
31✔
229
        RawWorkGroupMemory *raw_mem = unwrap<RawWorkGroupMemory>(ref);
31✔
230
        size_t num_bytes = raw_mem->nbytes;
31✔
231
        sycl::ext::oneapi::experimental::work_group_memory<char[]> mem{
31✔
232
            num_bytes, cgh};
31✔
233
        cgh.set_arg(idx, mem);
31✔
234
        break;
31✔
235
    }
×
236
#endif
×
237
#ifdef SYCL_EXT_ONEAPI_RAW_KERNEL_ARG
×
238
    case DPCTL_RAW_KERNEL_ARG:
30✔
239
    {
30✔
240
        auto ref = static_cast<DPCTLSyclRawKernelArgRef>(Arg);
30✔
241
        std::vector<unsigned char> *raw_arg =
30✔
242
            unwrap<std::vector<unsigned char>>(ref);
30✔
243
        void *bytes = raw_arg->data();
30✔
244
        size_t count = raw_arg->size();
30✔
245
        sycl::ext::oneapi::experimental::raw_kernel_arg arg{bytes, count};
30✔
246
        cgh.set_arg(idx, arg);
30✔
247
        break;
30✔
248
    }
×
249
#endif
×
250
    default:
1✔
251
        arg_set = false;
1✔
252
        break;
1✔
253
    }
502✔
254
    return arg_set;
502✔
255
}
502✔
256

257
void set_kernel_args(handler &cgh,
258
                     __dpctl_keep void **Args,
259
                     __dpctl_keep const DPCTLKernelArgType *ArgTypes,
260
                     size_t NArgs)
261
{
177✔
262
    for (auto i = 0ul; i < NArgs; ++i) {
677✔
263
        if (!set_kernel_arg(cgh, i, Args[i], ArgTypes[i])) {
502✔
264
            error_handler("Kernel argument could not be created.", __FILE__,
2✔
265
                          __func__, __LINE__);
2✔
266
            throw std::invalid_argument(
2✔
267
                "Kernel argument could not be created.");
2✔
268
        }
2✔
269
    }
502✔
270
}
177✔
271

272
std::unique_ptr<property_list> create_property_list(int properties)
273
{
1,795✔
274
    std::unique_ptr<property_list> propList;
1,795✔
275
    int _prop = properties;
1,795✔
276
    if (_prop & DPCTL_ENABLE_PROFILING) {
1,795✔
277
        _prop = _prop ^ DPCTL_ENABLE_PROFILING;
82✔
278
        if (_prop & DPCTL_IN_ORDER) {
82✔
279
            _prop = _prop ^ DPCTL_IN_ORDER;
34✔
280
            propList = std::make_unique<property_list>(
34✔
281
                sycl::property::queue::enable_profiling(),
34✔
282
                sycl::property::queue::in_order());
34✔
283
        }
34✔
284
        else {
48✔
285
            propList = std::make_unique<property_list>(
48✔
286
                sycl::property::queue::enable_profiling());
48✔
287
        }
48✔
288
    }
82✔
289
    else if (_prop & DPCTL_IN_ORDER) {
1,713✔
290
        _prop = _prop ^ DPCTL_IN_ORDER;
549✔
291
        propList =
549✔
292
            std::make_unique<property_list>(sycl::property::queue::in_order());
549✔
293
    }
549✔
294
    else {
1,164✔
295
        propList = std::make_unique<property_list>();
1,164✔
296
    }
1,164✔
297

298
    if (_prop) {
1,795✔
299
        std::stringstream ss;
1✔
300
        ss << "Invalid queue property argument (" << std::hex << properties
1✔
301
           << "), interpreted as (" << (properties ^ _prop) << ").";
1✔
302
        error_handler(ss.str(), __FILE__, __func__, __LINE__);
1✔
303
    }
1✔
304
    return propList;
1,795✔
305
}
1,795✔
306

307
__dpctl_give DPCTLSyclQueueRef
308
getQueueImpl(__dpctl_keep DPCTLSyclContextRef cRef,
309
             __dpctl_keep DPCTLSyclDeviceRef dRef,
310
             error_handler_callback *handler,
311
             int properties)
312
{
199✔
313
    DPCTLSyclQueueRef qRef = nullptr;
199✔
314
    qRef = DPCTLQueue_Create(cRef, dRef, handler, properties);
199✔
315
    return qRef;
199✔
316
}
199✔
317

318
} /* end of anonymous namespace */
319

320
DPCTL_API
321
__dpctl_give DPCTLSyclQueueRef
322
DPCTLQueue_Create(__dpctl_keep const DPCTLSyclContextRef CRef,
323
                  __dpctl_keep const DPCTLSyclDeviceRef DRef,
324
                  error_handler_callback *handler,
325
                  int properties)
326
{
1,797✔
327
    DPCTLSyclQueueRef q = nullptr;
1,797✔
328
    auto dev = unwrap<device>(DRef);
1,797✔
329
    auto ctx = unwrap<context>(CRef);
1,797✔
330

331
    if (!(dev && ctx)) {
1,797✔
332
        error_handler("Cannot create queue from DPCTLSyclContextRef and "
2✔
333
                      "DPCTLSyclDeviceRef as input is a nullptr.",
2✔
334
                      __FILE__, __func__, __LINE__);
2✔
335
        return q;
2✔
336
    }
2✔
337
    auto propList = create_property_list(properties);
1,795✔
338

339
    if (handler) {
1,795✔
340
        try {
64✔
341
            auto Queue = new queue(*ctx, *dev, DPCTL_AsyncErrorHandler(handler),
64✔
342
                                   *propList);
64✔
343
            q = wrap<queue>(Queue);
64✔
344
        } catch (std::exception const &e) {
64✔
345
            error_handler(e, __FILE__, __func__, __LINE__);
×
346
        }
×
347
    }
64✔
348
    else {
1,731✔
349
        try {
1,731✔
350
            auto Queue = new queue(*ctx, *dev, *propList);
1,731✔
351
            q = wrap<queue>(Queue);
1,731✔
352
        } catch (std::exception const &e) {
1,731✔
353
            error_handler(e, __FILE__, __func__, __LINE__);
1✔
354
        }
1✔
355
    }
1,731✔
356

357
    return q;
1,795✔
358
}
1,795✔
359

360
__dpctl_give DPCTLSyclQueueRef
361
DPCTLQueue_CreateForDevice(__dpctl_keep const DPCTLSyclDeviceRef DRef,
362
                           error_handler_callback *handler,
363
                           int properties)
364
{
465✔
365
    DPCTLSyclContextRef CRef = nullptr;
465✔
366
    DPCTLSyclQueueRef QRef = nullptr;
465✔
367
    auto Device = unwrap<device>(DRef);
465✔
368

369
    if (!Device) {
465✔
370
        error_handler("Cannot create queue from NULL device reference.",
266✔
371
                      __FILE__, __func__, __LINE__);
266✔
372
        return QRef;
266✔
373
    }
266✔
374
    // Check if a cached default context exists for the device.
375
    CRef = DPCTLDeviceMgr_GetCachedContext(DRef);
199✔
376
    // If a cached default context was found, that context will be used to use
377
    // create the new queue. When a default cached context was not found, as
378
    // will be the case for non-root devices, i.e., sub-devices, a new context
379
    // will be allocated. Note that any newly allocated context is not cached.
380
    if (!CRef) {
199!
381
        context *ContextPtr = nullptr;
×
382
        try {
×
383
            ContextPtr = new context(*Device);
×
384
            CRef = wrap<context>(ContextPtr);
×
385
        } catch (std::exception const &e) {
×
386
            error_handler(e, __FILE__, __func__, __LINE__);
×
387
            delete ContextPtr;
×
388
            return QRef;
×
389
        }
×
390
    }
×
391
    // At this point we have a valid context and the queue can be allocated.
392
    QRef = getQueueImpl(CRef, DRef, handler, properties);
199✔
393
    // Free the context
394
    DPCTLContext_Delete(CRef);
199✔
395
    return QRef;
199✔
396
}
199✔
397

398
/*!
399
 * Delete the passed in pointer after verifying it points to a sycl::queue.
400
 */
401
void DPCTLQueue_Delete(__dpctl_take DPCTLSyclQueueRef QRef)
402
{
2,171✔
403
    delete unwrap<queue>(QRef);
2,171✔
404
}
2,171✔
405

406
/*!
407
 * Make copy of sycl::queue referenced by passed pointer
408
 */
409
__dpctl_give DPCTLSyclQueueRef
410
DPCTLQueue_Copy(__dpctl_keep const DPCTLSyclQueueRef QRef)
411
{
116✔
412
    auto Queue = unwrap<queue>(QRef);
116✔
413
    if (Queue) {
116✔
414
        try {
115✔
415
            auto CopiedQueue = new queue(*Queue);
115✔
416
            return wrap<queue>(CopiedQueue);
115✔
417
        } catch (std::exception const &e) {
115✔
418
            error_handler(e, __FILE__, __func__, __LINE__);
×
419
            return nullptr;
×
420
        }
×
421
    }
115✔
422
    else {
1✔
423
        error_handler("Cannot copy DPCTLSyclQueueRef as input is a nullptr",
1✔
424
                      __FILE__, __func__, __LINE__);
1✔
425
        return nullptr;
1✔
426
    }
1✔
427
}
116✔
428

429
bool DPCTLQueue_AreEq(__dpctl_keep const DPCTLSyclQueueRef QRef1,
430
                      __dpctl_keep const DPCTLSyclQueueRef QRef2)
431
{
13✔
432
    if (!(QRef1 && QRef2)) {
13✔
433
        error_handler("DPCTLSyclQueueRefs are nullptr.", __FILE__, __func__,
2✔
434
                      __LINE__);
2✔
435
        return false;
2✔
436
    }
2✔
437
    return (*unwrap<queue>(QRef1) == *unwrap<queue>(QRef2));
11✔
438
}
13✔
439

440
DPCTLSyclBackendType DPCTLQueue_GetBackend(__dpctl_keep DPCTLSyclQueueRef QRef)
441
{
10✔
442
    auto Q = unwrap<queue>(QRef);
10✔
443
    if (Q) {
10✔
444
        try {
9✔
445
            auto C = Q->get_context();
9✔
446
            return DPCTLContext_GetBackend(wrap<context>(&C));
9✔
447
        } catch (std::exception const &e) {
9✔
448
            error_handler(e, __FILE__, __func__, __LINE__);
×
449
            return DPCTL_UNKNOWN_BACKEND;
×
450
        }
×
451
    }
9✔
452
    else
1✔
453
        return DPCTL_UNKNOWN_BACKEND;
1✔
454
}
10✔
455

456
__dpctl_give DPCTLSyclDeviceRef
457
DPCTLQueue_GetDevice(__dpctl_keep const DPCTLSyclQueueRef QRef)
458
{
74✔
459
    DPCTLSyclDeviceRef DRef = nullptr;
74✔
460
    auto Q = unwrap<queue>(QRef);
74✔
461
    if (Q) {
74✔
462
        try {
73✔
463
            auto Device = new device(Q->get_device());
73✔
464
            DRef = wrap<device>(Device);
73✔
465
        } catch (std::exception const &e) {
73✔
466
            error_handler(e, __FILE__, __func__, __LINE__);
×
467
        }
×
468
    }
73✔
469
    else {
1✔
470
        error_handler("Could not get the device for this queue.", __FILE__,
1✔
471
                      __func__, __LINE__);
1✔
472
    }
1✔
473
    return DRef;
74✔
474
}
74✔
475

476
__dpctl_give DPCTLSyclContextRef
477
DPCTLQueue_GetContext(__dpctl_keep const DPCTLSyclQueueRef QRef)
478
{
140✔
479
    auto Q = unwrap<queue>(QRef);
140✔
480
    DPCTLSyclContextRef CRef = nullptr;
140✔
481
    if (Q)
140✔
482
        CRef = wrap<context>(new context(Q->get_context()));
130✔
483
    else {
10✔
484
        error_handler("Could not get the context for this queue.", __FILE__,
10✔
485
                      __func__, __LINE__);
10✔
486
    }
10✔
487
    return CRef;
140✔
488
}
140✔
489

490
__dpctl_give DPCTLSyclEventRef
491
DPCTLQueue_SubmitRange(__dpctl_keep const DPCTLSyclKernelRef KRef,
492
                       __dpctl_keep const DPCTLSyclQueueRef QRef,
493
                       __dpctl_keep void **Args,
494
                       __dpctl_keep const DPCTLKernelArgType *ArgTypes,
495
                       size_t NArgs,
496
                       __dpctl_keep const size_t Range[3],
497
                       size_t NDims,
498
                       __dpctl_keep const DPCTLSyclEventRef *DepEvents,
499
                       size_t NDepEvents)
500
{
63✔
501
    auto Kernel = unwrap<kernel>(KRef);
63✔
502
    auto Queue = unwrap<queue>(QRef);
63✔
503
    event e;
63✔
504

505
    try {
63✔
506
        switch (NDims) {
63✔
507
        case 1:
29✔
508
        {
29✔
509
            e = Queue->submit([&](handler &cgh) {
29✔
510
                // Depend on any event that was specified by the caller.
511
                set_dependent_events(cgh, DepEvents, NDepEvents);
29✔
512
                set_kernel_args(cgh, Args, ArgTypes, NArgs);
29✔
513
                cgh.parallel_for(range<1>{Range[0]}, *Kernel);
29✔
514
            });
29✔
515
            return wrap<event>(new event(std::move(e)));
29✔
516
        }
×
517
        case 2:
17✔
518
        {
17✔
519
            e = Queue->submit([&](handler &cgh) {
17✔
520
                // Depend on any event that was specified by the caller.
521
                set_dependent_events(cgh, DepEvents, NDepEvents);
17✔
522
                set_kernel_args(cgh, Args, ArgTypes, NArgs);
17✔
523
                cgh.parallel_for(range<2>{Range[0], Range[1]}, *Kernel);
17✔
524
            });
17✔
525
            return wrap<event>(new event(std::move(e)));
17✔
526
        }
×
527
        case 3:
17✔
528
        {
17✔
529
            e = Queue->submit([&](handler &cgh) {
17✔
530
                // Depend on any event that was specified by the caller.
531
                set_dependent_events(cgh, DepEvents, NDepEvents);
17✔
532
                set_kernel_args(cgh, Args, ArgTypes, NArgs);
17✔
533
                cgh.parallel_for(range<3>{Range[0], Range[1], Range[2]},
17✔
534
                                 *Kernel);
17✔
535
            });
17✔
536
            return wrap<event>(new event(std::move(e)));
17✔
537
        }
×
538
        default:
×
539
            error_handler("Range cannot be greater than three "
×
540
                          "dimensions.",
×
541
                          __FILE__, __func__, __LINE__, error_level::error);
×
542
            return nullptr;
×
543
        }
63✔
544
    } catch (std::exception const &e) {
63✔
545
        error_handler(e, __FILE__, __func__, __LINE__, error_level::error);
1✔
546
        return nullptr;
1✔
547
    } catch (...) {
1✔
548
        error_handler("Unknown exception encountered", __FILE__, __func__,
×
549
                      __LINE__, error_level::error);
×
550
        return nullptr;
×
551
    }
×
552
}
63✔
553

554
__dpctl_give DPCTLSyclEventRef
555
DPCTLQueue_SubmitNDRange(__dpctl_keep const DPCTLSyclKernelRef KRef,
556
                         __dpctl_keep const DPCTLSyclQueueRef QRef,
557
                         __dpctl_keep void **Args,
558
                         __dpctl_keep const DPCTLKernelArgType *ArgTypes,
559
                         size_t NArgs,
560
                         __dpctl_keep const size_t gRange[3],
561
                         __dpctl_keep const size_t lRange[3],
562
                         size_t NDims,
563
                         __dpctl_keep const DPCTLSyclEventRef *DepEvents,
564
                         size_t NDepEvents)
565
{
114✔
566
    auto Kernel = unwrap<kernel>(KRef);
114✔
567
    auto Queue = unwrap<queue>(QRef);
114✔
568
    event e;
114✔
569

570
    try {
114✔
571
        switch (NDims) {
114✔
572
        case 1:
100✔
573
        {
100✔
574
            e = Queue->submit([&](handler &cgh) {
100✔
575
                // Depend on any event that was specified by the caller.
576
                set_dependent_events(cgh, DepEvents, NDepEvents);
100✔
577
                set_kernel_args(cgh, Args, ArgTypes, NArgs);
100✔
578
                cgh.parallel_for(nd_range<1>{{gRange[0]}, {lRange[0]}},
100✔
579
                                 *Kernel);
100✔
580
            });
100✔
581
            return wrap<event>(new event(std::move(e)));
100✔
582
        }
×
583
        case 2:
7✔
584
        {
7✔
585
            e = Queue->submit([&](handler &cgh) {
7✔
586
                // Depend on any event that was specified by the caller.
587
                set_dependent_events(cgh, DepEvents, NDepEvents);
7✔
588
                set_kernel_args(cgh, Args, ArgTypes, NArgs);
7✔
589
                cgh.parallel_for(
7✔
590
                    nd_range<2>{{gRange[0], gRange[1]}, {lRange[0], lRange[1]}},
7✔
591
                    *Kernel);
7✔
592
            });
7✔
593
            return wrap<event>(new event(std::move(e)));
7✔
594
        }
×
595
        case 3:
7✔
596
        {
7✔
597
            e = Queue->submit([&](handler &cgh) {
7✔
598
                // Depend on any event that was specified by the caller.
599
                set_dependent_events(cgh, DepEvents, NDepEvents);
7✔
600
                set_kernel_args(cgh, Args, ArgTypes, NArgs);
7✔
601
                cgh.parallel_for(nd_range<3>{{gRange[0], gRange[1], gRange[2]},
7✔
602
                                             {lRange[0], lRange[1], lRange[2]}},
7✔
603
                                 *Kernel);
7✔
604
            });
7✔
605
            return wrap<event>(new event(std::move(e)));
7✔
606
        }
×
607
        default:
×
608
            error_handler("Range cannot be greater than three "
×
609
                          "dimensions.",
×
610
                          __FILE__, __func__, __LINE__, error_level::error);
×
611
            return nullptr;
×
612
        }
114✔
613
    } catch (std::exception const &e) {
114✔
614
        error_handler(e, __FILE__, __func__, __LINE__, error_level::error);
1✔
615
        return nullptr;
1✔
616
    } catch (...) {
1✔
617
        error_handler("Unknown exception encountered", __FILE__, __func__,
×
618
                      __LINE__, error_level::error);
×
619
        return nullptr;
×
620
    }
×
621
}
114✔
622

623
void DPCTLQueue_Wait(__dpctl_keep DPCTLSyclQueueRef QRef)
624
{
1✔
625
    // \todo what happens if the QRef is null or a pointer to a valid sycl
626
    // queue
627
    if (QRef) {
1!
628
        auto SyclQueue = unwrap<queue>(QRef);
1✔
629
        if (SyclQueue)
1!
630
            SyclQueue->wait();
1✔
631
    }
1✔
632
    else {
×
633
        error_handler("Argument QRef is NULL.", __FILE__, __func__, __LINE__);
×
634
    }
×
635
}
1✔
636

637
__dpctl_give DPCTLSyclEventRef
638
DPCTLQueue_Memcpy(__dpctl_keep const DPCTLSyclQueueRef QRef,
639
                  void *Dest,
640
                  const void *Src,
641
                  size_t Count)
642
{
200✔
643
    auto Q = unwrap<queue>(QRef);
200✔
644
    if (Q) {
200✔
645
        sycl::event ev;
199✔
646
        try {
199✔
647
            ev = Q->memcpy(Dest, Src, Count);
199✔
648
        } catch (std::exception const &e) {
199✔
649
            error_handler(e, __FILE__, __func__, __LINE__);
8✔
650
            return nullptr;
8✔
651
        }
8✔
652
        return wrap<event>(new event(std::move(ev)));
191✔
653
    }
199✔
654
    else {
1✔
655
        error_handler("QRef passed to memcpy was NULL.", __FILE__, __func__,
1✔
656
                      __LINE__);
1✔
657
        return nullptr;
1✔
658
    }
1✔
659
}
200✔
660

661
__dpctl_give DPCTLSyclEventRef
662
DPCTLQueue_MemcpyWithEvents(__dpctl_keep const DPCTLSyclQueueRef QRef,
663
                            void *Dest,
664
                            const void *Src,
665
                            size_t Count,
666
                            const DPCTLSyclEventRef *DepEvents,
667
                            size_t DepEventsCount)
668
{
121✔
669
    event ev;
121✔
670
    auto Q = unwrap<queue>(QRef);
121✔
671
    if (Q) {
121✔
672
        try {
120✔
673
            ev = Q->submit([&](handler &cgh) {
120✔
674
                if (DepEvents)
120✔
675
                    for (size_t i = 0; i < DepEventsCount; ++i) {
287✔
676
                        event *ei = unwrap<event>(DepEvents[i]);
175✔
677
                        if (ei)
175!
678
                            cgh.depends_on(*ei);
175✔
679
                    }
175✔
680

681
                cgh.memcpy(Dest, Src, Count);
120✔
682
            });
120✔
683
        } catch (const std::exception &ex) {
120✔
684
            error_handler(ex, __FILE__, __func__, __LINE__);
8✔
685
            return nullptr;
8✔
686
        }
8✔
687
    }
120✔
688
    else {
1✔
689
        error_handler("QRef passed to memcpy was NULL.", __FILE__, __func__,
1✔
690
                      __LINE__);
1✔
691
        return nullptr;
1✔
692
    }
1✔
693

694
    return wrap<event>(new event(ev));
112✔
695
}
121✔
696

697
__dpctl_give DPCTLSyclEventRef
698
DPCTLQueue_CopyData(__dpctl_keep const DPCTLSyclQueueRef QRef,
699
                    void *Dest,
700
                    const void *Src,
701
                    size_t Count)
702
{
50✔
703
    auto Q = unwrap<queue>(QRef);
50✔
704
    if (Q) {
50✔
705
        sycl::event ev;
49✔
706
        try {
49✔
707
            // Copy uint8_t elements (1 byte each), so Count is a byte count.
708
            ev = Q->copy(static_cast<const std::uint8_t *>(Src),
49✔
709
                         static_cast<std::uint8_t *>(Dest), Count);
49✔
710
        } catch (std::exception const &e) {
49✔
711
            error_handler(e, __FILE__, __func__, __LINE__);
8✔
712
            return nullptr;
8✔
713
        }
8✔
714
        return wrap<event>(new event(std::move(ev)));
41✔
715
    }
49✔
716
    else {
1✔
717
        error_handler("QRef passed to copy was NULL.", __FILE__, __func__,
1✔
718
                      __LINE__);
1✔
719
        return nullptr;
1✔
720
    }
1✔
721
}
50✔
722

723
__dpctl_give DPCTLSyclEventRef
724
DPCTLQueue_CopyDataWithEvents(__dpctl_keep const DPCTLSyclQueueRef QRef,
725
                              void *Dest,
726
                              const void *Src,
727
                              size_t Count,
728
                              const DPCTLSyclEventRef *DepEvents,
729
                              size_t DepEventsCount)
730
{
10✔
731
    auto Q = unwrap<queue>(QRef);
10✔
732
    if (Q) {
10✔
733
        try {
9✔
734
            std::vector<event> dep_events;
9✔
735
            if (DepEvents) {
9✔
736
                dep_events.reserve(DepEventsCount);
1✔
737
                for (size_t i = 0; i < DepEventsCount; ++i) {
2✔
738
                    event *ei = unwrap<event>(DepEvents[i]);
1✔
739
                    if (ei)
1!
740
                        dep_events.push_back(*ei);
1✔
741
                }
1✔
742
            }
1✔
743

744
            // Copy uint8_t elements (1 byte each), so Count is a byte count.
745
            auto ev =
9✔
746
                Q->copy(static_cast<const std::uint8_t *>(Src),
9✔
747
                        static_cast<std::uint8_t *>(Dest), Count, dep_events);
9✔
748
            return wrap<event>(new event(std::move(ev)));
9✔
749
        } catch (const std::exception &ex) {
9✔
750
            error_handler(ex, __FILE__, __func__, __LINE__);
8✔
751
            return nullptr;
8✔
752
        }
8✔
753
    }
9✔
754
    else {
1✔
755
        error_handler("QRef passed to copy was NULL.", __FILE__, __func__,
1✔
756
                      __LINE__);
1✔
757
        return nullptr;
1✔
758
    }
1✔
759
}
10✔
760

761
__dpctl_give DPCTLSyclEventRef
762
DPCTLQueue_Prefetch(__dpctl_keep DPCTLSyclQueueRef QRef,
763
                    const void *Ptr,
764
                    size_t Count)
765
{
16✔
766
    auto Q = unwrap<queue>(QRef);
16✔
767
    if (Q) {
16✔
768
        if (Ptr) {
15✔
769
            sycl::event ev;
7✔
770
            try {
7✔
771
                ev = Q->prefetch(Ptr, Count);
7✔
772
            } catch (std::exception const &e) {
7✔
773
                error_handler(e, __FILE__, __func__, __LINE__);
×
774
                return nullptr;
×
775
            }
×
776
            return wrap<event>(new event(std::move(ev)));
7✔
777
        }
7✔
778
        else {
8✔
779
            error_handler("Attempt to prefetch USM-allocation at nullptr.",
8✔
780
                          __FILE__, __func__, __LINE__);
8✔
781
            return nullptr;
8✔
782
        }
8✔
783
    }
15✔
784
    else {
1✔
785
        error_handler("QRef passed to prefetch was NULL.", __FILE__, __func__,
1✔
786
                      __LINE__);
1✔
787
        return nullptr;
1✔
788
    }
1✔
789
}
16✔
790

791
__dpctl_give DPCTLSyclEventRef
792
DPCTLQueue_MemAdvise(__dpctl_keep DPCTLSyclQueueRef QRef,
793
                     const void *Ptr,
794
                     size_t Count,
795
                     int Advice)
796
{
16✔
797
    auto Q = unwrap<queue>(QRef);
16✔
798
    if (Q) {
16✔
799
        sycl::event ev;
15✔
800
        try {
15✔
801
            ev = Q->mem_advise(Ptr, Count, Advice);
15✔
802
        } catch (std::exception const &e) {
15✔
803
            error_handler(e, __FILE__, __func__, __LINE__);
×
804
            return nullptr;
×
805
        }
×
806
        return wrap<event>(new event(std::move(ev)));
15✔
807
    }
15✔
808
    else {
1✔
809
        error_handler("QRef passed to prefetch was NULL.", __FILE__, __func__,
1✔
810
                      __LINE__);
1✔
811
        return nullptr;
1✔
812
    }
1✔
813
}
16✔
814

815
bool DPCTLQueue_IsInOrder(__dpctl_keep const DPCTLSyclQueueRef QRef)
816
{
1,040✔
817
    auto Q = unwrap<queue>(QRef);
1,040✔
818
    if (Q) {
1,040✔
819
        return Q->is_in_order();
1,039✔
820
    }
1,039✔
821
    else
1✔
822
        return false;
1✔
823
}
1,040✔
824

825
bool DPCTLQueue_HasEnableProfiling(__dpctl_keep const DPCTLSyclQueueRef QRef)
826
{
67✔
827
    auto Q = unwrap<queue>(QRef);
67✔
828
    if (Q) {
67✔
829
        return Q->has_property<sycl::property::queue::enable_profiling>();
66✔
830
    }
66✔
831
    else
1✔
832
        return false;
1✔
833
}
67✔
834

835
size_t DPCTLQueue_Hash(__dpctl_keep const DPCTLSyclQueueRef QRef)
836
{
24✔
837
    auto Q = unwrap<queue>(QRef);
24✔
838
    if (Q) {
24✔
839
        std::hash<queue> hash_fn;
21✔
840
        return hash_fn(*Q);
21✔
841
    }
21✔
842
    else {
3✔
843
        error_handler("Argument QRef is NULL.", __FILE__, __func__, __LINE__);
3✔
844
        return 0;
3✔
845
    }
3✔
846
}
24✔
847

848
__dpctl_give DPCTLSyclEventRef DPCTLQueue_SubmitBarrierForEvents(
849
    __dpctl_keep const DPCTLSyclQueueRef QRef,
850
    __dpctl_keep const DPCTLSyclEventRef *DepEvents,
851
    size_t NDepEvents)
852
{
107✔
853
    auto Q = unwrap<queue>(QRef);
107✔
854
    event e;
107✔
855
    if (Q) {
107!
856
        try {
107✔
857
            e = Q->submit([&](handler &cgh) {
107✔
858
                // Depend on any event that was specified by the caller.
859
                if (NDepEvents)
107✔
860
                    for (auto i = 0ul; i < NDepEvents; ++i)
18✔
861
                        cgh.depends_on(*unwrap<event>(DepEvents[i]));
12✔
862

863
                cgh.ext_oneapi_barrier();
107✔
864
            });
107✔
865
        } catch (std::exception const &e) {
107✔
866
            error_handler(e, __FILE__, __func__, __LINE__);
×
867
            return nullptr;
×
868
        }
×
869

870
        return wrap<event>(new event(std::move(e)));
107✔
871
    }
107✔
872
    else {
×
873
        error_handler("Argument QRef is NULL", __FILE__, __func__, __LINE__);
×
874
        return nullptr;
×
875
    }
×
876
}
107✔
877

878
__dpctl_give DPCTLSyclEventRef
879
DPCTLQueue_SubmitBarrier(__dpctl_keep const DPCTLSyclQueueRef QRef)
880
{
1✔
881
    return DPCTLQueue_SubmitBarrierForEvents(QRef, nullptr, 0);
1✔
882
}
1✔
883

884
__dpctl_give DPCTLSyclEventRef
885
DPCTLQueue_Memset(__dpctl_keep const DPCTLSyclQueueRef QRef,
886
                  void *USMRef,
887
                  uint8_t Value,
888
                  size_t Count)
889
{
62✔
890
    auto Q = unwrap<queue>(QRef);
62✔
891
    if (Q && USMRef) {
62!
892
        sycl::event ev;
61✔
893
        try {
61✔
894
            ev = Q->memset(USMRef, static_cast<int>(Value), Count);
61✔
895
        } catch (std::exception const &e) {
61✔
896
            error_handler(e, __FILE__, __func__, __LINE__);
×
897
            return nullptr;
×
898
        }
×
899
        return wrap<event>(new event(std::move(ev)));
61✔
900
    }
61✔
901
    else {
1✔
902
        error_handler("QRef or USMRef passed to fill8 were NULL.", __FILE__,
1✔
903
                      __func__, __LINE__);
1✔
904
        return nullptr;
1✔
905
    }
1✔
906
};
62✔
907

908
__dpctl_give DPCTLSyclEventRef
909
DPCTLQueue_Fill8(__dpctl_keep const DPCTLSyclQueueRef QRef,
910
                 void *USMRef,
911
                 uint8_t Value,
912
                 size_t Count)
913
{
28✔
914
    auto Q = unwrap<queue>(QRef);
28✔
915
    if (Q && USMRef) {
28!
916
        sycl::event ev;
27✔
917
        try {
27✔
918
            ev = Q->fill<uint8_t>(USMRef, Value, Count);
27✔
919
        } catch (std::exception const &e) {
27✔
920
            error_handler(e, __FILE__, __func__, __LINE__);
×
921
            return nullptr;
×
922
        }
×
923
        return wrap<event>(new event(std::move(ev)));
27✔
924
    }
27✔
925
    else {
1✔
926
        error_handler("QRef or USMRef passed to fill8 were NULL.", __FILE__,
1✔
927
                      __func__, __LINE__);
1✔
928
        return nullptr;
1✔
929
    }
1✔
930
}
28✔
931

932
__dpctl_give DPCTLSyclEventRef
933
DPCTLQueue_Fill8WithEvents(__dpctl_keep const DPCTLSyclQueueRef QRef,
934
                           void *USMRef,
935
                           uint8_t Value,
936
                           size_t Count,
937
                           const DPCTLSyclEventRef *DepEvents,
938
                           size_t DepEventsCount)
939
{
10✔
940
    auto Q = unwrap<queue>(QRef);
10✔
941
    if (Q && USMRef) {
10!
942
        sycl::event ev;
9✔
943
        try {
9✔
944
            std::vector<event> dep_events;
9✔
945
            if (DepEvents) {
9!
946
                dep_events.reserve(DepEventsCount);
9✔
947
                for (size_t i = 0; i < DepEventsCount; ++i) {
18✔
948
                    event *ei = unwrap<event>(DepEvents[i]);
9✔
949
                    if (ei)
9!
950
                        dep_events.push_back(*ei);
9✔
951
                }
9✔
952
            }
9✔
953
            ev = Q->fill<uint8_t>(USMRef, Value, Count, dep_events);
9✔
954
        } catch (std::exception const &e) {
9✔
NEW
955
            error_handler(e, __FILE__, __func__, __LINE__);
×
NEW
956
            return nullptr;
×
NEW
957
        }
×
958
        return wrap<event>(new event(std::move(ev)));
9✔
959
    }
9✔
960
    else {
1✔
961
        error_handler("QRef or USMRef passed to fill8 were NULL.", __FILE__,
1✔
962
                      __func__, __LINE__);
1✔
963
        return nullptr;
1✔
964
    }
1✔
965
}
10✔
966

967
__dpctl_give DPCTLSyclEventRef
968
DPCTLQueue_Fill16(__dpctl_keep const DPCTLSyclQueueRef QRef,
969
                  void *USMRef,
970
                  uint16_t Value,
971
                  size_t Count)
972
{
24✔
973
    auto Q = unwrap<queue>(QRef);
24✔
974
    if (Q && USMRef) {
24!
975
        sycl::event ev;
23✔
976
        try {
23✔
977
            ev = Q->fill<uint16_t>(USMRef, Value, Count);
23✔
978
        } catch (std::exception const &e) {
23✔
979
            error_handler(e, __FILE__, __func__, __LINE__);
×
980
            return nullptr;
×
981
        }
×
982
        return wrap<event>(new event(std::move(ev)));
23✔
983
    }
23✔
984
    else {
1✔
985
        error_handler("QRef or USMRef passed to fill16 were NULL.", __FILE__,
1✔
986
                      __func__, __LINE__);
1✔
987
        return nullptr;
1✔
988
    }
1✔
989
}
24✔
990

991
__dpctl_give DPCTLSyclEventRef
992
DPCTLQueue_Fill16WithEvents(__dpctl_keep const DPCTLSyclQueueRef QRef,
993
                            void *USMRef,
994
                            uint16_t Value,
995
                            size_t Count,
996
                            const DPCTLSyclEventRef *DepEvents,
997
                            size_t DepEventsCount)
998
{
9✔
999
    auto Q = unwrap<queue>(QRef);
9✔
1000
    if (Q && USMRef) {
9!
1001
        sycl::event ev;
8✔
1002
        try {
8✔
1003
            std::vector<event> dep_events;
8✔
1004
            if (DepEvents) {
8!
1005
                dep_events.reserve(DepEventsCount);
8✔
1006
                for (size_t i = 0; i < DepEventsCount; ++i) {
16✔
1007
                    event *ei = unwrap<event>(DepEvents[i]);
8✔
1008
                    if (ei)
8!
1009
                        dep_events.push_back(*ei);
8✔
1010
                }
8✔
1011
            }
8✔
1012
            ev = Q->fill<uint16_t>(USMRef, Value, Count, dep_events);
8✔
1013
        } catch (std::exception const &e) {
8✔
NEW
1014
            error_handler(e, __FILE__, __func__, __LINE__);
×
NEW
1015
            return nullptr;
×
NEW
1016
        }
×
1017
        return wrap<event>(new event(std::move(ev)));
8✔
1018
    }
8✔
1019
    else {
1✔
1020
        error_handler("QRef or USMRef passed to fill16 were NULL.", __FILE__,
1✔
1021
                      __func__, __LINE__);
1✔
1022
        return nullptr;
1✔
1023
    }
1✔
1024
}
9✔
1025

1026
__dpctl_give DPCTLSyclEventRef
1027
DPCTLQueue_Fill32(__dpctl_keep const DPCTLSyclQueueRef QRef,
1028
                  void *USMRef,
1029
                  uint32_t Value,
1030
                  size_t Count)
1031
{
27✔
1032
    auto Q = unwrap<queue>(QRef);
27✔
1033
    if (Q && USMRef) {
27!
1034
        sycl::event ev;
26✔
1035
        try {
26✔
1036
            ev = Q->fill<uint32_t>(USMRef, Value, Count);
26✔
1037
        } catch (std::exception const &e) {
26✔
1038
            error_handler(e, __FILE__, __func__, __LINE__);
×
1039
            return nullptr;
×
1040
        }
×
1041
        return wrap<event>(new event(std::move(ev)));
26✔
1042
    }
26✔
1043
    else {
1✔
1044
        error_handler("QRef or USMRef passed to fill32 were NULL.", __FILE__,
1✔
1045
                      __func__, __LINE__);
1✔
1046
        return nullptr;
1✔
1047
    }
1✔
1048
}
27✔
1049

1050
__dpctl_give DPCTLSyclEventRef
1051
DPCTLQueue_Fill32WithEvents(__dpctl_keep const DPCTLSyclQueueRef QRef,
1052
                            void *USMRef,
1053
                            uint32_t Value,
1054
                            size_t Count,
1055
                            const DPCTLSyclEventRef *DepEvents,
1056
                            size_t DepEventsCount)
1057
{
9✔
1058
    auto Q = unwrap<queue>(QRef);
9✔
1059
    if (Q && USMRef) {
9!
1060
        sycl::event ev;
8✔
1061
        try {
8✔
1062
            std::vector<event> dep_events;
8✔
1063
            if (DepEvents) {
8!
1064
                dep_events.reserve(DepEventsCount);
8✔
1065
                for (size_t i = 0; i < DepEventsCount; ++i) {
16✔
1066
                    event *ei = unwrap<event>(DepEvents[i]);
8✔
1067
                    if (ei)
8!
1068
                        dep_events.push_back(*ei);
8✔
1069
                }
8✔
1070
            }
8✔
1071
            ev = Q->fill<uint32_t>(USMRef, Value, Count, dep_events);
8✔
1072
        } catch (std::exception const &e) {
8✔
NEW
1073
            error_handler(e, __FILE__, __func__, __LINE__);
×
NEW
1074
            return nullptr;
×
NEW
1075
        }
×
1076
        return wrap<event>(new event(std::move(ev)));
8✔
1077
    }
8✔
1078
    else {
1✔
1079
        error_handler("QRef or USMRef passed to fill32 were NULL.", __FILE__,
1✔
1080
                      __func__, __LINE__);
1✔
1081
        return nullptr;
1✔
1082
    }
1✔
1083
}
9✔
1084

1085
__dpctl_give DPCTLSyclEventRef
1086
DPCTLQueue_Fill64(__dpctl_keep const DPCTLSyclQueueRef QRef,
1087
                  void *USMRef,
1088
                  uint64_t Value,
1089
                  size_t Count)
1090
{
33✔
1091
    auto Q = unwrap<queue>(QRef);
33✔
1092
    if (Q && USMRef) {
33!
1093
        sycl::event ev;
32✔
1094
        try {
32✔
1095
            ev = Q->fill<uint64_t>(USMRef, Value, Count);
32✔
1096
        } catch (std::exception const &e) {
32✔
1097
            error_handler(e, __FILE__, __func__, __LINE__);
×
1098
            return nullptr;
×
1099
        }
×
1100
        return wrap<event>(new event(std::move(ev)));
32✔
1101
    }
32✔
1102
    else {
1✔
1103
        error_handler("QRef or USMRef passed to fill64 were NULL.", __FILE__,
1✔
1104
                      __func__, __LINE__);
1✔
1105
        return nullptr;
1✔
1106
    }
1✔
1107
}
33✔
1108

1109
__dpctl_give DPCTLSyclEventRef
1110
DPCTLQueue_Fill64WithEvents(__dpctl_keep const DPCTLSyclQueueRef QRef,
1111
                            void *USMRef,
1112
                            uint64_t Value,
1113
                            size_t Count,
1114
                            const DPCTLSyclEventRef *DepEvents,
1115
                            size_t DepEventsCount)
1116
{
9✔
1117
    auto Q = unwrap<queue>(QRef);
9✔
1118
    if (Q && USMRef) {
9!
1119
        sycl::event ev;
8✔
1120
        try {
8✔
1121
            std::vector<event> dep_events;
8✔
1122
            if (DepEvents) {
8!
1123
                dep_events.reserve(DepEventsCount);
8✔
1124
                for (size_t i = 0; i < DepEventsCount; ++i) {
16✔
1125
                    event *ei = unwrap<event>(DepEvents[i]);
8✔
1126
                    if (ei)
8!
1127
                        dep_events.push_back(*ei);
8✔
1128
                }
8✔
1129
            }
8✔
1130
            ev = Q->fill<uint64_t>(USMRef, Value, Count, dep_events);
8✔
1131
        } catch (std::exception const &e) {
8✔
NEW
1132
            error_handler(e, __FILE__, __func__, __LINE__);
×
NEW
1133
            return nullptr;
×
NEW
1134
        }
×
1135
        return wrap<event>(new event(std::move(ev)));
8✔
1136
    }
8✔
1137
    else {
1✔
1138
        error_handler("QRef or USMRef passed to fill64 were NULL.", __FILE__,
1✔
1139
                      __func__, __LINE__);
1✔
1140
        return nullptr;
1✔
1141
    }
1✔
1142
}
9✔
1143

1144
__dpctl_give DPCTLSyclEventRef
1145
DPCTLQueue_Fill128(__dpctl_keep const DPCTLSyclQueueRef QRef,
1146
                   void *USMRef,
1147
                   uint64_t *Value,
1148
                   size_t Count)
1149
{
21✔
1150
    auto Q = unwrap<queue>(QRef);
21✔
1151
    if (Q && USMRef) {
21!
1152
        sycl::event ev;
20✔
1153
        try {
20✔
1154
            complexNumber Val;
20✔
1155
            Val.real = Value[0];
20✔
1156
            Val.imag = Value[1];
20✔
1157
            ev = Q->fill(USMRef, Val, Count);
20✔
1158
        } catch (std::exception const &e) {
20✔
1159
            error_handler(e, __FILE__, __func__, __LINE__);
×
1160
            return nullptr;
×
1161
        }
×
1162
        return wrap<event>(new event(std::move(ev)));
20✔
1163
    }
20✔
1164
    else {
1✔
1165
        error_handler("QRef or USMRef passed to fill128 were NULL.", __FILE__,
1✔
1166
                      __func__, __LINE__);
1✔
1167
        return nullptr;
1✔
1168
    }
1✔
1169
}
21✔
1170

1171
__dpctl_give DPCTLSyclEventRef
1172
DPCTLQueue_Fill128WithEvents(__dpctl_keep const DPCTLSyclQueueRef QRef,
1173
                             void *USMRef,
1174
                             uint64_t *Value,
1175
                             size_t Count,
1176
                             const DPCTLSyclEventRef *DepEvents,
1177
                             size_t DepEventsCount)
1178
{
9✔
1179
    auto Q = unwrap<queue>(QRef);
9✔
1180
    if (Q && USMRef) {
9!
1181
        sycl::event ev;
8✔
1182
        try {
8✔
1183
            std::vector<event> dep_events;
8✔
1184
            if (DepEvents) {
8!
1185
                dep_events.reserve(DepEventsCount);
8✔
1186
                for (size_t i = 0; i < DepEventsCount; ++i) {
16✔
1187
                    event *ei = unwrap<event>(DepEvents[i]);
8✔
1188
                    if (ei)
8!
1189
                        dep_events.push_back(*ei);
8✔
1190
                }
8✔
1191
            }
8✔
1192
            complexNumber Val;
8✔
1193
            Val.real = Value[0];
8✔
1194
            Val.imag = Value[1];
8✔
1195
            ev = Q->fill(USMRef, Val, Count, dep_events);
8✔
1196
        } catch (std::exception const &e) {
8✔
NEW
1197
            error_handler(e, __FILE__, __func__, __LINE__);
×
NEW
1198
            return nullptr;
×
NEW
1199
        }
×
1200
        return wrap<event>(new event(std::move(ev)));
8✔
1201
    }
8✔
1202
    else {
1✔
1203
        error_handler("QRef or USMRef passed to fill128 were NULL.", __FILE__,
1✔
1204
                      __func__, __LINE__);
1205
        return nullptr;
1✔
1206
    }
1✔
1207
}
9✔
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