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

IntelPython / dpctl / 6003885775

28 Aug 2023 07:06PM UTC coverage: 85.635% (+0.009%) from 85.626%
6003885775

push

github

web-flow
Merge pull request #1374 from IntelPython/coverity-floor-divide-operands-do-not-affect-results

Addressed Coverity issue about handling bools in floor_divide

2339 of 2766 branches covered (0.0%)

Branch coverage included in aggregate %.

8481 of 9869 relevant lines covered (85.94%)

7956.8 hits per line

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

82.02
/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-2022 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
#include <CL/sycl.hpp> /* SYCL headers   */
35
#include <exception>
36
#include <stdexcept>
37

38
using namespace sycl;
39

40
namespace
41
{
42
static_assert(__SYCL_COMPILER_VERSION >= __SYCL_COMPILER_VERSION_REQUIRED,
43
              "The compiler does not meet minimum version requirement");
44

45
using namespace dpctl::syclinterface;
46

47
typedef struct complex
48
{
49
    uint64_t real;
50
    uint64_t imag;
51
} complexNumber;
52

53
/*!
54
 * @brief Set the kernel arg object
55
 *
56
 * @param    cgh            My Param doc
57
 * @param    Arg            My Param doc
58
 */
59
bool set_kernel_arg(handler &cgh,
60
                    size_t idx,
61
                    __dpctl_keep void *Arg,
62
                    DPCTLKernelArgType ArgTy)
63
{
189✔
64
    bool arg_set = true;
189✔
65

66
    switch (ArgTy) {
189✔
67
    case DPCTL_CHAR:
×
68
        cgh.set_arg(idx, *(char *)Arg);
×
69
        break;
×
70
    case DPCTL_SIGNED_CHAR:
×
71
        cgh.set_arg(idx, *(signed char *)Arg);
×
72
        break;
×
73
    case DPCTL_UNSIGNED_CHAR:
×
74
        cgh.set_arg(idx, *(unsigned char *)Arg);
×
75
        break;
×
76
    case DPCTL_SHORT:
6✔
77
        cgh.set_arg(idx, *(short *)Arg);
6✔
78
        break;
6✔
79
    case DPCTL_INT:
6✔
80
        cgh.set_arg(idx, *(int *)Arg);
6✔
81
        break;
6✔
82
    case DPCTL_UNSIGNED_INT:
8✔
83
        cgh.set_arg(idx, *(unsigned int *)Arg);
8✔
84
        break;
8✔
85
    case DPCTL_UNSIGNED_INT8:
×
86
        cgh.set_arg(idx, *(uint8_t *)Arg);
×
87
        break;
×
88
    case DPCTL_LONG:
6✔
89
        cgh.set_arg(idx, *(long *)Arg);
6✔
90
        break;
6✔
91
    case DPCTL_UNSIGNED_LONG:
6✔
92
        cgh.set_arg(idx, *(unsigned long *)Arg);
6✔
93
        break;
6✔
94
    case DPCTL_LONG_LONG:
×
95
        cgh.set_arg(idx, *(long long *)Arg);
×
96
        break;
×
97
    case DPCTL_UNSIGNED_LONG_LONG:
×
98
        cgh.set_arg(idx, *(unsigned long long *)Arg);
×
99
        break;
×
100
    case DPCTL_SIZE_T:
×
101
        cgh.set_arg(idx, *(size_t *)Arg);
×
102
        break;
×
103
    case DPCTL_FLOAT:
8✔
104
        cgh.set_arg(idx, *(float *)Arg);
8✔
105
        break;
8✔
106
    case DPCTL_DOUBLE:
6✔
107
        cgh.set_arg(idx, *(double *)Arg);
6✔
108
        break;
6✔
109
    case DPCTL_LONG_DOUBLE:
×
110
        cgh.set_arg(idx, *(long double *)Arg);
×
111
        break;
×
112
    case DPCTL_VOID_PTR:
143✔
113
        cgh.set_arg(idx, Arg);
143✔
114
        break;
143✔
115
    default:
×
116
        arg_set = false;
×
117
        error_handler("Kernel argument could not be created.", __FILE__,
×
118
                      __func__, __LINE__);
×
119
        break;
×
120
    }
189✔
121
    return arg_set;
189✔
122
}
189✔
123

124
std::unique_ptr<property_list> create_property_list(int properties)
125
{
25,728✔
126
    std::unique_ptr<property_list> propList;
25,728✔
127
    int _prop = properties;
25,728✔
128
    if (_prop & DPCTL_ENABLE_PROFILING) {
25,728✔
129
        _prop = _prop ^ DPCTL_ENABLE_PROFILING;
56✔
130
        if (_prop & DPCTL_IN_ORDER) {
56✔
131
            _prop = _prop ^ DPCTL_IN_ORDER;
22✔
132
            propList = std::make_unique<property_list>(
22✔
133
                sycl::property::queue::enable_profiling(),
22✔
134
                sycl::property::queue::in_order());
22✔
135
        }
22✔
136
        else {
34✔
137
            propList = std::make_unique<property_list>(
34✔
138
                sycl::property::queue::enable_profiling());
34✔
139
        }
34✔
140
    }
56✔
141
    else if (_prop & DPCTL_IN_ORDER) {
25,672✔
142
        _prop = _prop ^ DPCTL_IN_ORDER;
417✔
143
        propList =
417✔
144
            std::make_unique<property_list>(sycl::property::queue::in_order());
417✔
145
    }
417✔
146
    else {
25,255✔
147
        propList = std::make_unique<property_list>();
25,255✔
148
    }
25,255✔
149

150
    if (_prop) {
25,728✔
151
        std::stringstream ss;
1✔
152
        ss << "Invalid queue property argument (" << std::hex << properties
1✔
153
           << "), interpreted as (" << (properties ^ _prop) << ").";
1✔
154
        error_handler(ss.str(), __FILE__, __func__, __LINE__);
1✔
155
    }
1✔
156
    return propList;
25,728✔
157
}
25,728✔
158

159
__dpctl_give DPCTLSyclQueueRef
160
getQueueImpl(__dpctl_keep DPCTLSyclContextRef cRef,
161
             __dpctl_keep DPCTLSyclDeviceRef dRef,
162
             error_handler_callback *handler,
163
             int properties)
164
{
107✔
165
    DPCTLSyclQueueRef qRef = nullptr;
107✔
166
    qRef = DPCTLQueue_Create(cRef, dRef, handler, properties);
107✔
167
    return qRef;
107✔
168
}
107✔
169

170
} /* end of anonymous namespace */
171

172
DPCTL_API
173
__dpctl_give DPCTLSyclQueueRef
174
DPCTLQueue_Create(__dpctl_keep const DPCTLSyclContextRef CRef,
175
                  __dpctl_keep const DPCTLSyclDeviceRef DRef,
176
                  error_handler_callback *handler,
177
                  int properties)
178
{
25,728✔
179
    DPCTLSyclQueueRef q = nullptr;
25,728✔
180
    auto dev = unwrap<device>(DRef);
25,728✔
181
    auto ctx = unwrap<context>(CRef);
25,728✔
182

183
    if (!(dev && ctx)) {
25,728!
184
        error_handler("Cannot create queue from DPCTLSyclContextRef and "
×
185
                      "DPCTLSyclDeviceRef as input is a nullptr.",
×
186
                      __FILE__, __func__, __LINE__);
×
187
        return q;
×
188
    }
×
189
    auto propList = create_property_list(properties);
25,728✔
190

191
    if (handler) {
25,728✔
192
        try {
25,647✔
193
            auto Queue = new queue(*ctx, *dev, DPCTL_AsyncErrorHandler(handler),
25,647✔
194
                                   *propList);
25,647✔
195
            q = wrap<queue>(Queue);
25,647✔
196
        } catch (std::exception const &e) {
25,647✔
197
            error_handler(e, __FILE__, __func__, __LINE__);
1✔
198
        }
1✔
199
    }
25,647✔
200
    else {
81✔
201
        try {
81✔
202
            auto Queue = new queue(*ctx, *dev, *propList);
81✔
203
            q = wrap<queue>(Queue);
81✔
204
        } catch (std::exception const &e) {
81✔
205
            error_handler(e, __FILE__, __func__, __LINE__);
×
206
        }
×
207
    }
81✔
208

209
    return q;
25,728✔
210
}
25,728✔
211

212
__dpctl_give DPCTLSyclQueueRef
213
DPCTLQueue_CreateForDevice(__dpctl_keep const DPCTLSyclDeviceRef DRef,
214
                           error_handler_callback *handler,
215
                           int properties)
216
{
277✔
217
    DPCTLSyclContextRef CRef = nullptr;
277✔
218
    DPCTLSyclQueueRef QRef = nullptr;
277✔
219
    auto Device = unwrap<device>(DRef);
277✔
220

221
    if (!Device) {
277✔
222
        error_handler("Cannot create queue from NULL device reference.",
170✔
223
                      __FILE__, __func__, __LINE__);
170✔
224
        return QRef;
170✔
225
    }
170✔
226
    // Check if a cached default context exists for the device.
227
    CRef = DPCTLDeviceMgr_GetCachedContext(DRef);
107✔
228
    // If a cached default context was found, that context will be used to use
229
    // create the new queue. When a default cached context was not found, as
230
    // will be the case for non-root devices, i.e., sub-devices, a new context
231
    // will be allocated. Note that any newly allocated context is not cached.
232
    if (!CRef) {
107✔
233
        context *ContextPtr = nullptr;
1✔
234
        try {
1✔
235
            ContextPtr = new context(*Device);
1✔
236
            CRef = wrap<context>(ContextPtr);
1✔
237
        } catch (std::exception const &e) {
1✔
238
            error_handler(e, __FILE__, __func__, __LINE__);
×
239
            delete ContextPtr;
×
240
            return QRef;
×
241
        }
×
242
    }
1✔
243
    // At this point we have a valid context and the queue can be allocated.
244
    QRef = getQueueImpl(CRef, DRef, handler, properties);
107✔
245
    // Free the context
246
    DPCTLContext_Delete(CRef);
107✔
247
    return QRef;
107✔
248
}
107✔
249

250
/*!
251
 * Delete the passed in pointer after verifying it points to a sycl::queue.
252
 */
253
void DPCTLQueue_Delete(__dpctl_take DPCTLSyclQueueRef QRef)
254
{
191,145✔
255
    delete unwrap<queue>(QRef);
191,145✔
256
}
191,145✔
257

258
/*!
259
 * Make copy of sycl::queue referenced by passed pointer
260
 */
261
__dpctl_give DPCTLSyclQueueRef
262
DPCTLQueue_Copy(__dpctl_keep const DPCTLSyclQueueRef QRef)
263
{
405,222✔
264
    auto Queue = unwrap<queue>(QRef);
405,222✔
265
    if (Queue) {
405,222✔
266
        try {
405,221✔
267
            auto CopiedQueue = new queue(*Queue);
405,221✔
268
            return wrap<queue>(CopiedQueue);
405,221✔
269
        } catch (std::exception const &e) {
405,221✔
270
            error_handler(e, __FILE__, __func__, __LINE__);
×
271
            return nullptr;
×
272
        }
×
273
    }
405,221✔
274
    else {
1✔
275
        error_handler("Cannot copy DPCTLSyclQueueRef as input is a nullptr",
1✔
276
                      __FILE__, __func__, __LINE__);
1✔
277
        return nullptr;
1✔
278
    }
1✔
279
}
405,222✔
280

281
bool DPCTLQueue_AreEq(__dpctl_keep const DPCTLSyclQueueRef QRef1,
282
                      __dpctl_keep const DPCTLSyclQueueRef QRef2)
283
{
22,878✔
284
    if (!(QRef1 && QRef2)) {
22,878✔
285
        error_handler("DPCTLSyclQueueRefs are nullptr.", __FILE__, __func__,
2✔
286
                      __LINE__);
2✔
287
        return false;
2✔
288
    }
2✔
289
    return (*unwrap<queue>(QRef1) == *unwrap<queue>(QRef2));
22,876✔
290
}
22,878✔
291

292
DPCTLSyclBackendType DPCTLQueue_GetBackend(__dpctl_keep DPCTLSyclQueueRef QRef)
293
{
11✔
294
    auto Q = unwrap<queue>(QRef);
11✔
295
    if (Q) {
11✔
296
        try {
10✔
297
            auto C = Q->get_context();
10✔
298
            return DPCTLContext_GetBackend(wrap<context>(&C));
10✔
299
        } catch (std::exception const &e) {
10✔
300
            error_handler(e, __FILE__, __func__, __LINE__);
×
301
            return DPCTL_UNKNOWN_BACKEND;
×
302
        }
×
303
    }
10✔
304
    else
1✔
305
        return DPCTL_UNKNOWN_BACKEND;
1✔
306
}
11✔
307

308
__dpctl_give DPCTLSyclDeviceRef
309
DPCTLQueue_GetDevice(__dpctl_keep const DPCTLSyclQueueRef QRef)
310
{
82,639✔
311
    DPCTLSyclDeviceRef DRef = nullptr;
82,639✔
312
    auto Q = unwrap<queue>(QRef);
82,639✔
313
    if (Q) {
82,639✔
314
        try {
82,638✔
315
            auto Device = new device(Q->get_device());
82,638✔
316
            DRef = wrap<device>(Device);
82,638✔
317
        } catch (std::exception const &e) {
82,638✔
318
            error_handler(e, __FILE__, __func__, __LINE__);
×
319
        }
×
320
    }
82,638✔
321
    else {
1✔
322
        error_handler("Could not get the device for this queue.", __FILE__,
1✔
323
                      __func__, __LINE__);
1✔
324
    }
1✔
325
    return DRef;
82,639✔
326
}
82,639✔
327

328
__dpctl_give DPCTLSyclContextRef
329
DPCTLQueue_GetContext(__dpctl_keep const DPCTLSyclQueueRef QRef)
330
{
84,313✔
331
    auto Q = unwrap<queue>(QRef);
84,313✔
332
    DPCTLSyclContextRef CRef = nullptr;
84,313✔
333
    if (Q)
84,313✔
334
        CRef = wrap<context>(new context(Q->get_context()));
84,303✔
335
    else {
10✔
336
        error_handler("Could not get the context for this queue.", __FILE__,
10✔
337
                      __func__, __LINE__);
10✔
338
    }
10✔
339
    return CRef;
84,313✔
340
}
84,313✔
341

342
__dpctl_give DPCTLSyclEventRef
343
DPCTLQueue_SubmitRange(__dpctl_keep const DPCTLSyclKernelRef KRef,
344
                       __dpctl_keep const DPCTLSyclQueueRef QRef,
345
                       __dpctl_keep void **Args,
346
                       __dpctl_keep const DPCTLKernelArgType *ArgTypes,
347
                       size_t NArgs,
348
                       __dpctl_keep const size_t Range[3],
349
                       size_t NDims,
350
                       __dpctl_keep const DPCTLSyclEventRef *DepEvents,
351
                       size_t NDepEvents)
352
{
31✔
353
    auto Kernel = unwrap<kernel>(KRef);
31✔
354
    auto Queue = unwrap<queue>(QRef);
31✔
355
    event e;
31✔
356

357
    try {
31✔
358
        e = Queue->submit([&](handler &cgh) {
31✔
359
            // Depend on any event that was specified by the caller.
360
            if (NDepEvents)
31✔
361
                for (auto i = 0ul; i < NDepEvents; ++i)
7✔
362
                    cgh.depends_on(*unwrap<event>(DepEvents[i]));
4✔
363

364
            for (auto i = 0ul; i < NArgs; ++i) {
132✔
365
                // \todo add support for Sycl buffers
366
                if (!set_kernel_arg(cgh, i, Args[i], ArgTypes[i]))
101!
367
                    exit(1);
×
368
            }
101✔
369
            switch (NDims) {
31✔
370
            case 1:
17✔
371
                cgh.parallel_for(range<1>{Range[0]}, *Kernel);
17✔
372
                break;
17✔
373
            case 2:
7✔
374
                cgh.parallel_for(range<2>{Range[0], Range[1]}, *Kernel);
7✔
375
                break;
7✔
376
            case 3:
7✔
377
                cgh.parallel_for(range<3>{Range[0], Range[1], Range[2]},
7✔
378
                                 *Kernel);
7✔
379
                break;
7✔
380
            default:
×
381
                throw std::runtime_error("Range cannot be greater than three "
×
382
                                         "dimensions.");
×
383
            }
31✔
384
        });
31✔
385
    } catch (std::exception const &e) {
31✔
386
        error_handler(e, __FILE__, __func__, __LINE__);
×
387
        return nullptr;
×
388
    }
×
389

390
    return wrap<event>(new event(e));
31✔
391
}
31✔
392

393
__dpctl_give DPCTLSyclEventRef
394
DPCTLQueue_SubmitNDRange(__dpctl_keep const DPCTLSyclKernelRef KRef,
395
                         __dpctl_keep const DPCTLSyclQueueRef QRef,
396
                         __dpctl_keep void **Args,
397
                         __dpctl_keep const DPCTLKernelArgType *ArgTypes,
398
                         size_t NArgs,
399
                         __dpctl_keep const size_t gRange[3],
400
                         __dpctl_keep const size_t lRange[3],
401
                         size_t NDims,
402
                         __dpctl_keep const DPCTLSyclEventRef *DepEvents,
403
                         size_t NDepEvents)
404
{
22✔
405
    auto Kernel = unwrap<kernel>(KRef);
22✔
406
    auto Queue = unwrap<queue>(QRef);
22✔
407
    event e;
22✔
408

409
    try {
22✔
410
        e = Queue->submit([&](handler &cgh) {
22✔
411
            // Depend on any event that was specified by the caller.
412
            if (NDepEvents)
22!
413
                for (auto i = 0ul; i < NDepEvents; ++i)
44✔
414
                    cgh.depends_on(*unwrap<event>(DepEvents[i]));
22✔
415

416
            for (auto i = 0ul; i < NArgs; ++i) {
110✔
417
                // \todo add support for Sycl buffers
418
                if (!set_kernel_arg(cgh, i, Args[i], ArgTypes[i]))
88!
419
                    exit(1);
×
420
            }
88✔
421
            switch (NDims) {
22✔
422
            case 1:
7✔
423
                cgh.parallel_for(nd_range<1>{{gRange[0]}, {lRange[0]}},
7✔
424
                                 *Kernel);
7✔
425
                break;
7✔
426
            case 2:
7✔
427
                cgh.parallel_for(
7✔
428
                    nd_range<2>{{gRange[0], gRange[1]}, {lRange[0], lRange[1]}},
7✔
429
                    *Kernel);
7✔
430
                break;
7✔
431
            case 3:
8✔
432
                cgh.parallel_for(nd_range<3>{{gRange[0], gRange[1], gRange[2]},
8✔
433
                                             {lRange[0], lRange[1], lRange[2]}},
8✔
434
                                 *Kernel);
8✔
435
                break;
8✔
436
            default:
×
437
                throw std::runtime_error("Range cannot be greater than three "
×
438
                                         "dimensions.");
×
439
            }
22✔
440
        });
22✔
441
    } catch (std::exception const &e) {
22✔
442
        error_handler(e, __FILE__, __func__, __LINE__);
×
443
        return nullptr;
×
444
    }
×
445

446
    return wrap<event>(new event(e));
22✔
447
}
22✔
448

449
void DPCTLQueue_Wait(__dpctl_keep DPCTLSyclQueueRef QRef)
450
{
3✔
451
    // \todo what happens if the QRef is null or a pointer to a valid sycl
452
    // queue
453
    if (QRef) {
3!
454
        auto SyclQueue = unwrap<queue>(QRef);
3✔
455
        if (SyclQueue)
3!
456
            SyclQueue->wait();
3✔
457
    }
3✔
458
    else {
×
459
        error_handler("Argument QRef is NULL.", __FILE__, __func__, __LINE__);
×
460
    }
×
461
}
3✔
462

463
__dpctl_give DPCTLSyclEventRef
464
DPCTLQueue_Memcpy(__dpctl_keep const DPCTLSyclQueueRef QRef,
465
                  void *Dest,
466
                  const void *Src,
467
                  size_t Count)
468
{
81,030✔
469
    auto Q = unwrap<queue>(QRef);
81,030✔
470
    if (Q) {
81,030✔
471
        sycl::event ev;
81,029✔
472
        try {
81,029✔
473
            ev = Q->memcpy(Dest, Src, Count);
81,029✔
474
        } catch (std::exception const &e) {
81,029✔
475
            error_handler(e, __FILE__, __func__, __LINE__);
8✔
476
            return nullptr;
8✔
477
        }
8✔
478
        return wrap<event>(new event(ev));
81,021✔
479
    }
81,029✔
480
    else {
1✔
481
        error_handler("QRef passed to memcpy was NULL.", __FILE__, __func__,
1✔
482
                      __LINE__);
1✔
483
        return nullptr;
1✔
484
    }
1✔
485
}
81,030✔
486

487
__dpctl_give DPCTLSyclEventRef
488
DPCTLQueue_Prefetch(__dpctl_keep DPCTLSyclQueueRef QRef,
489
                    const void *Ptr,
490
                    size_t Count)
491
{
16✔
492
    auto Q = unwrap<queue>(QRef);
16✔
493
    if (Q) {
16✔
494
        if (Ptr) {
15✔
495
            sycl::event ev;
7✔
496
            try {
7✔
497
                ev = Q->prefetch(Ptr, Count);
7✔
498
            } catch (std::exception const &e) {
7✔
499
                error_handler(e, __FILE__, __func__, __LINE__);
×
500
                return nullptr;
×
501
            }
×
502
            return wrap<event>(new event(ev));
7✔
503
        }
7✔
504
        else {
8✔
505
            error_handler("Attempt to prefetch USM-allocation at nullptr.",
8✔
506
                          __FILE__, __func__, __LINE__);
8✔
507
            return nullptr;
8✔
508
        }
8✔
509
    }
15✔
510
    else {
1✔
511
        error_handler("QRef passed to prefetch was NULL.", __FILE__, __func__,
1✔
512
                      __LINE__);
1✔
513
        return nullptr;
1✔
514
    }
1✔
515
}
16✔
516

517
__dpctl_give DPCTLSyclEventRef
518
DPCTLQueue_MemAdvise(__dpctl_keep DPCTLSyclQueueRef QRef,
519
                     const void *Ptr,
520
                     size_t Count,
521
                     int Advice)
522
{
16✔
523
    auto Q = unwrap<queue>(QRef);
16✔
524
    if (Q) {
16✔
525
        sycl::event ev;
15✔
526
        try {
15✔
527
            ev = Q->mem_advise(Ptr, Count, Advice);
15✔
528
        } catch (std::exception const &e) {
15✔
529
            error_handler(e, __FILE__, __func__, __LINE__);
×
530
            return nullptr;
×
531
        }
×
532
        return wrap<event>(new event(ev));
15✔
533
    }
15✔
534
    else {
1✔
535
        error_handler("QRef passed to prefetch was NULL.", __FILE__, __func__,
1✔
536
                      __LINE__);
1✔
537
        return nullptr;
1✔
538
    }
1✔
539
}
16✔
540

541
bool DPCTLQueue_IsInOrder(__dpctl_keep const DPCTLSyclQueueRef QRef)
542
{
800✔
543
    auto Q = unwrap<queue>(QRef);
800✔
544
    if (Q) {
800✔
545
        return Q->is_in_order();
799✔
546
    }
799✔
547
    else
1✔
548
        return false;
1✔
549
}
800✔
550

551
bool DPCTLQueue_HasEnableProfiling(__dpctl_keep const DPCTLSyclQueueRef QRef)
552
{
56✔
553
    auto Q = unwrap<queue>(QRef);
56✔
554
    if (Q) {
56✔
555
        return Q->has_property<sycl::property::queue::enable_profiling>();
55✔
556
    }
55✔
557
    else
1✔
558
        return false;
1✔
559
}
56✔
560

561
size_t DPCTLQueue_Hash(__dpctl_keep const DPCTLSyclQueueRef QRef)
562
{
38✔
563
    auto Q = unwrap<queue>(QRef);
38✔
564
    if (Q) {
38✔
565
        std::hash<queue> hash_fn;
35✔
566
        return hash_fn(*Q);
35✔
567
    }
35✔
568
    else {
3✔
569
        error_handler("Argument QRef is NULL.", __FILE__, __func__, __LINE__);
3✔
570
        return 0;
3✔
571
    }
3✔
572
}
38✔
573

574
__dpctl_give DPCTLSyclEventRef DPCTLQueue_SubmitBarrierForEvents(
575
    __dpctl_keep const DPCTLSyclQueueRef QRef,
576
    __dpctl_keep const DPCTLSyclEventRef *DepEvents,
577
    size_t NDepEvents)
578
{
105✔
579
    auto Q = unwrap<queue>(QRef);
105✔
580
    event e;
105✔
581
    if (Q) {
105!
582
        try {
105✔
583
            e = Q->submit([&](handler &cgh) {
105✔
584
                // Depend on any event that was specified by the caller.
585
                if (NDepEvents)
105✔
586
                    for (auto i = 0ul; i < NDepEvents; ++i)
20✔
587
                        cgh.depends_on(*unwrap<event>(DepEvents[i]));
13✔
588

589
                cgh.ext_oneapi_barrier();
105✔
590
            });
105✔
591
        } catch (std::exception const &e) {
105✔
592
            error_handler(e, __FILE__, __func__, __LINE__);
×
593
            return nullptr;
×
594
        }
×
595

596
        return wrap<event>(new event(e));
105✔
597
    }
105✔
598
    else {
×
599
        error_handler("Argument QRef is NULL", __FILE__, __func__, __LINE__);
×
600
        return nullptr;
×
601
    }
×
602
}
105✔
603

604
__dpctl_give DPCTLSyclEventRef
605
DPCTLQueue_SubmitBarrier(__dpctl_keep const DPCTLSyclQueueRef QRef)
606
{
1✔
607
    return DPCTLQueue_SubmitBarrierForEvents(QRef, nullptr, 0);
1✔
608
}
1✔
609

610
__dpctl_give DPCTLSyclEventRef
611
DPCTLQueue_Memset(__dpctl_keep const DPCTLSyclQueueRef QRef,
612
                  void *USMRef,
613
                  uint8_t Value,
614
                  size_t Count)
615
{
3,081✔
616
    auto Q = unwrap<queue>(QRef);
3,081✔
617
    if (Q && USMRef) {
3,081!
618
        sycl::event ev;
3,080✔
619
        try {
3,080✔
620
            ev = Q->memset(USMRef, static_cast<int>(Value), Count);
3,080✔
621
        } catch (std::exception const &e) {
3,080✔
622
            error_handler(e, __FILE__, __func__, __LINE__);
×
623
            return nullptr;
×
624
        }
×
625
        return wrap<event>(new event(ev));
3,080✔
626
    }
3,080✔
627
    else {
1✔
628
        error_handler("QRef or USMRef passed to fill8 were NULL.", __FILE__,
1✔
629
                      __func__, __LINE__);
1✔
630
        return nullptr;
1✔
631
    }
1✔
632
};
3,081✔
633

634
__dpctl_give DPCTLSyclEventRef
635
DPCTLQueue_Fill8(__dpctl_keep const DPCTLSyclQueueRef QRef,
636
                 void *USMRef,
637
                 uint8_t Value,
638
                 size_t Count)
639
{
9✔
640
    auto Q = unwrap<queue>(QRef);
9✔
641
    if (Q && USMRef) {
9!
642
        sycl::event ev;
8✔
643
        try {
8✔
644
            ev = Q->fill<uint8_t>(USMRef, Value, Count);
8✔
645
        } catch (std::exception const &e) {
8✔
646
            error_handler(e, __FILE__, __func__, __LINE__);
×
647
            return nullptr;
×
648
        }
×
649
        return wrap<event>(new event(ev));
8✔
650
    }
8✔
651
    else {
1✔
652
        error_handler("QRef or USMRef passed to fill8 were NULL.", __FILE__,
1✔
653
                      __func__, __LINE__);
1✔
654
        return nullptr;
1✔
655
    }
1✔
656
}
9✔
657

658
__dpctl_give DPCTLSyclEventRef
659
DPCTLQueue_Fill16(__dpctl_keep const DPCTLSyclQueueRef QRef,
660
                  void *USMRef,
661
                  uint16_t Value,
662
                  size_t Count)
663
{
9✔
664
    auto Q = unwrap<queue>(QRef);
9✔
665
    if (Q && USMRef) {
9!
666
        sycl::event ev;
8✔
667
        try {
8✔
668
            ev = Q->fill<uint16_t>(USMRef, Value, Count);
8✔
669
        } catch (std::exception const &e) {
8✔
670
            error_handler(e, __FILE__, __func__, __LINE__);
×
671
            return nullptr;
×
672
        }
×
673
        return wrap<event>(new event(ev));
8✔
674
    }
8✔
675
    else {
1✔
676
        error_handler("QRef or USMRef passed to fill16 were NULL.", __FILE__,
1✔
677
                      __func__, __LINE__);
1✔
678
        return nullptr;
1✔
679
    }
1✔
680
}
9✔
681

682
__dpctl_give DPCTLSyclEventRef
683
DPCTLQueue_Fill32(__dpctl_keep const DPCTLSyclQueueRef QRef,
684
                  void *USMRef,
685
                  uint32_t Value,
686
                  size_t Count)
687
{
9✔
688
    auto Q = unwrap<queue>(QRef);
9✔
689
    if (Q && USMRef) {
9!
690
        sycl::event ev;
8✔
691
        try {
8✔
692
            ev = Q->fill<uint32_t>(USMRef, Value, Count);
8✔
693
        } catch (std::exception const &e) {
8✔
694
            error_handler(e, __FILE__, __func__, __LINE__);
×
695
            return nullptr;
×
696
        }
×
697
        return wrap<event>(new event(ev));
8✔
698
    }
8✔
699
    else {
1✔
700
        error_handler("QRef or USMRef passed to fill32 were NULL.", __FILE__,
1✔
701
                      __func__, __LINE__);
1✔
702
        return nullptr;
1✔
703
    }
1✔
704
}
9✔
705

706
__dpctl_give DPCTLSyclEventRef
707
DPCTLQueue_Fill64(__dpctl_keep const DPCTLSyclQueueRef QRef,
708
                  void *USMRef,
709
                  uint64_t Value,
710
                  size_t Count)
711
{
9✔
712
    auto Q = unwrap<queue>(QRef);
9✔
713
    if (Q && USMRef) {
9!
714
        sycl::event ev;
8✔
715
        try {
8✔
716
            ev = Q->fill<uint64_t>(USMRef, Value, Count);
8✔
717
        } catch (std::exception const &e) {
8✔
718
            error_handler(e, __FILE__, __func__, __LINE__);
×
719
            return nullptr;
×
720
        }
×
721
        return wrap<event>(new event(ev));
8✔
722
    }
8✔
723
    else {
1✔
724
        error_handler("QRef or USMRef passed to fill64 were NULL.", __FILE__,
1✔
725
                      __func__, __LINE__);
1✔
726
        return nullptr;
1✔
727
    }
1✔
728
}
9✔
729

730
__dpctl_give DPCTLSyclEventRef
731
DPCTLQueue_Fill128(__dpctl_keep const DPCTLSyclQueueRef QRef,
732
                   void *USMRef,
733
                   uint64_t *Value,
734
                   size_t Count)
735
{
9✔
736
    auto Q = unwrap<queue>(QRef);
9✔
737
    if (Q && USMRef) {
9!
738
        sycl::event ev;
8✔
739
        try {
8✔
740
            complexNumber Val;
8✔
741
            Val.real = Value[0];
8✔
742
            Val.imag = Value[1];
8✔
743
            ev = Q->fill(USMRef, Val, Count);
8✔
744
        } catch (std::exception const &e) {
8✔
745
            error_handler(e, __FILE__, __func__, __LINE__);
×
746
            return nullptr;
×
747
        }
×
748
        return wrap<event>(new event(ev));
8✔
749
    }
8✔
750
    else {
1✔
751
        error_handler("QRef or USMRef passed to fill128 were NULL.", __FILE__,
1✔
752
                      __func__, __LINE__);
1✔
753
        return nullptr;
1✔
754
    }
1✔
755
}
9✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc