29
29
#include " dpctl_error_handlers.h"
30
30
#include " dpctl_string_utils.hpp"
31
31
#include < CL/sycl.hpp> /* Sycl headers */
32
+ #include < cstdint>
32
33
33
34
using namespace cl ::sycl;
34
35
@@ -39,21 +40,177 @@ DEFINE_SIMPLE_CONVERSION_FUNCTIONS(kernel, DPCTLSyclKernelRef)
39
40
40
41
} /* end of anonymous namespace */
41
42
42
- size_t DPCTLKernel_GetNumArgs (__dpctl_keep const DPCTLSyclKernelRef Kernel )
43
+ size_t DPCTLKernel_GetNumArgs (__dpctl_keep const DPCTLSyclKernelRef KRef )
43
44
{
44
- if (!Kernel ) {
45
+ if (!KRef ) {
45
46
error_handler (" Cannot get the number of arguments from "
46
47
" DPCTLSyclKernelRef as input is a nullptr." ,
47
48
__FILE__, __func__, __LINE__);
48
49
return -1 ;
49
50
}
50
51
51
- auto SyclKernel = unwrap (Kernel );
52
- auto num_args = SyclKernel ->get_info <info::kernel::num_args>();
53
- return ( size_t ) num_args;
52
+ auto sycl_kernel = unwrap (KRef );
53
+ auto num_args = sycl_kernel ->get_info <info::kernel::num_args>();
54
+ return static_cast < size_t >( num_args) ;
54
55
}
55
56
56
- void DPCTLKernel_Delete (__dpctl_take DPCTLSyclKernelRef Kernel )
57
+ void DPCTLKernel_Delete (__dpctl_take DPCTLSyclKernelRef KRef )
57
58
{
58
- delete unwrap (Kernel);
59
+ delete unwrap (KRef);
60
+ }
61
+
62
+ size_t DPCTLKernel_GetWorkGroupSize (__dpctl_keep const DPCTLSyclKernelRef KRef)
63
+ {
64
+ if (!KRef) {
65
+ error_handler (" Input DPCTKSyclKernelRef is nullptr." , __FILE__,
66
+ __func__, __LINE__);
67
+ return 0 ;
68
+ }
69
+
70
+ auto sycl_kern = unwrap (KRef);
71
+ auto devs = sycl_kern->get_kernel_bundle ().get_devices ();
72
+ if (devs.empty ()) {
73
+ error_handler (" Input DPCTKSyclKernelRef has no associated device." ,
74
+ __FILE__, __func__, __LINE__);
75
+ return 0 ;
76
+ }
77
+ auto v = sycl_kern->get_info <info::kernel_device_specific::work_group_size>(
78
+ devs[0 ]);
79
+ return static_cast <size_t >(v);
80
+ }
81
+
82
+ size_t DPCTLKernel_GetPreferredWorkGroupSizeMultiple (
83
+ __dpctl_keep const DPCTLSyclKernelRef KRef)
84
+ {
85
+ if (!KRef) {
86
+ error_handler (" Input DPCTKSyclKernelRef is nullptr." , __FILE__,
87
+ __func__, __LINE__);
88
+ return 0 ;
89
+ }
90
+
91
+ auto sycl_kern = unwrap (KRef);
92
+ auto devs = sycl_kern->get_kernel_bundle ().get_devices ();
93
+ if (devs.empty ()) {
94
+ error_handler (" Input DPCTKSyclKernelRef has no associated device." ,
95
+ __FILE__, __func__, __LINE__);
96
+ return 0 ;
97
+ }
98
+ auto v = sycl_kern->get_info <
99
+ info::kernel_device_specific::preferred_work_group_size_multiple>(
100
+ devs[0 ]);
101
+ return static_cast <size_t >(v);
102
+ }
103
+
104
+ size_t DPCTLKernel_GetPrivateMemSize (__dpctl_keep const DPCTLSyclKernelRef KRef)
105
+ {
106
+ if (!KRef) {
107
+ error_handler (" Input DPCTKSyclKernelRef is nullptr." , __FILE__,
108
+ __func__, __LINE__);
109
+ return 0 ;
110
+ }
111
+
112
+ auto sycl_kern = unwrap (KRef);
113
+ auto devs = sycl_kern->get_kernel_bundle ().get_devices ();
114
+ if (devs.empty ()) {
115
+ error_handler (" Input DPCTKSyclKernelRef has no associated device." ,
116
+ __FILE__, __func__, __LINE__);
117
+ return 0 ;
118
+ }
119
+ auto v =
120
+ sycl_kern->get_info <info::kernel_device_specific::private_mem_size>(
121
+ devs[0 ]);
122
+ return static_cast <size_t >(v);
123
+ }
124
+
125
+ uint32_t
126
+ DPCTLKernel_GetMaxNumSubGroups (__dpctl_keep const DPCTLSyclKernelRef KRef)
127
+ {
128
+ if (!KRef) {
129
+ error_handler (" Input DPCTKSyclKernelRef is nullptr." , __FILE__,
130
+ __func__, __LINE__);
131
+ return 0 ;
132
+ }
133
+
134
+ auto sycl_kern = unwrap (KRef);
135
+ auto devs = sycl_kern->get_kernel_bundle ().get_devices ();
136
+ if (devs.empty ()) {
137
+ error_handler (" Input DPCTKSyclKernelRef has no associated device." ,
138
+ __FILE__, __func__, __LINE__);
139
+ return 0 ;
140
+ }
141
+ auto v =
142
+ sycl_kern->get_info <info::kernel_device_specific::max_num_sub_groups>(
143
+ devs[0 ]);
144
+ return static_cast <uint32_t >(v);
145
+ }
146
+
147
+ #if 0
148
+ // commented out due to bug in DPC++ runtime, get_info for max_sub_group_size
149
+ // exported by libsycl has different, not SPEC-compliant signature
150
+ uint32_t
151
+ DPCTLKernel_GetMaxSubGroupSize(__dpctl_keep const DPCTLSyclKernelRef KRef)
152
+ {
153
+ if (!KRef) {
154
+ error_handler("Input DPCTKSyclKernelRef is nullptr.", __FILE__,
155
+ __func__, __LINE__);
156
+ return 0;
157
+ }
158
+
159
+ auto sycl_kern = unwrap(KRef);
160
+ auto devs = sycl_kern->get_kernel_bundle().get_devices();
161
+ if (devs.empty()) {
162
+ error_handler("Input DPCTKSyclKernelRef has no associated device.",
163
+ __FILE__, __func__, __LINE__);
164
+ return 0;
165
+ }
166
+ auto v = sycl_kern
167
+ ->get_info<info::kernel_device_specific::max_sub_group_size>(devs[0]);
168
+ return v;
169
+ }
170
+ #endif
171
+
172
+ uint32_t
173
+ DPCTLKernel_GetCompileNumSubGroups (__dpctl_keep const DPCTLSyclKernelRef KRef)
174
+ {
175
+ if (!KRef) {
176
+ error_handler (" Input DPCTKSyclKernelRef is nullptr." , __FILE__,
177
+ __func__, __LINE__);
178
+ return 0 ;
179
+ }
180
+
181
+ auto sycl_kern = unwrap (KRef);
182
+ auto devs = sycl_kern->get_kernel_bundle ().get_devices ();
183
+ if (devs.empty ()) {
184
+ error_handler (" Input DPCTKSyclKernelRef has no associated device." ,
185
+ __FILE__, __func__, __LINE__);
186
+ return 0 ;
187
+ }
188
+ auto v =
189
+ sycl_kern
190
+ ->get_info <info::kernel_device_specific::compile_num_sub_groups>(
191
+ devs[0 ]);
192
+ return static_cast <uint32_t >(v);
193
+ }
194
+
195
+ uint32_t
196
+ DPCTLKernel_GetCompileSubGroupSize (__dpctl_keep const DPCTLSyclKernelRef KRef)
197
+ {
198
+ if (!KRef) {
199
+ error_handler (" Input DPCTKSyclKernelRef is nullptr." , __FILE__,
200
+ __func__, __LINE__);
201
+ return 0 ;
202
+ }
203
+
204
+ auto sycl_kern = unwrap (KRef);
205
+ auto devs = sycl_kern->get_kernel_bundle ().get_devices ();
206
+ if (devs.empty ()) {
207
+ error_handler (" Input DPCTKSyclKernelRef has no associated device." ,
208
+ __FILE__, __func__, __LINE__);
209
+ return 0 ;
210
+ }
211
+ auto v =
212
+ sycl_kern
213
+ ->get_info <info::kernel_device_specific::compile_sub_group_size>(
214
+ devs[0 ]);
215
+ return static_cast <uint32_t >(v);
59
216
}
0 commit comments