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

IntelPython / dpctl / 35426034188

19 Sep 2026 06:13AM UTC coverage: 75.208% (+0.2%) from 74.959%
35426034188

Pull #2384

github

web-flow
Merge d1888a5a4 into 3799508da
Pull Request #2384: Enable AdaptiveCpp builds

1053 of 1480 branches covered (71.15%)

Branch coverage included in aggregate %.

80 of 96 new or added lines in 16 files covered. (83.33%)

2 existing lines in 2 files now uncovered.

4110 of 5385 relevant lines covered (76.32%)

284.9 hits per line

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

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

133
namespace
134
{
135
#ifndef __ADAPTIVECPP__
136
static_assert(__SYCL_COMPILER_VERSION >= __SYCL_COMPILER_VERSION_REQUIRED,
137
              "The compiler does not meet minimum version requirement");
138
#endif
139

140
using namespace dpctl::syclinterface;
141

142
typedef struct complex
143
{
144
    std::uint64_t real;
145
    std::uint64_t imag;
146
} complexNumber;
147

148
#ifndef __ADAPTIVECPP__
149

150
void set_dependent_events(handler &cgh,
151
                          __dpctl_keep const DPCTLSyclEventRef *DepEvents,
152
                          size_t NDepEvents)
153
{
177✔
154
    for (auto i = 0ul; i < NDepEvents; ++i) {
333✔
155
        auto ei = unwrap<event>(DepEvents[i]);
156✔
156
        if (ei)
156!
157
            cgh.depends_on(*ei);
156✔
158
    }
156✔
159
}
177✔
160

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

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

271
void set_kernel_args(handler &cgh,
272
                     __dpctl_keep void **Args,
273
                     __dpctl_keep const DPCTLKernelArgType *ArgTypes,
274
                     size_t NArgs)
275
{
177✔
276
    for (auto i = 0ul; i < NArgs; ++i) {
677✔
277
        if (!set_kernel_arg(cgh, i, Args[i], ArgTypes[i])) {
502✔
278
            error_handler("Kernel argument could not be created.", __FILE__,
2✔
279
                          __func__, __LINE__);
2✔
280
            throw std::invalid_argument(
2✔
281
                "Kernel argument could not be created.");
2✔
282
        }
2✔
283
    }
502✔
284
}
177✔
285

286
#endif /* #ifndef __ADAPTIVECPP__ */
287

288
std::unique_ptr<property_list> create_property_list(int properties)
289
{
1,855✔
290
    std::unique_ptr<property_list> propList;
1,855✔
291
    int _prop = properties;
1,855✔
292
    if (_prop & DPCTL_ENABLE_PROFILING) {
1,855✔
293
        _prop = _prop ^ DPCTL_ENABLE_PROFILING;
86✔
294
        if (_prop & DPCTL_IN_ORDER) {
86✔
295
            _prop = _prop ^ DPCTL_IN_ORDER;
36✔
296
            propList = std::make_unique<property_list>(
36✔
297
                sycl::property::queue::enable_profiling(),
36✔
298
                sycl::property::queue::in_order());
36✔
299
        }
36✔
300
        else {
50✔
301
            propList = std::make_unique<property_list>(
50✔
302
                sycl::property::queue::enable_profiling());
50✔
303
        }
50✔
304
    }
86✔
305
    else if (_prop & DPCTL_IN_ORDER) {
1,769✔
306
        _prop = _prop ^ DPCTL_IN_ORDER;
551✔
307
        propList =
551✔
308
            std::make_unique<property_list>(sycl::property::queue::in_order());
551✔
309
    }
551✔
310
    else {
1,218✔
311
        propList = std::make_unique<property_list>();
1,218✔
312
    }
1,218✔
313

314
    if (_prop) {
1,855✔
315
        std::stringstream ss;
1✔
316
        ss << "Invalid queue property argument (" << std::hex << properties
1✔
317
           << "), interpreted as (" << (properties ^ _prop) << ").";
1✔
318
        error_handler(ss.str(), __FILE__, __func__, __LINE__);
1✔
319
    }
1✔
320
    return propList;
1,855✔
321
}
1,855✔
322

323
__dpctl_give DPCTLSyclQueueRef
324
getQueueImpl(__dpctl_keep DPCTLSyclContextRef cRef,
325
             __dpctl_keep DPCTLSyclDeviceRef dRef,
326
             error_handler_callback *handler,
327
             int properties)
328
{
207✔
329
    DPCTLSyclQueueRef qRef = nullptr;
207✔
330
    qRef = DPCTLQueue_Create(cRef, dRef, handler, properties);
207✔
331
    return qRef;
207✔
332
}
207✔
333

334
} /* end of anonymous namespace */
335

336
DPCTL_API
337
__dpctl_give DPCTLSyclQueueRef
338
DPCTLQueue_Create(__dpctl_keep const DPCTLSyclContextRef CRef,
339
                  __dpctl_keep const DPCTLSyclDeviceRef DRef,
340
                  error_handler_callback *handler,
341
                  int properties)
342
{
1,857✔
343
    DPCTLSyclQueueRef q = nullptr;
1,857✔
344
    auto dev = unwrap<device>(DRef);
1,857✔
345
    auto ctx = unwrap<context>(CRef);
1,857✔
346

347
    if (!(dev && ctx)) {
1,857✔
348
        error_handler("Cannot create queue from DPCTLSyclContextRef and "
2✔
349
                      "DPCTLSyclDeviceRef as input is a nullptr.",
2✔
350
                      __FILE__, __func__, __LINE__);
2✔
351
        return q;
2✔
352
    }
2✔
353
    auto propList = create_property_list(properties);
1,855✔
354

355
    if (handler) {
1,855✔
356
        try {
68✔
357
            auto Queue = new queue(*ctx, *dev, DPCTL_AsyncErrorHandler(handler),
68✔
358
                                   *propList);
68✔
359
            q = wrap<queue>(Queue);
68✔
360
        } catch (std::exception const &e) {
68✔
361
            error_handler(e, __FILE__, __func__, __LINE__);
×
362
        }
×
363
    }
68✔
364
    else {
1,787✔
365
        try {
1,787✔
366
            auto Queue = new queue(*ctx, *dev, *propList);
1,787✔
367
            q = wrap<queue>(Queue);
1,787✔
368
        } catch (std::exception const &e) {
1,787✔
369
            error_handler(e, __FILE__, __func__, __LINE__);
1✔
370
        }
1✔
371
    }
1,787✔
372

373
    return q;
1,855✔
374
}
1,855✔
375

376
__dpctl_give DPCTLSyclQueueRef
377
DPCTLQueue_CreateForDevice(__dpctl_keep const DPCTLSyclDeviceRef DRef,
378
                           error_handler_callback *handler,
379
                           int properties)
380
{
489✔
381
    DPCTLSyclContextRef CRef = nullptr;
489✔
382
    DPCTLSyclQueueRef QRef = nullptr;
489✔
383
    auto Device = unwrap<device>(DRef);
489✔
384

385
    if (!Device) {
489✔
386
        error_handler("Cannot create queue from NULL device reference.",
282✔
387
                      __FILE__, __func__, __LINE__);
282✔
388
        return QRef;
282✔
389
    }
282✔
390
    // Check if a cached default context exists for the device.
391
    CRef = DPCTLDeviceMgr_GetCachedContext(DRef);
207✔
392
    // If a cached default context was found, that context will be used to use
393
    // create the new queue. When a default cached context was not found, as
394
    // will be the case for non-root devices, i.e., sub-devices, a new context
395
    // will be allocated. Note that any newly allocated context is not cached.
396
    if (!CRef) {
207!
397
        context *ContextPtr = nullptr;
×
398
        try {
×
399
            ContextPtr = new context(*Device);
×
400
            CRef = wrap<context>(ContextPtr);
×
401
        } catch (std::exception const &e) {
×
402
            error_handler(e, __FILE__, __func__, __LINE__);
×
403
            delete ContextPtr;
×
404
            return QRef;
×
405
        }
×
406
    }
×
407
    // At this point we have a valid context and the queue can be allocated.
408
    QRef = getQueueImpl(CRef, DRef, handler, properties);
207✔
409
    // Free the context
410
    DPCTLContext_Delete(CRef);
207✔
411
    return QRef;
207✔
412
}
207✔
413

414
/*!
415
 * Delete the passed in pointer after verifying it points to a sycl::queue.
416
 */
417
void DPCTLQueue_Delete(__dpctl_take DPCTLSyclQueueRef QRef)
418
{
2,247✔
419
    delete unwrap<queue>(QRef);
2,247✔
420
}
2,247✔
421

422
/*!
423
 * Make copy of sycl::queue referenced by passed pointer
424
 */
425
__dpctl_give DPCTLSyclQueueRef
426
DPCTLQueue_Copy(__dpctl_keep const DPCTLSyclQueueRef QRef)
427
{
116✔
428
    auto Queue = unwrap<queue>(QRef);
116✔
429
    if (Queue) {
116✔
430
        try {
115✔
431
            auto CopiedQueue = new queue(*Queue);
115✔
432
            return wrap<queue>(CopiedQueue);
115✔
433
        } catch (std::exception const &e) {
115✔
434
            error_handler(e, __FILE__, __func__, __LINE__);
×
435
            return nullptr;
×
436
        }
×
437
    }
115✔
438
    else {
1✔
439
        error_handler("Cannot copy DPCTLSyclQueueRef as input is a nullptr",
1✔
440
                      __FILE__, __func__, __LINE__);
1✔
441
        return nullptr;
1✔
442
    }
1✔
443
}
116✔
444

445
bool DPCTLQueue_AreEq(__dpctl_keep const DPCTLSyclQueueRef QRef1,
446
                      __dpctl_keep const DPCTLSyclQueueRef QRef2)
447
{
13✔
448
    if (!(QRef1 && QRef2)) {
13✔
449
        error_handler("DPCTLSyclQueueRefs are nullptr.", __FILE__, __func__,
2✔
450
                      __LINE__);
2✔
451
        return false;
2✔
452
    }
2✔
453
    return (*unwrap<queue>(QRef1) == *unwrap<queue>(QRef2));
11✔
454
}
13✔
455

456
DPCTLSyclBackendType DPCTLQueue_GetBackend(__dpctl_keep DPCTLSyclQueueRef QRef)
457
{
10✔
458
    auto Q = unwrap<queue>(QRef);
10✔
459
    if (Q) {
10✔
460
        try {
9✔
461
            auto C = Q->get_context();
9✔
462
            return DPCTLContext_GetBackend(wrap<context>(&C));
9✔
463
        } catch (std::exception const &e) {
9✔
464
            error_handler(e, __FILE__, __func__, __LINE__);
×
465
            return DPCTL_UNKNOWN_BACKEND;
×
466
        }
×
467
    }
9✔
468
    else
1✔
469
        return DPCTL_UNKNOWN_BACKEND;
1✔
470
}
10✔
471

472
__dpctl_give DPCTLSyclDeviceRef
473
DPCTLQueue_GetDevice(__dpctl_keep const DPCTLSyclQueueRef QRef)
474
{
74✔
475
    DPCTLSyclDeviceRef DRef = nullptr;
74✔
476
    auto Q = unwrap<queue>(QRef);
74✔
477
    if (Q) {
74✔
478
        try {
73✔
479
            auto Device = new device(Q->get_device());
73✔
480
            DRef = wrap<device>(Device);
73✔
481
        } catch (std::exception const &e) {
73✔
482
            error_handler(e, __FILE__, __func__, __LINE__);
×
483
        }
×
484
    }
73✔
485
    else {
1✔
486
        error_handler("Could not get the device for this queue.", __FILE__,
1✔
487
                      __func__, __LINE__);
1✔
488
    }
1✔
489
    return DRef;
74✔
490
}
74✔
491

492
__dpctl_give DPCTLSyclContextRef
493
DPCTLQueue_GetContext(__dpctl_keep const DPCTLSyclQueueRef QRef)
494
{
140✔
495
    auto Q = unwrap<queue>(QRef);
140✔
496
    DPCTLSyclContextRef CRef = nullptr;
140✔
497
    if (Q)
140✔
498
        CRef = wrap<context>(new context(Q->get_context()));
130✔
499
    else {
10✔
500
        error_handler("Could not get the context for this queue.", __FILE__,
10✔
501
                      __func__, __LINE__);
10✔
502
    }
10✔
503
    return CRef;
140✔
504
}
140✔
505

506
__dpctl_give DPCTLSyclEventRef
507
DPCTLQueue_SubmitRange(__dpctl_keep const DPCTLSyclKernelRef KRef,
508
                       __dpctl_keep const DPCTLSyclQueueRef QRef,
509
                       __dpctl_keep void **Args,
510
                       __dpctl_keep const DPCTLKernelArgType *ArgTypes,
511
                       size_t NArgs,
512
                       __dpctl_keep const size_t Range[3],
513
                       size_t NDims,
514
                       __dpctl_keep const DPCTLSyclEventRef *DepEvents,
515
                       size_t NDepEvents)
516
{
63✔
517
#ifndef __ADAPTIVECPP__
63✔
518
    auto Kernel = unwrap<kernel>(KRef);
63✔
519
    auto Queue = unwrap<queue>(QRef);
63✔
520
    event e;
63✔
521

522
    try {
63✔
523
        switch (NDims) {
63✔
524
        case 1:
29✔
525
        {
29✔
526
            e = Queue->submit([&](handler &cgh) {
29✔
527
                set_dependent_events(cgh, DepEvents, NDepEvents);
29✔
528
                set_kernel_args(cgh, Args, ArgTypes, NArgs);
29✔
529
                cgh.parallel_for(range<1>{Range[0]}, *Kernel);
29✔
530
            });
29✔
531
            return wrap<event>(new event(std::move(e)));
29✔
532
        }
×
533
        case 2:
17✔
534
        {
17✔
535
            e = Queue->submit([&](handler &cgh) {
17✔
536
                set_dependent_events(cgh, DepEvents, NDepEvents);
17✔
537
                set_kernel_args(cgh, Args, ArgTypes, NArgs);
17✔
538
                cgh.parallel_for(range<2>{Range[0], Range[1]}, *Kernel);
17✔
539
            });
17✔
540
            return wrap<event>(new event(std::move(e)));
17✔
541
        }
×
542
        case 3:
17✔
543
        {
17✔
544
            e = Queue->submit([&](handler &cgh) {
17✔
545
                set_dependent_events(cgh, DepEvents, NDepEvents);
17✔
546
                set_kernel_args(cgh, Args, ArgTypes, NArgs);
17✔
547
                cgh.parallel_for(range<3>{Range[0], Range[1], Range[2]},
17✔
548
                                 *Kernel);
17✔
549
            });
17✔
550
            return wrap<event>(new event(std::move(e)));
17✔
551
        }
×
552
        default:
×
NEW
553
            error_handler("Range cannot be greater than three dimensions.",
×
554
                          __FILE__, __func__, __LINE__, error_level::error);
×
555
            return nullptr;
×
556
        }
63✔
557
    } catch (std::exception const &e) {
63✔
558
        error_handler(e, __FILE__, __func__, __LINE__, error_level::error);
1✔
559
        return nullptr;
1✔
560
    } catch (...) {
1✔
561
        error_handler("Unknown exception encountered", __FILE__, __func__,
×
562
                      __LINE__, error_level::error);
×
563
        return nullptr;
×
564
    }
×
565
#else
566
    error_handler("Dynamic OpenCL-style kernel execution is not supported in "
567
                  "AdaptiveCpp.",
568
                  __FILE__, __func__, __LINE__, error_level::error);
569
    return nullptr;
570
#endif
571
}
63✔
572

573
__dpctl_give DPCTLSyclEventRef
574
DPCTLQueue_SubmitNDRange(__dpctl_keep const DPCTLSyclKernelRef KRef,
575
                         __dpctl_keep const DPCTLSyclQueueRef QRef,
576
                         __dpctl_keep void **Args,
577
                         __dpctl_keep const DPCTLKernelArgType *ArgTypes,
578
                         size_t NArgs,
579
                         __dpctl_keep const size_t gRange[3],
580
                         __dpctl_keep const size_t lRange[3],
581
                         size_t NDims,
582
                         __dpctl_keep const DPCTLSyclEventRef *DepEvents,
583
                         size_t NDepEvents)
584
{
114✔
585
#ifndef __ADAPTIVECPP__
114✔
586
    auto Kernel = unwrap<kernel>(KRef);
114✔
587
    auto Queue = unwrap<queue>(QRef);
114✔
588
    event e;
114✔
589

590
    try {
114✔
591
        switch (NDims) {
114✔
592
        case 1:
100✔
593
        {
100✔
594
            e = Queue->submit([&](handler &cgh) {
100✔
595
                set_dependent_events(cgh, DepEvents, NDepEvents);
100✔
596
                set_kernel_args(cgh, Args, ArgTypes, NArgs);
100✔
597
                cgh.parallel_for(nd_range<1>{{gRange[0]}, {lRange[0]}},
100✔
598
                                 *Kernel);
100✔
599
            });
100✔
600
            return wrap<event>(new event(std::move(e)));
100✔
601
        }
×
602
        case 2:
7✔
603
        {
7✔
604
            e = Queue->submit([&](handler &cgh) {
7✔
605
                set_dependent_events(cgh, DepEvents, NDepEvents);
7✔
606
                set_kernel_args(cgh, Args, ArgTypes, NArgs);
7✔
607
                cgh.parallel_for(
7✔
608
                    nd_range<2>{{gRange[0], gRange[1]}, {lRange[0], lRange[1]}},
7✔
609
                    *Kernel);
7✔
610
            });
7✔
611
            return wrap<event>(new event(std::move(e)));
7✔
612
        }
×
613
        case 3:
7✔
614
        {
7✔
615
            e = Queue->submit([&](handler &cgh) {
7✔
616
                set_dependent_events(cgh, DepEvents, NDepEvents);
7✔
617
                set_kernel_args(cgh, Args, ArgTypes, NArgs);
7✔
618
                cgh.parallel_for(nd_range<3>{{gRange[0], gRange[1], gRange[2]},
7✔
619
                                             {lRange[0], lRange[1], lRange[2]}},
7✔
620
                                 *Kernel);
7✔
621
            });
7✔
622
            return wrap<event>(new event(std::move(e)));
7✔
623
        }
×
624
        default:
×
NEW
625
            error_handler("Range cannot be greater than three dimensions.",
×
626
                          __FILE__, __func__, __LINE__, error_level::error);
×
627
            return nullptr;
×
628
        }
114✔
629
    } catch (std::exception const &e) {
114✔
630
        error_handler(e, __FILE__, __func__, __LINE__, error_level::error);
1✔
631
        return nullptr;
1✔
632
    } catch (...) {
1✔
633
        error_handler("Unknown exception encountered", __FILE__, __func__,
×
634
                      __LINE__, error_level::error);
×
635
        return nullptr;
×
636
    }
×
637
#else
638
    error_handler("Dynamic OpenCL-style kernel execution is not supported in "
639
                  "AdaptiveCpp.",
640
                  __FILE__, __func__, __LINE__, error_level::error);
641
    return nullptr;
642
#endif
643
}
114✔
644

645
void DPCTLQueue_Wait(__dpctl_keep DPCTLSyclQueueRef QRef)
646
{
1✔
647
    // \todo what happens if the QRef is null or a pointer to a valid sycl
648
    // queue
649
    if (QRef) {
1!
650
        auto SyclQueue = unwrap<queue>(QRef);
1✔
651
        if (SyclQueue)
1!
652
            SyclQueue->wait();
1✔
653
    }
1✔
654
    else {
×
655
        error_handler("Argument QRef is NULL.", __FILE__, __func__, __LINE__);
×
656
    }
×
657
}
1✔
658

659
__dpctl_give DPCTLSyclEventRef
660
DPCTLQueue_Memcpy(__dpctl_keep const DPCTLSyclQueueRef QRef,
661
                  void *Dest,
662
                  const void *Src,
663
                  size_t Count)
664
{
205✔
665
    auto Q = unwrap<queue>(QRef);
205✔
666
    if (Q) {
205✔
667
        sycl::event ev;
204✔
668
        try {
204✔
669
            ev = Q->memcpy(Dest, Src, Count);
204✔
670
        } catch (std::exception const &e) {
204✔
671
            error_handler(e, __FILE__, __func__, __LINE__);
8✔
672
            return nullptr;
8✔
673
        }
8✔
674
        return wrap<event>(new event(std::move(ev)));
196✔
675
    }
204✔
676
    else {
1✔
677
        error_handler("QRef passed to memcpy was NULL.", __FILE__, __func__,
1✔
678
                      __LINE__);
1✔
679
        return nullptr;
1✔
680
    }
1✔
681
}
205✔
682

683
__dpctl_give DPCTLSyclEventRef
684
DPCTLQueue_MemcpyWithEvents(__dpctl_keep const DPCTLSyclQueueRef QRef,
685
                            void *Dest,
686
                            const void *Src,
687
                            size_t Count,
688
                            const DPCTLSyclEventRef *DepEvents,
689
                            size_t DepEventsCount)
690
{
130✔
691
    event ev;
130✔
692
    auto Q = unwrap<queue>(QRef);
130✔
693
    if (Q) {
130✔
694
        try {
129✔
695
            ev = Q->submit([&](handler &cgh) {
129✔
696
                if (DepEvents)
129✔
697
                    for (size_t i = 0; i < DepEventsCount; ++i) {
302✔
698
                        event *ei = unwrap<event>(DepEvents[i]);
181✔
699
                        if (ei)
181!
700
                            cgh.depends_on(*ei);
181✔
701
                    }
181✔
702

703
                cgh.memcpy(Dest, Src, Count);
129✔
704
            });
129✔
705
        } catch (const std::exception &ex) {
129✔
706
            error_handler(ex, __FILE__, __func__, __LINE__);
8✔
707
            return nullptr;
8✔
708
        }
8✔
709
    }
129✔
710
    else {
1✔
711
        error_handler("QRef passed to memcpy was NULL.", __FILE__, __func__,
1✔
712
                      __LINE__);
1✔
713
        return nullptr;
1✔
714
    }
1✔
715

716
    return wrap<event>(new event(ev));
121✔
717
}
130✔
718

719
__dpctl_give DPCTLSyclEventRef
720
DPCTLQueue_CopyData(__dpctl_keep const DPCTLSyclQueueRef QRef,
721
                    void *Dest,
722
                    const void *Src,
723
                    size_t Count)
724
{
51✔
725
    auto Q = unwrap<queue>(QRef);
51✔
726
    if (Q) {
51✔
727
        sycl::event ev;
50✔
728
        try {
50✔
729
            // Copy uint8_t elements (1 byte each), so Count is a byte count.
730
            ev = Q->copy(static_cast<const std::uint8_t *>(Src),
50✔
731
                         static_cast<std::uint8_t *>(Dest), Count);
50✔
732
        } catch (std::exception const &e) {
50✔
733
            error_handler(e, __FILE__, __func__, __LINE__);
8✔
734
            return nullptr;
8✔
735
        }
8✔
736
        return wrap<event>(new event(std::move(ev)));
42✔
737
    }
50✔
738
    else {
1✔
739
        error_handler("QRef passed to copy was NULL.", __FILE__, __func__,
1✔
740
                      __LINE__);
1✔
741
        return nullptr;
1✔
742
    }
1✔
743
}
51✔
744

745
__dpctl_give DPCTLSyclEventRef
746
DPCTLQueue_CopyDataWithEvents(__dpctl_keep const DPCTLSyclQueueRef QRef,
747
                              void *Dest,
748
                              const void *Src,
749
                              size_t Count,
750
                              const DPCTLSyclEventRef *DepEvents,
751
                              size_t DepEventsCount)
752
{
10✔
753
    auto Q = unwrap<queue>(QRef);
10✔
754
    if (Q) {
10✔
755
        try {
9✔
756
            std::vector<event> dep_events;
9✔
757
            if (DepEvents) {
9✔
758
                dep_events.reserve(DepEventsCount);
1✔
759
                for (size_t i = 0; i < DepEventsCount; ++i) {
2✔
760
                    event *ei = unwrap<event>(DepEvents[i]);
1✔
761
                    if (ei)
1!
762
                        dep_events.push_back(*ei);
1✔
763
                }
1✔
764
            }
1✔
765

766
            // Copy uint8_t elements (1 byte each), so Count is a byte count.
767
            auto ev =
9✔
768
                Q->copy(static_cast<const std::uint8_t *>(Src),
9✔
769
                        static_cast<std::uint8_t *>(Dest), Count, dep_events);
9✔
770
            return wrap<event>(new event(std::move(ev)));
9✔
771
        } catch (const std::exception &ex) {
9✔
772
            error_handler(ex, __FILE__, __func__, __LINE__);
8✔
773
            return nullptr;
8✔
774
        }
8✔
775
    }
9✔
776
    else {
1✔
777
        error_handler("QRef passed to copy was NULL.", __FILE__, __func__,
1✔
778
                      __LINE__);
1✔
779
        return nullptr;
1✔
780
    }
1✔
781
}
10✔
782

783
__dpctl_give DPCTLSyclEventRef
784
DPCTLQueue_Prefetch(__dpctl_keep DPCTLSyclQueueRef QRef,
785
                    const void *Ptr,
786
                    size_t Count)
787
{
16✔
788
    auto Q = unwrap<queue>(QRef);
16✔
789
    if (Q) {
16✔
790
        if (Ptr) {
15✔
791
            sycl::event ev;
7✔
792
            try {
7✔
793
                ev = Q->prefetch(Ptr, Count);
7✔
794
            } catch (std::exception const &e) {
7✔
795
                error_handler(e, __FILE__, __func__, __LINE__);
×
796
                return nullptr;
×
797
            }
×
798
            return wrap<event>(new event(std::move(ev)));
7✔
799
        }
7✔
800
        else {
8✔
801
            error_handler("Attempt to prefetch USM-allocation at nullptr.",
8✔
802
                          __FILE__, __func__, __LINE__);
8✔
803
            return nullptr;
8✔
804
        }
8✔
805
    }
15✔
806
    else {
1✔
807
        error_handler("QRef passed to prefetch was NULL.", __FILE__, __func__,
1✔
808
                      __LINE__);
1✔
809
        return nullptr;
1✔
810
    }
1✔
811
}
16✔
812

813
__dpctl_give DPCTLSyclEventRef
814
DPCTLQueue_MemAdvise(__dpctl_keep DPCTLSyclQueueRef QRef,
815
                     const void *Ptr,
816
                     size_t Count,
817
                     int Advice)
818
{
16✔
819
    auto Q = unwrap<queue>(QRef);
16✔
820
    if (Q) {
16✔
821
        sycl::event ev;
15✔
822
        try {
15✔
823
            ev = Q->mem_advise(Ptr, Count, Advice);
15✔
824
        } catch (std::exception const &e) {
15✔
825
            error_handler(e, __FILE__, __func__, __LINE__);
×
826
            return nullptr;
×
827
        }
×
828
        return wrap<event>(new event(std::move(ev)));
15✔
829
    }
15✔
830
    else {
1✔
831
        error_handler("QRef passed to prefetch was NULL.", __FILE__, __func__,
1✔
832
                      __LINE__);
1✔
833
        return nullptr;
1✔
834
    }
1✔
835
}
16✔
836

837
bool DPCTLQueue_IsInOrder(__dpctl_keep const DPCTLSyclQueueRef QRef)
838
{
1,040✔
839
    auto Q = unwrap<queue>(QRef);
1,040✔
840
    if (Q) {
1,040✔
841
        return Q->is_in_order();
1,039✔
842
    }
1,039✔
843
    else
1✔
844
        return false;
1✔
845
}
1,040✔
846

847
bool DPCTLQueue_HasEnableProfiling(__dpctl_keep const DPCTLSyclQueueRef QRef)
848
{
67✔
849
    auto Q = unwrap<queue>(QRef);
67✔
850
    if (Q) {
67✔
851
        return Q->has_property<sycl::property::queue::enable_profiling>();
66✔
852
    }
66✔
853
    else
1✔
854
        return false;
1✔
855
}
67✔
856

857
size_t DPCTLQueue_Hash(__dpctl_keep const DPCTLSyclQueueRef QRef)
858
{
30✔
859
    auto Q = unwrap<queue>(QRef);
30✔
860
    if (Q) {
30✔
861
        std::hash<queue> hash_fn;
27✔
862
        return hash_fn(*Q);
27✔
863
    }
27✔
864
    else {
3✔
865
        error_handler("Argument QRef is NULL.", __FILE__, __func__, __LINE__);
3✔
866
        return 0;
3✔
867
    }
3✔
868
}
30✔
869

870
__dpctl_give DPCTLSyclEventRef DPCTLQueue_SubmitBarrierForEvents(
871
    __dpctl_keep const DPCTLSyclQueueRef QRef,
872
    __dpctl_keep const DPCTLSyclEventRef *DepEvents,
873
    size_t NDepEvents)
874
{
111✔
875
    auto Q = unwrap<queue>(QRef);
111✔
876
    event e;
111✔
877
    if (Q) {
111!
878
        try {
111✔
879
            e = Q->submit([&](handler &cgh) {
111✔
880
                // Depend on any event that was specified by the caller.
881
                if (NDepEvents)
111✔
882
                    for (auto i = 0ul; i < NDepEvents; ++i)
18✔
883
                        cgh.depends_on(*unwrap<event>(DepEvents[i]));
12✔
884

885
#ifndef __ADAPTIVECPP__
111✔
886
                cgh.ext_oneapi_barrier();
111✔
887
#else
888
                class dpctl_barrier_task;
889
                cgh.single_task<dpctl_barrier_task>([=]() {});
890
#endif
891
            });
111✔
892
        } catch (std::exception const &e) {
111✔
893
            error_handler(e, __FILE__, __func__, __LINE__);
×
894
            return nullptr;
×
895
        }
×
896

897
        return wrap<event>(new event(std::move(e)));
111✔
898
    }
111✔
899
    else {
×
900
        error_handler("Argument QRef is NULL", __FILE__, __func__, __LINE__);
×
901
        return nullptr;
×
902
    }
×
903
}
111✔
904

905
__dpctl_give DPCTLSyclEventRef
906
DPCTLQueue_SubmitBarrier(__dpctl_keep const DPCTLSyclQueueRef QRef)
907
{
1✔
908
    return DPCTLQueue_SubmitBarrierForEvents(QRef, nullptr, 0);
1✔
909
}
1✔
910

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

935
__dpctl_give DPCTLSyclEventRef
936
DPCTLQueue_MemsetWithEvents(__dpctl_keep const DPCTLSyclQueueRef QRef,
937
                            void *USMRef,
938
                            uint8_t Value,
939
                            size_t Count,
940
                            const DPCTLSyclEventRef *DepEvents,
941
                            size_t DepEventsCount)
942
{
10✔
943
    event ev;
10✔
944
    auto Q = unwrap<queue>(QRef);
10✔
945
    if (Q && USMRef) {
10!
946
        try {
9✔
947
            ev = Q->submit([&](handler &cgh) {
9✔
948
                if (DepEvents)
9!
949
                    for (size_t i = 0; i < DepEventsCount; ++i) {
18✔
950
                        event *ei = unwrap<event>(DepEvents[i]);
9✔
951
                        if (ei)
9!
952
                            cgh.depends_on(*ei);
9✔
953
                    }
9✔
954

955
                cgh.memset(USMRef, static_cast<int>(Value), Count);
9✔
956
            });
9✔
957
        } catch (const std::exception &ex) {
9✔
958
            error_handler(ex, __FILE__, __func__, __LINE__);
×
959
            return nullptr;
×
960
        }
×
961
    }
9✔
962
    else {
1✔
963
        error_handler("QRef or USMRef passed to memset_async were NULL.",
1✔
964
                      __FILE__, __func__, __LINE__);
1✔
965
        return nullptr;
1✔
966
    }
1✔
967

968
    return wrap<event>(new event(std::move(ev)));
9✔
969
}
10✔
970

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

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

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

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

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

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

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

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

1207
__dpctl_give DPCTLSyclEventRef
1208
DPCTLQueue_Fill128(__dpctl_keep const DPCTLSyclQueueRef QRef,
1209
                   void *USMRef,
1210
                   uint64_t *Value,
1211
                   size_t Count)
1212
{
29✔
1213
    auto Q = unwrap<queue>(QRef);
29✔
1214
    if (Q && USMRef && Value) {
29!
1215
        sycl::event ev;
20✔
1216
        try {
20✔
1217
            complexNumber Val;
20✔
1218
            Val.real = Value[0];
20✔
1219
            Val.imag = Value[1];
20✔
1220
            ev = Q->fill(USMRef, Val, Count);
20✔
1221
        } catch (std::exception const &e) {
20✔
1222
            error_handler(e, __FILE__, __func__, __LINE__);
×
1223
            return nullptr;
×
1224
        }
×
1225
        return wrap<event>(new event(std::move(ev)));
20✔
1226
    }
20✔
1227
    else {
9✔
1228
        error_handler("QRef, USMRef, or Value passed to fill128 were NULL.",
9✔
1229
                      __FILE__, __func__, __LINE__);
9✔
1230
        return nullptr;
9✔
1231
    }
9✔
1232
}
29✔
1233

1234
__dpctl_give DPCTLSyclEventRef
1235
DPCTLQueue_Fill128WithEvents(__dpctl_keep const DPCTLSyclQueueRef QRef,
1236
                             void *USMRef,
1237
                             uint64_t *Value,
1238
                             size_t Count,
1239
                             const DPCTLSyclEventRef *DepEvents,
1240
                             size_t DepEventsCount)
1241
{
17✔
1242
    auto Q = unwrap<queue>(QRef);
17✔
1243
    if (Q && USMRef && Value) {
17!
1244
        sycl::event ev;
8✔
1245
        try {
8✔
1246
            std::vector<event> dep_events;
8✔
1247
            if (DepEvents) {
8!
1248
                dep_events.reserve(DepEventsCount);
8✔
1249
                for (size_t i = 0; i < DepEventsCount; ++i) {
16✔
1250
                    event *ei = unwrap<event>(DepEvents[i]);
8✔
1251
                    if (ei)
8!
1252
                        dep_events.push_back(*ei);
8✔
1253
                }
8✔
1254
            }
8✔
1255
            complexNumber Val;
8✔
1256
            Val.real = Value[0];
8✔
1257
            Val.imag = Value[1];
8✔
1258
            ev = Q->fill(USMRef, Val, Count, dep_events);
8✔
1259
        } catch (std::exception const &e) {
8✔
1260
            error_handler(e, __FILE__, __func__, __LINE__);
×
1261
            return nullptr;
×
1262
        }
×
1263
        return wrap<event>(new event(std::move(ev)));
8✔
1264
    }
8✔
1265
    else {
9✔
1266
        error_handler(
9✔
1267
            "QRef, USMRef, or Value passed to fill128_async were NULL.",
9✔
1268
            __FILE__, __func__, __LINE__);
9✔
1269
        return nullptr;
9✔
1270
    }
9✔
1271
}
17✔
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