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

IntelPython / dpnp / 25528825989

08 May 2026 12:02AM UTC coverage: 78.444% (+0.01%) from 78.432%
25528825989

push

github

web-flow
Pin Intel OneAPI to 2025.3 in CI workflows for coverage (#2887)

This PR proposes using OneAPI 2025.3 for `build-sphinx` and
`generate_coverage` workflows to match the compiler version used to
build dpctl packages since dpctl is waiting for the latest compiler to
become available on conda-forge
[dpctl#2300](https://github.com/IntelPython/dpctl/pull/2300/changes#diff-a88e46d7b31a87dc2241c3e8e3acf8eeeL575)

1573 of 2908 branches covered (54.09%)

Branch coverage included in aggregate %.

26273 of 32590 relevant lines covered (80.62%)

7636.65 hits per line

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

83.33
/dpnp/backend/src/queue_sycl.hpp
1
//*****************************************************************************
2
// Copyright (c) 2016, Intel Corporation
3
// All rights reserved.
4
//
5
// Redistribution and use in source and binary forms, with or without
6
// modification, are permitted provided that the following conditions are met:
7
// - Redistributions of source code must retain the above copyright notice,
8
//   this list of conditions and the following disclaimer.
9
// - Redistributions in binary form must reproduce the above copyright notice,
10
//   this list of conditions and the following disclaimer in the documentation
11
//   and/or other materials provided with the distribution.
12
// - Neither the name of the copyright holder nor the names of its contributors
13
//   may be used to endorse or promote products derived from this software
14
//   without specific prior written permission.
15
//
16
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
20
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
26
// THE POSSIBILITY OF SUCH DAMAGE.
27
//*****************************************************************************
28

29
#pragma once
30
#ifndef QUEUE_SYCL_H // Cython compatibility
31
#define QUEUE_SYCL_H
32

33
// #pragma clang diagnostic push
34
// #pragma clang diagnostic ignored "-Wpass-failed"
35
#include <sycl/sycl.hpp>
36
// #pragma clang diagnostic pop
37

38
#pragma clang diagnostic push
39
#pragma clang diagnostic ignored "-Wunused-parameter"
40
#pragma clang diagnostic ignored "-Wreorder-ctor"
41
#include <oneapi/mkl.hpp>
42
#pragma clang diagnostic pop
43

44
#include <utility>
45

46
#include "dpnp_pstl.hpp" // this header must be included after <mkl.hpp>
47

48
#include "verbose.hpp"
49

50
namespace mkl_rng = oneapi::mkl::rng;
51

52
#define DPNP_QUEUE            backend_sycl::get_queue()
6✔
53
#define DPNP_RNG_ENGINE       backend_sycl::get_rng_engine()
257✔
54
#define DPNP_RNG_MCG59_ENGINE backend_sycl::get_rng_mcg59_engine()
×
55

56
/**
57
 * This is container for the SYCL queue, random number generation engine and
58
 * related functions like queue and engine initialization and maintenance. The
59
 * queue could not be initialized as a global object. Global object
60
 * initialization order is undefined. This class postpone initialization of the
61
 * SYCL queue and mt19937 random number generation engine.
62
 */
63
class backend_sycl
64
{
65
public:
66
    ~backend_sycl() {}
1✔
67

68
    static backend_sycl &get()
69
    {
556✔
70
#if defined(_WIN32) && INTEL_MKL_VERSION == 20260000
71
        // TODO: remove once MKLD-19835 is resolved
72
        // mt19937 (oneMKL 2026.0) destructor crashes during DLL_PROCESS_DETACH
73
        // on Windows (Battlemage/Level Zero). Use a heap-allocated
74
        // process-lifetime singleton to skip destructor; OS reclaims memory.
75
        static backend_sycl *backend = new backend_sycl{};
76
        return *backend;
77
#else
78
        static backend_sycl backend{};
556✔
79
        return backend;
556✔
80
#endif
556✔
81
    }
556✔
82

83
    static sycl::queue &get_queue()
84
    {
6✔
85
        auto &be = backend_sycl::get();
6✔
86
        return be.queue_;
6✔
87
    }
6✔
88

89
    static mkl_rng::mt19937 &get_rng_engine()
90
    {
257✔
91
        auto &be = backend_sycl::get();
257✔
92
        return be.rng_mt19937_engine_;
257✔
93
    }
257✔
94

95
    static mkl_rng::mcg59 &get_rng_mcg59_engine()
96
    {
×
97
        auto &be = backend_sycl::get();
×
98
        return be.rng_mcg59_engine_;
×
99
    }
×
100

101
    template <typename SeedT>
102
    void set_rng_engines_seed(const SeedT &seed)
103
    {
287✔
104
        mkl_rng::mt19937 rng_eng_mt19937(queue_, seed);
287✔
105
        mkl_rng::mcg59 rng_eng_mcg59(queue_, seed);
287✔
106

107
        // now that instances are created, let's move them
108
        rng_mt19937_engine_ = std::move(rng_eng_mt19937);
287✔
109
        rng_mcg59_engine_ = std::move(rng_eng_mcg59);
287✔
110
    }
287✔
111

112
    bool backend_sycl_is_cpu() const
113
    {
6✔
114
        const auto &dev = queue_.get_device();
6✔
115
        return dev.is_cpu();
6✔
116
    }
6✔
117

118
private:
119
    static constexpr std::size_t default_seed = 1;
120

121
    backend_sycl()
122
        : queue_{sycl::default_selector_v,
1✔
123
                 (is_verbose_mode())
1!
124
                     ? sycl::property_list{sycl::property::queue::
1✔
125
                                               enable_profiling()}
×
126
                     : sycl::property_list{}},
1✔
127
          rng_mt19937_engine_{queue_, default_seed},
1✔
128
          rng_mcg59_engine_{queue_, default_seed}
1✔
129
    {
1✔
130
    }
1✔
131

132
    backend_sycl(backend_sycl const &) = default;
133
    backend_sycl &operator=(backend_sycl const &) = default;
134
    backend_sycl &operator=(backend_sycl &&) = default;
135

136
    sycl::queue queue_;
137
    mkl_rng::mt19937 rng_mt19937_engine_;
138
    mkl_rng::mcg59 rng_mcg59_engine_;
139
};
140

141
#endif // QUEUE_SYCL_H
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