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

IntelPython / dpctl / 42535732639

08 Nov 2026 11:33PM UTC coverage: 75.112% (-0.03%) from 75.137%
42535732639

Pull #2425

github

web-flow
Merge 40dcdf28e into 2ed816f33
Pull Request #2425: Check the number of kernel arguments only for interoperability kernels

1080 of 1514 branches covered (71.33%)

Branch coverage included in aggregate %.

4 of 7 new or added lines in 1 file covered. (57.14%)

4123 of 5413 relevant lines covered (76.17%)

283.15 hits per line

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

78.76
/libsyclinterface/source/dpctl_sycl_kernel_interface.cpp
1
//===--- dpctl_sycl_kernel_interface.cpp - Implements C API for sycl::kernel =//
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 functions declared in
23
/// dpctl_sycl_kernel_interface.h.
24
///
25
//===----------------------------------------------------------------------===//
26

27
#include "dpctl_sycl_kernel_interface.h"
28
#include "Config/dpctl_config.h"
29
#include "dpctl_error_handlers.h"
30
#include "dpctl_string_utils.hpp"
31
#include "dpctl_sycl_type_casters.hpp"
32
#include <cstdint>
33
#include <stddef.h>
34
#include <sycl/sycl.hpp> /* Sycl headers */
35

36
using namespace sycl;
37

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

43
using namespace dpctl::syclinterface;
44
} // end of anonymous namespace
45

46
size_t DPCTLKernel_GetNumArgs(__dpctl_keep const DPCTLSyclKernelRef KRef)
47
{
110 ✔
48
    if (!KRef) {
110 ✔
49
        error_handler("Cannot get the number of arguments from "
1 ✔
50
                      "DPCTLSyclKernelRef as input is a nullptr.",
1 ✔
51
                      __FILE__, __func__, __LINE__);
1 ✔
52
        return -1;
1 ✔
53
    }
1 ✔
54

55
    auto sycl_kernel = unwrap<kernel>(KRef);
109 ✔
56
    try {
109 ✔
57
        auto num_args = sycl_kernel->get_info<info::kernel::num_args>();
109 ✔
58
        return static_cast<size_t>(num_args);
109 ✔
59
    } catch (std::exception const &e) {
109 ✔
NEW
60
        error_handler(e, __FILE__, __func__, __LINE__);
×
NEW
61
        return -1;
×
NEW
62
    }
×
63
}
109 ✔
64

65
void DPCTLKernel_Delete(__dpctl_take DPCTLSyclKernelRef KRef)
66
{
134 ✔
67
    delete unwrap<kernel>(KRef);
134 ✔
68
}
134 ✔
69

70
__dpctl_give DPCTLSyclKernelRef
71
DPCTLKernel_Copy(__dpctl_keep const DPCTLSyclKernelRef KRef)
72
{
15 ✔
73
    auto Kernel = unwrap<kernel>(KRef);
15 ✔
74
    if (!Kernel) {
15 ✔
75
        error_handler("Cannot copy DPCTLSyclKernelRef as input is a nullptr",
1 ✔
76
                      __FILE__, __func__, __LINE__);
1 ✔
77
        return nullptr;
1 ✔
78
    }
1 ✔
79
    try {
14 ✔
80
        auto CopiedKernel = new kernel(*Kernel);
14 ✔
81
        return wrap<kernel>(CopiedKernel);
14 ✔
82
    } catch (std::exception const &e) {
14 ✔
83
        error_handler(e, __FILE__, __func__, __LINE__);
×
84
        return nullptr;
×
85
    }
×
86
}
14 ✔
87

88
size_t DPCTLKernel_GetWorkGroupSize(__dpctl_keep const DPCTLSyclKernelRef KRef)
89
{
33 ✔
90
    if (!KRef) {
33 ✔
91
        error_handler("Input DPCTKSyclKernelRef is nullptr.", __FILE__,
1 ✔
92
                      __func__, __LINE__);
1 ✔
93
        return 0;
1 ✔
94
    }
1 ✔
95

96
    auto sycl_kern = unwrap<kernel>(KRef);
32 ✔
97
    auto devs = sycl_kern->get_kernel_bundle().get_devices();
32 ✔
98
    if (devs.empty()) {
32 !
99
        error_handler("Input DPCTKSyclKernelRef has no associated device.",
×
100
                      __FILE__, __func__, __LINE__);
×
101
        return 0;
×
102
    }
×
103
    auto v = sycl_kern->get_info<info::kernel_device_specific::work_group_size>(
32 ✔
104
        devs[0]);
32 ✔
105
    return static_cast<size_t>(v);
32 ✔
106
}
32 ✔
107

108
size_t DPCTLKernel_GetPreferredWorkGroupSizeMultiple(
109
    __dpctl_keep const DPCTLSyclKernelRef KRef)
110
{
9 ✔
111
    if (!KRef) {
9 ✔
112
        error_handler("Input DPCTKSyclKernelRef is nullptr.", __FILE__,
1 ✔
113
                      __func__, __LINE__);
1 ✔
114
        return 0;
1 ✔
115
    }
1 ✔
116

117
    auto sycl_kern = unwrap<kernel>(KRef);
8 ✔
118
    auto devs = sycl_kern->get_kernel_bundle().get_devices();
8 ✔
119
    if (devs.empty()) {
8 !
120
        error_handler("Input DPCTKSyclKernelRef has no associated device.",
×
121
                      __FILE__, __func__, __LINE__);
×
122
        return 0;
×
123
    }
×
124
    auto v = sycl_kern->get_info<
8 ✔
125
        info::kernel_device_specific::preferred_work_group_size_multiple>(
8 ✔
126
        devs[0]);
8 ✔
127
    return static_cast<size_t>(v);
8 ✔
128
}
8 ✔
129

130
size_t DPCTLKernel_GetPrivateMemSize(__dpctl_keep const DPCTLSyclKernelRef KRef)
131
{
9 ✔
132
    if (!KRef) {
9 ✔
133
        error_handler("Input DPCTKSyclKernelRef is nullptr.", __FILE__,
1 ✔
134
                      __func__, __LINE__);
1 ✔
135
        return 0;
1 ✔
136
    }
1 ✔
137

138
    auto sycl_kern = unwrap<kernel>(KRef);
8 ✔
139
    auto devs = sycl_kern->get_kernel_bundle().get_devices();
8 ✔
140
    if (devs.empty()) {
8 !
141
        error_handler("Input DPCTKSyclKernelRef has no associated device.",
×
142
                      __FILE__, __func__, __LINE__);
×
143
        return 0;
×
144
    }
×
145
    auto v =
8 ✔
146
        sycl_kern->get_info<info::kernel_device_specific::private_mem_size>(
8 ✔
147
            devs[0]);
8 ✔
148
    return static_cast<size_t>(v);
8 ✔
149
}
8 ✔
150

151
uint32_t
152
DPCTLKernel_GetMaxNumSubGroups(__dpctl_keep const DPCTLSyclKernelRef KRef)
153
{
9 ✔
154
    if (!KRef) {
9 ✔
155
        error_handler("Input DPCTKSyclKernelRef is nullptr.", __FILE__,
1 ✔
156
                      __func__, __LINE__);
1 ✔
157
        return 0;
1 ✔
158
    }
1 ✔
159

160
    auto sycl_kern = unwrap<kernel>(KRef);
8 ✔
161
    auto devs = sycl_kern->get_kernel_bundle().get_devices();
8 ✔
162
    if (devs.empty()) {
8 !
163
        error_handler("Input DPCTKSyclKernelRef has no associated device.",
×
164
                      __FILE__, __func__, __LINE__);
×
165
        return 0;
×
166
    }
×
167
    auto v =
8 ✔
168
        sycl_kern->get_info<info::kernel_device_specific::max_num_sub_groups>(
8 ✔
169
            devs[0]);
8 ✔
170
    return static_cast<uint32_t>(v);
8 ✔
171
}
8 ✔
172

173
uint32_t
174
DPCTLKernel_GetMaxSubGroupSize(__dpctl_keep const DPCTLSyclKernelRef KRef)
175
{
9 ✔
176
    if (!KRef) {
9 ✔
177
        error_handler("Input DPCTKSyclKernelRef is nullptr.", __FILE__,
1 ✔
178
                      __func__, __LINE__);
1 ✔
179
        return 0;
1 ✔
180
    }
1 ✔
181

182
    auto sycl_kern = unwrap<kernel>(KRef);
8 ✔
183
    auto devs = sycl_kern->get_kernel_bundle().get_devices();
8 ✔
184
    if (devs.empty()) {
8 !
185
        error_handler("Input DPCTKSyclKernelRef has no associated device.",
×
186
                      __FILE__, __func__, __LINE__);
×
187
        return 0;
×
188
    }
×
189
    auto v =
8 ✔
190
        sycl_kern->get_info<info::kernel_device_specific::max_sub_group_size>(
8 ✔
191
            devs[0]);
8 ✔
192
    return v;
8 ✔
193
}
8 ✔
194

195
uint32_t
196
DPCTLKernel_GetCompileNumSubGroups(__dpctl_keep const DPCTLSyclKernelRef KRef)
197
{
9 ✔
198
    if (!KRef) {
9 ✔
199
        error_handler("Input DPCTKSyclKernelRef is nullptr.", __FILE__,
1 ✔
200
                      __func__, __LINE__);
1 ✔
201
        return 0;
1 ✔
202
    }
1 ✔
203

204
    auto sycl_kern = unwrap<kernel>(KRef);
8 ✔
205
    auto devs = sycl_kern->get_kernel_bundle().get_devices();
8 ✔
206
    if (devs.empty()) {
8 !
207
        error_handler("Input DPCTKSyclKernelRef has no associated device.",
×
208
                      __FILE__, __func__, __LINE__);
×
209
        return 0;
×
210
    }
×
211
    auto v =
8 ✔
212
        sycl_kern
8 ✔
213
            ->get_info<info::kernel_device_specific::compile_num_sub_groups>(
8 ✔
214
                devs[0]);
8 ✔
215
    return static_cast<uint32_t>(v);
8 ✔
216
}
8 ✔
217

218
uint32_t
219
DPCTLKernel_GetCompileSubGroupSize(__dpctl_keep const DPCTLSyclKernelRef KRef)
220
{
9 ✔
221
    if (!KRef) {
9 ✔
222
        error_handler("Input DPCTKSyclKernelRef is nullptr.", __FILE__,
1 ✔
223
                      __func__, __LINE__);
1 ✔
224
        return 0;
1 ✔
225
    }
1 ✔
226

227
    auto sycl_kern = unwrap<kernel>(KRef);
8 ✔
228
    auto devs = sycl_kern->get_kernel_bundle().get_devices();
8 ✔
229
    if (devs.empty()) {
8 !
230
        error_handler("Input DPCTKSyclKernelRef has no associated device.",
×
231
                      __FILE__, __func__, __LINE__);
×
232
        return 0;
×
233
    }
×
234
    auto v =
8 ✔
235
        sycl_kern
8 ✔
236
            ->get_info<info::kernel_device_specific::compile_sub_group_size>(
8 ✔
237
                devs[0]);
8 ✔
238
    return static_cast<uint32_t>(v);
8 ✔
239
}
8 ✔
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