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

IntelPython / dpctl / 9974566682

17 Jul 2024 12:52PM UTC coverage: 87.967%. Remained the same
9974566682

Pull #1737

github

web-flow
Merge b23013880 into 6d34a6beb
Pull Request #1737: Replace "-c intel" in docs and readme file

3328 of 3822 branches covered (87.07%)

Branch coverage included in aggregate %.

11257 of 12758 relevant lines covered (88.23%)

7349.42 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 <sycl/sycl.hpp> /* Sycl headers */
34

35
using namespace sycl;
36

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

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

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

54
    auto sycl_kernel = unwrap<kernel>(KRef);
31✔
55
    auto num_args = sycl_kernel->get_info<info::kernel::num_args>();
31✔
56
    return static_cast<size_t>(num_args);
31✔
57
}
32✔
58

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

© 2025 Coveralls, Inc