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

IntelPython / dpctl / 12520577393

27 Dec 2024 08:50PM UTC coverage: 87.659%. Remained the same
12520577393

Pull #1950

github

web-flow
Merge 75f114513 into 39a19c159
Pull Request #1950: [MAINT] Use `std::size_t` from `cstddef` and use `dpctl::tensor::ssize_t` where `ssize_t` is used

3120 of 3640 branches covered (85.71%)

Branch coverage included in aggregate %.

11810 of 13392 relevant lines covered (88.19%)

7083.2 hits per line

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

79.79
/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-2024 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
{
32✔
48
    if (!KRef) {
32✔
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);
31✔
56
    auto num_args = sycl_kernel->get_info<info::kernel::num_args>();
31✔
57
    return static_cast<size_t>(num_args);
31✔
58
}
32✔
59

60
void DPCTLKernel_Delete(__dpctl_take DPCTLSyclKernelRef KRef)
61
{
96✔
62
    delete unwrap<kernel>(KRef);
96✔
63
}
96✔
64

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

83
size_t
84
DPCTLKernel_GetWorkGroupSize(__dpctl_keep const DPCTLSyclKernelRef KRef)
85
{
23✔
86
    if (!KRef) {
23✔
87
        error_handler("Input DPCTKSyclKernelRef is nullptr.", __FILE__,
1✔
88
                      __func__, __LINE__);
1✔
89
        return 0;
1✔
90
    }
1✔
91

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

104
size_t DPCTLKernel_GetPreferredWorkGroupSizeMultiple(
105
    __dpctl_keep const DPCTLSyclKernelRef KRef)
106
{
7✔
107
    if (!KRef) {
7✔
108
        error_handler("Input DPCTKSyclKernelRef is nullptr.", __FILE__,
1✔
109
                      __func__, __LINE__);
1✔
110
        return 0;
1✔
111
    }
1✔
112

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

126
size_t
127
DPCTLKernel_GetPrivateMemSize(__dpctl_keep const DPCTLSyclKernelRef KRef)
128
{
7✔
129
    if (!KRef) {
7✔
130
        error_handler("Input DPCTKSyclKernelRef is nullptr.", __FILE__,
1✔
131
                      __func__, __LINE__);
1✔
132
        return 0;
1✔
133
    }
1✔
134

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

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

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

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

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

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

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

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

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