Skip to content

Commit e3b76be

Browse files
garimagubader
authored andcommitted
[SYCL] Enable infrastructure for multiple run-time plug-ins support (#843)
* Using a single call to Plugin, and populating a Plugin data structure with all function pointers. Extension to this will allow us to bind multiple plugins. * Change PI_CALL syntax from PI_CALL(pi, ...Args) to PI_CALL(pi)(...Args); Required extension of Trace class. * Added the clang-format config file for SYCL runtime library. Consider PI_CALL/PI_CALL_THROW/PI_CALL_NOCHECK as typenames instead of being functions. Signed-off-by: Garima Gupta <[email protected]>
1 parent 6aae4ef commit e3b76be

38 files changed

+635
-503
lines changed

sycl/.clang-format

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
BasedOnStyle: LLVM
2+
TypenameMacros: ['PI_CALL' ,'PI_CALL_THROW', 'PI_CALL_NOCHECK']

sycl/include/CL/sycl/buffer.hpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -181,9 +181,8 @@ class buffer {
181181
: Range{0} {
182182

183183
size_t BufSize = 0;
184-
PI_CALL(detail::RT::piMemGetInfo,
185-
detail::pi::cast<detail::RT::PiMem>(MemObject), CL_MEM_SIZE,
186-
sizeof(size_t), &BufSize, nullptr);
184+
PI_CALL(piMemGetInfo)(detail::pi::cast<detail::RT::PiMem>(MemObject),
185+
CL_MEM_SIZE, sizeof(size_t), &BufSize, nullptr);
187186

188187
Range[0] = BufSize / sizeof(T);
189188
impl = std::make_shared<detail::buffer_impl<AllocatorT>>(

sycl/include/CL/sycl/detail/context_info.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ template <info::context param> struct get_context_info {
2222
static RetType _(RT::PiContext ctx) {
2323
RetType Result = 0;
2424
// TODO catch an exception and put it to list of asynchronous exceptions
25-
PI_CALL(RT::piContextGetInfo, ctx, pi::cast<pi_context_info>(param),
26-
sizeof(Result), &Result, nullptr);
25+
PI_CALL(piContextGetInfo)(ctx, pi::cast<pi_context_info>(param),
26+
sizeof(Result), &Result, nullptr);
2727
return Result;
2828
}
2929
};

sycl/include/CL/sycl/detail/device_info.hpp

Lines changed: 44 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ template <> struct check_fp_support<info::device::double_fp_config> {
4848
template <typename T, info::device param> struct get_device_info {
4949
static T _(RT::PiDevice dev) {
5050
typename sycl_to_pi<T>::type result;
51-
PI_CALL(RT::piDeviceGetInfo, dev, pi::cast<RT::PiDeviceInfo>(param),
52-
sizeof(result), &result, nullptr);
51+
PI_CALL(piDeviceGetInfo)(dev, pi::cast<RT::PiDeviceInfo>(param),
52+
sizeof(result), &result, nullptr);
5353
return T(result);
5454
}
5555
};
@@ -58,8 +58,8 @@ template <typename T, info::device param> struct get_device_info {
5858
template <info::device param> struct get_device_info<platform, param> {
5959
static platform _(RT::PiDevice dev) {
6060
typename sycl_to_pi<platform>::type result;
61-
PI_CALL(RT::piDeviceGetInfo, dev, pi::cast<RT::PiDeviceInfo>(param),
62-
sizeof(result), &result, nullptr);
61+
PI_CALL(piDeviceGetInfo)(dev, pi::cast<RT::PiDeviceInfo>(param),
62+
sizeof(result), &result, nullptr);
6363
return createSyclObjFromImpl<platform>(
6464
std::make_shared<platform_impl_pi>(result));
6565
}
@@ -69,14 +69,14 @@ template <info::device param> struct get_device_info<platform, param> {
6969
template <info::device param> struct get_device_info<string_class, param> {
7070
static string_class _(RT::PiDevice dev) {
7171
size_t resultSize;
72-
PI_CALL(RT::piDeviceGetInfo, dev, pi::cast<RT::PiDeviceInfo>(param), 0, nullptr,
73-
&resultSize);
72+
PI_CALL(piDeviceGetInfo)(dev, pi::cast<RT::PiDeviceInfo>(param), 0, nullptr,
73+
&resultSize);
7474
if (resultSize == 0) {
7575
return string_class();
7676
}
7777
unique_ptr_class<char[]> result(new char[resultSize]);
78-
PI_CALL(RT::piDeviceGetInfo, dev, pi::cast<RT::PiDeviceInfo>(param), resultSize,
79-
result.get(), nullptr);
78+
PI_CALL(piDeviceGetInfo)(dev, pi::cast<RT::PiDeviceInfo>(param), resultSize,
79+
result.get(), nullptr);
8080

8181
return string_class(result.get());
8282
}
@@ -91,8 +91,8 @@ template <typename T> struct get_device_info<T, info::device::parent_device> {
9191
template <info::device param> struct get_device_info<id<3>, param> {
9292
static id<3> _(RT::PiDevice dev) {
9393
size_t result[3];
94-
PI_CALL(RT::piDeviceGetInfo, dev, pi::cast<RT::PiDeviceInfo>(param),
95-
sizeof(result), &result, nullptr);
94+
PI_CALL(piDeviceGetInfo)(dev, pi::cast<RT::PiDeviceInfo>(param),
95+
sizeof(result), &result, nullptr);
9696
return id<3>(result[0], result[1], result[2]);
9797
}
9898
};
@@ -109,8 +109,8 @@ struct get_device_info<vector_class<info::fp_config>, param> {
109109
return {};
110110
}
111111
cl_device_fp_config result;
112-
PI_CALL(RT::piDeviceGetInfo, dev, pi::cast<RT::PiDeviceInfo>(param),
113-
sizeof(result), &result, nullptr);
112+
PI_CALL(piDeviceGetInfo)(dev, pi::cast<RT::PiDeviceInfo>(param),
113+
sizeof(result), &result, nullptr);
114114
return read_fp_bitfield(result);
115115
}
116116
};
@@ -121,9 +121,9 @@ struct get_device_info<vector_class<info::fp_config>,
121121
info::device::single_fp_config> {
122122
static vector_class<info::fp_config> _(RT::PiDevice dev) {
123123
cl_device_fp_config result;
124-
PI_CALL(RT::piDeviceGetInfo, dev,
125-
pi::cast<RT::PiDeviceInfo>(info::device::single_fp_config),
126-
sizeof(result), &result, nullptr);
124+
PI_CALL(piDeviceGetInfo)(
125+
dev, pi::cast<RT::PiDeviceInfo>(info::device::single_fp_config),
126+
sizeof(result), &result, nullptr);
127127
return read_fp_bitfield(result);
128128
}
129129
};
@@ -132,9 +132,9 @@ struct get_device_info<vector_class<info::fp_config>,
132132
template <> struct get_device_info<bool, info::device::queue_profiling> {
133133
static bool _(RT::PiDevice dev) {
134134
cl_command_queue_properties result;
135-
PI_CALL(RT::piDeviceGetInfo, dev,
136-
pi::cast<RT::PiDeviceInfo>(info::device::queue_profiling),
137-
sizeof(result), &result, nullptr);
135+
PI_CALL(piDeviceGetInfo)(
136+
dev, pi::cast<RT::PiDeviceInfo>(info::device::queue_profiling),
137+
sizeof(result), &result, nullptr);
138138
return (result & CL_QUEUE_PROFILING_ENABLE);
139139
}
140140
};
@@ -145,9 +145,9 @@ struct get_device_info<vector_class<info::execution_capability>,
145145
info::device::execution_capabilities> {
146146
static vector_class<info::execution_capability> _(RT::PiDevice dev) {
147147
cl_device_exec_capabilities result;
148-
PI_CALL(RT::piDeviceGetInfo, dev,
149-
pi::cast<RT::PiDeviceInfo>(info::device::execution_capabilities),
150-
sizeof(result), &result, nullptr);
148+
PI_CALL(piDeviceGetInfo)(
149+
dev, pi::cast<RT::PiDeviceInfo>(info::device::execution_capabilities),
150+
sizeof(result), &result, nullptr);
151151
return read_execution_bitfield(result);
152152
}
153153
};
@@ -182,16 +182,16 @@ struct get_device_info<vector_class<info::partition_property>,
182182
pi::cast<RT::PiDeviceInfo>(info::device::partition_properties);
183183

184184
size_t resultSize;
185-
PI_CALL(RT::piDeviceGetInfo, dev, info_partition, 0, nullptr, &resultSize);
185+
PI_CALL(piDeviceGetInfo)(dev, info_partition, 0, nullptr, &resultSize);
186186

187187
size_t arrayLength = resultSize / sizeof(cl_device_partition_property);
188188
if (arrayLength == 0) {
189189
return {};
190190
}
191191
unique_ptr_class<cl_device_partition_property[]> arrayResult(
192192
new cl_device_partition_property[arrayLength]);
193-
PI_CALL(RT::piDeviceGetInfo, dev, info_partition, resultSize, arrayResult.get(),
194-
nullptr);
193+
PI_CALL(piDeviceGetInfo)(dev, info_partition, resultSize, arrayResult.get(),
194+
nullptr);
195195

196196
vector_class<info::partition_property> result;
197197
for (size_t i = 0; i < arrayLength - 1; ++i) {
@@ -207,8 +207,8 @@ struct get_device_info<vector_class<info::partition_affinity_domain>,
207207
info::device::partition_affinity_domains> {
208208
static vector_class<info::partition_affinity_domain> _(RT::PiDevice dev) {
209209
cl_device_affinity_domain result;
210-
PI_CALL(
211-
RT::piDeviceGetInfo, dev,
210+
PI_CALL(piDeviceGetInfo)(
211+
dev,
212212
pi::cast<RT::PiDeviceInfo>(info::device::partition_affinity_domains),
213213
sizeof(result), &result, nullptr);
214214
return read_domain_bitfield(result);
@@ -222,18 +222,18 @@ struct get_device_info<info::partition_affinity_domain,
222222
info::device::partition_type_affinity_domain> {
223223
static info::partition_affinity_domain _(RT::PiDevice dev) {
224224
size_t resultSize;
225-
PI_CALL(RT::piDeviceGetInfo, dev,
226-
pi::cast<RT::PiDeviceInfo>(
227-
info::device::partition_type_affinity_domain),
228-
0, nullptr, &resultSize);
225+
PI_CALL(piDeviceGetInfo)(dev,
226+
pi::cast<RT::PiDeviceInfo>(
227+
info::device::partition_type_affinity_domain),
228+
0, nullptr, &resultSize);
229229
if (resultSize != 1) {
230230
return info::partition_affinity_domain::not_applicable;
231231
}
232232
cl_device_partition_property result;
233-
PI_CALL(RT::piDeviceGetInfo, dev,
234-
pi::cast<RT::PiDeviceInfo>(
235-
info::device::partition_type_affinity_domain),
236-
sizeof(result), &result, nullptr);
233+
PI_CALL(piDeviceGetInfo)(dev,
234+
pi::cast<RT::PiDeviceInfo>(
235+
info::device::partition_type_affinity_domain),
236+
sizeof(result), &result, nullptr);
237237
if (result == CL_DEVICE_AFFINITY_DOMAIN_NUMA ||
238238
result == CL_DEVICE_AFFINITY_DOMAIN_L4_CACHE ||
239239
result == CL_DEVICE_AFFINITY_DOMAIN_L3_CACHE ||
@@ -252,17 +252,17 @@ struct get_device_info<info::partition_property,
252252
info::device::partition_type_property> {
253253
static info::partition_property _(RT::PiDevice dev) {
254254
size_t resultSize;
255-
PI_CALL(RT::piDeviceGetInfo, dev, PI_DEVICE_INFO_PARTITION_TYPE, 0, nullptr,
256-
&resultSize);
255+
PI_CALL(piDeviceGetInfo)(dev, PI_DEVICE_INFO_PARTITION_TYPE, 0, nullptr,
256+
&resultSize);
257257
if (!resultSize)
258258
return info::partition_property::no_partition;
259259

260260
size_t arrayLength = resultSize / sizeof(cl_device_partition_property);
261261

262262
unique_ptr_class<cl_device_partition_property[]> arrayResult(
263263
new cl_device_partition_property[arrayLength]);
264-
PI_CALL(RT::piDeviceGetInfo, dev, PI_DEVICE_INFO_PARTITION_TYPE, resultSize,
265-
arrayResult.get(), nullptr);
264+
PI_CALL(piDeviceGetInfo)(dev, PI_DEVICE_INFO_PARTITION_TYPE, resultSize,
265+
arrayResult.get(), nullptr);
266266
if (!arrayResult[0])
267267
return info::partition_property::no_partition;
268268
return info::partition_property(arrayResult[0]);
@@ -273,14 +273,14 @@ template <>
273273
struct get_device_info<vector_class<size_t>, info::device::sub_group_sizes> {
274274
static vector_class<size_t> _(RT::PiDevice dev) {
275275
size_t resultSize = 0;
276-
PI_CALL(RT::piDeviceGetInfo, dev,
277-
pi::cast<RT::PiDeviceInfo>(info::device::sub_group_sizes), 0,
278-
nullptr, &resultSize);
276+
PI_CALL(piDeviceGetInfo)(
277+
dev, pi::cast<RT::PiDeviceInfo>(info::device::sub_group_sizes), 0,
278+
nullptr, &resultSize);
279279

280280
vector_class<size_t> result(resultSize / sizeof(size_t));
281-
PI_CALL(RT::piDeviceGetInfo, dev,
282-
pi::cast<RT::PiDeviceInfo>(info::device::sub_group_sizes),
283-
resultSize, result.data(), nullptr);
281+
PI_CALL(piDeviceGetInfo)(
282+
dev, pi::cast<RT::PiDeviceInfo>(info::device::sub_group_sizes),
283+
resultSize, result.data(), nullptr);
284284
return result;
285285
}
286286
};

sycl/include/CL/sycl/detail/event_info.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ template <info::event_profiling Param> struct get_event_profiling_info {
2222
static RetType _(RT::PiEvent Event) {
2323
RetType Result = 0;
2424
// TODO catch an exception and put it to list of asynchronous exceptions
25-
PI_CALL(RT::piEventGetProfilingInfo,
26-
Event, cl_profiling_info(Param), sizeof(Result), &Result, nullptr);
25+
PI_CALL(piEventGetProfilingInfo)(Event, cl_profiling_info(Param),
26+
sizeof(Result), &Result, nullptr);
2727
return Result;
2828
}
2929
};
@@ -34,8 +34,8 @@ template <info::event Param> struct get_event_info {
3434
static RetType _(RT::PiEvent Event) {
3535
RetType Result = (RetType)0;
3636
// TODO catch an exception and put it to list of asynchronous exceptions
37-
PI_CALL(RT::piEventGetInfo,
38-
Event, cl_profiling_info(Param), sizeof(Result), &Result, nullptr);
37+
PI_CALL(piEventGetInfo)(Event, cl_profiling_info(Param), sizeof(Result),
38+
&Result, nullptr);
3939
return Result;
4040
}
4141
};

sycl/include/CL/sycl/detail/image_impl.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -232,8 +232,8 @@ class image_impl final : public SYCLMemObjT<AllocatorT> {
232232
: BaseT(MemObject, SyclContext, std::move(AvailableEvent)),
233233
MRange(InitializedVal<Dimensions, range>::template get<0>()) {
234234
RT::PiMem Mem = pi::cast<RT::PiMem>(BaseT::MInteropMemObject);
235-
PI_CALL(RT::piMemGetInfo, Mem, CL_MEM_SIZE, sizeof(size_t),
236-
&(BaseT::MSizeInBytes), nullptr);
235+
PI_CALL(piMemGetInfo)(Mem, CL_MEM_SIZE, sizeof(size_t),
236+
&(BaseT::MSizeInBytes), nullptr);
237237

238238
RT::PiMemImageFormat Format;
239239
getImageInfo(PI_IMAGE_INFO_FORMAT, Format);
@@ -348,7 +348,7 @@ class image_impl final : public SYCLMemObjT<AllocatorT> {
348348
private:
349349
template <typename T> void getImageInfo(RT::PiMemImageInfo Info, T &Dest) {
350350
RT::PiMem Mem = pi::cast<RT::PiMem>(BaseT::MInteropMemObject);
351-
PI_CALL(RT::piMemImageGetInfo, Mem, Info, sizeof(T), &Dest, nullptr);
351+
PI_CALL(piMemImageGetInfo)(Mem, Info, sizeof(T), &Dest, nullptr);
352352
}
353353

354354
template <info::device Param>

sycl/include/CL/sycl/detail/kernel_impl.hpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,7 @@ class kernel_impl {
7373
cl_kernel get() const {
7474
if (is_host())
7575
throw invalid_object_error("This instance of kernel is a host instance");
76-
77-
PI_CALL(RT::piKernelRetain, MKernel);
76+
PI_CALL(piKernelRetain)(MKernel);
7877
return pi::cast<cl_kernel>(MKernel);
7978
}
8079

sycl/include/CL/sycl/detail/kernel_info.hpp

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,15 @@ template <info::kernel Param> struct get_kernel_info<string_class, Param> {
2424
static string_class _(RT::PiKernel Kernel) {
2525
size_t ResultSize;
2626
// TODO catch an exception and put it to list of asynchronous exceptions
27-
PI_CALL(RT::piKernelGetInfo,
28-
Kernel, cl_kernel_info(Param), 0, nullptr, &ResultSize);
27+
PI_CALL(piKernelGetInfo)(Kernel, cl_kernel_info(Param), 0, nullptr,
28+
&ResultSize);
2929
if (ResultSize == 0) {
3030
return "";
3131
}
3232
vector_class<char> Result(ResultSize);
3333
// TODO catch an exception and put it to list of asynchronous exceptions
34-
PI_CALL(RT::piKernelGetInfo,
35-
Kernel, cl_kernel_info(Param), ResultSize, Result.data(), nullptr);
34+
PI_CALL(piKernelGetInfo)(Kernel, cl_kernel_info(Param), ResultSize,
35+
Result.data(), nullptr);
3636
return string_class(Result.data());
3737
}
3838
};
@@ -41,8 +41,8 @@ template <info::kernel Param> struct get_kernel_info<cl_uint, Param> {
4141
static cl_uint _(RT::PiKernel Kernel) {
4242
cl_uint Result;
4343
// TODO catch an exception and put it to list of asynchronous exceptions
44-
PI_CALL(RT::piKernelGetInfo,
45-
Kernel, cl_kernel_info(Param), sizeof(cl_uint), &Result, nullptr);
44+
PI_CALL(piKernelGetInfo)(Kernel, cl_kernel_info(Param), sizeof(cl_uint),
45+
&Result, nullptr);
4646
return Result;
4747
}
4848
};
@@ -54,9 +54,9 @@ struct get_kernel_work_group_info {
5454
static T _(RT::PiKernel Kernel, RT::PiDevice Device) {
5555
T Result;
5656
// TODO catch an exception and put it to list of asynchronous exceptions
57-
PI_CALL(RT::piKernelGetGroupInfo,
58-
Kernel, Device, cl_kernel_work_group_info(Param),
59-
sizeof(T), &Result, nullptr);
57+
PI_CALL(piKernelGetGroupInfo)(Kernel, Device,
58+
cl_kernel_work_group_info(Param), sizeof(T),
59+
&Result, nullptr);
6060
return Result;
6161
}
6262
};
@@ -66,9 +66,9 @@ struct get_kernel_work_group_info<cl::sycl::range<3>, Param> {
6666
static cl::sycl::range<3> _(RT::PiKernel Kernel, RT::PiDevice Device) {
6767
size_t Result[3];
6868
// TODO catch an exception and put it to list of asynchronous exceptions
69-
PI_CALL(RT::piKernelGetGroupInfo,
70-
Kernel, Device, cl_kernel_work_group_info(Param),
71-
sizeof(size_t) * 3, Result, nullptr);
69+
PI_CALL(piKernelGetGroupInfo)(Kernel, Device,
70+
cl_kernel_work_group_info(Param),
71+
sizeof(size_t) * 3, Result, nullptr);
7272
return cl::sycl::range<3>(Result[0], Result[1], Result[2]);
7373
}
7474
};
@@ -109,9 +109,9 @@ struct get_kernel_sub_group_info {
109109
static TOut _(RT::PiKernel Kernel, RT::PiDevice Device) {
110110
TOut Result;
111111
// TODO catch an exception and put it to list of asynchronous exceptions
112-
PI_CALL(RT::piKernelGetSubGroupInfo,
113-
Kernel, Device, cl_kernel_sub_group_info(Param), 0, nullptr,
114-
sizeof(TOut), &Result, nullptr);
112+
PI_CALL(piKernelGetSubGroupInfo)(Kernel, Device,
113+
cl_kernel_sub_group_info(Param), 0,
114+
nullptr, sizeof(TOut), &Result, nullptr);
115115
return Result;
116116
}
117117
};
@@ -121,7 +121,7 @@ struct get_kernel_sub_group_info_with_input {
121121
static TOut _(RT::PiKernel Kernel, RT::PiDevice Device, TIn In) {
122122
TOut Result;
123123
// TODO catch an exception and put it to list of asynchronous exceptions
124-
PI_CALL(RT::piKernelGetSubGroupInfo,
124+
PI_CALL(piKernelGetSubGroupInfo)(
125125
Kernel, Device, cl_kernel_sub_group_info(Param), sizeof(TIn), &In,
126126
sizeof(TOut), &Result, nullptr);
127127
return Result;
@@ -135,9 +135,9 @@ struct get_kernel_sub_group_info_with_input<cl::sycl::range<3>, Param,
135135
size_t In) {
136136
size_t Result[3];
137137
// TODO catch an exception and put it to list of asynchronous exceptions
138-
PI_CALL(RT::piKernelGetSubGroupInfo,
139-
Kernel, Device, cl_kernel_sub_group_info(Param), sizeof(size_t),
140-
&In, sizeof(size_t) * 3, Result, nullptr);
138+
PI_CALL(piKernelGetSubGroupInfo)(
139+
Kernel, Device, cl_kernel_sub_group_info(Param), sizeof(size_t), &In,
140+
sizeof(size_t) * 3, Result, nullptr);
141141
return cl::sycl::range<3>(Result[0], Result[1], Result[2]);
142142
}
143143
};
@@ -150,7 +150,7 @@ struct get_kernel_sub_group_info_with_input<size_t, Param,
150150
size_t Input[3] = {In[0], In[1], In[2]};
151151
size_t Result;
152152
// TODO catch an exception and put it to list of asynchronous exceptions
153-
PI_CALL(RT::piKernelGetSubGroupInfo,
153+
PI_CALL(piKernelGetSubGroupInfo)(
154154
Kernel, Device, cl_kernel_sub_group_info(Param), sizeof(size_t) * 3,
155155
Input, sizeof(size_t), &Result, nullptr);
156156
return Result;

0 commit comments

Comments
 (0)