Skip to content

Commit d6023e8

Browse files
garimagubader
authored andcommitted
[SYCL] Re-route PI_CALL macro to PI_TRACE (#798)
Signed-off-by: Garima Gupta <[email protected]>
1 parent 0e7639a commit d6023e8

33 files changed

+445
-496
lines changed

sycl/include/CL/sycl/buffer.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,9 +148,9 @@ class buffer {
148148
: Range{0} {
149149

150150
size_t BufSize = 0;
151-
PI_CALL(detail::RT::piMemGetInfo(
151+
PI_CALL(detail::RT::piMemGetInfo,
152152
detail::pi::cast<detail::RT::PiMem>(MemObject), CL_MEM_SIZE,
153-
sizeof(size_t), &BufSize, nullptr));
153+
sizeof(size_t), &BufSize, nullptr);
154154

155155
Range[0] = BufSize / sizeof(T);
156156
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(RT::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: 54 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -48,19 +48,18 @@ 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(
52-
dev, pi::cast<RT::PiDeviceInfo>(param), sizeof(result), &result, NULL));
51+
PI_CALL(RT::piDeviceGetInfo, dev, pi::cast<RT::PiDeviceInfo>(param),
52+
sizeof(result), &result, nullptr);
5353
return T(result);
5454
}
5555
};
5656

5757
// Specialization for platform
58-
template <info::device param>
59-
struct get_device_info<platform, param> {
58+
template <info::device param> struct get_device_info<platform, param> {
6059
static platform _(RT::PiDevice dev) {
6160
typename sycl_to_pi<platform>::type result;
62-
PI_CALL(RT::piDeviceGetInfo(
63-
dev, pi::cast<RT::PiDeviceInfo>(param), sizeof(result), &result, NULL));
61+
PI_CALL(RT::piDeviceGetInfo, dev, pi::cast<RT::PiDeviceInfo>(param),
62+
sizeof(result), &result, nullptr);
6463
return createSyclObjFromImpl<platform>(
6564
std::make_shared<platform_impl_pi>(result));
6665
}
@@ -70,32 +69,30 @@ struct get_device_info<platform, param> {
7069
template <info::device param> struct get_device_info<string_class, param> {
7170
static string_class _(RT::PiDevice dev) {
7271
size_t resultSize;
73-
PI_CALL(RT::piDeviceGetInfo(
74-
dev, pi::cast<RT::PiDeviceInfo>(param), 0, NULL, &resultSize));
72+
PI_CALL(RT::piDeviceGetInfo, dev, pi::cast<RT::PiDeviceInfo>(param), 0, nullptr,
73+
&resultSize);
7574
if (resultSize == 0) {
7675
return string_class();
7776
}
7877
unique_ptr_class<char[]> result(new char[resultSize]);
79-
PI_CALL(RT::piDeviceGetInfo(
80-
dev, pi::cast<RT::PiDeviceInfo>(param),
81-
resultSize, result.get(), NULL));
78+
PI_CALL(RT::piDeviceGetInfo, dev, pi::cast<RT::PiDeviceInfo>(param), resultSize,
79+
result.get(), nullptr);
8280

8381
return string_class(result.get());
8482
}
8583
};
8684

8785
// Specialization for parent device
88-
template <typename T>
89-
struct get_device_info<T, info::device::parent_device> {
86+
template <typename T> struct get_device_info<T, info::device::parent_device> {
9087
static T _(RT::PiDevice dev);
9188
};
9289

9390
// Specialization for id return type
9491
template <info::device param> struct get_device_info<id<3>, param> {
9592
static id<3> _(RT::PiDevice dev) {
9693
size_t result[3];
97-
PI_CALL(RT::piDeviceGetInfo(
98-
dev, pi::cast<RT::PiDeviceInfo>(param), sizeof(result), &result, NULL));
94+
PI_CALL(RT::piDeviceGetInfo, dev, pi::cast<RT::PiDeviceInfo>(param),
95+
sizeof(result), &result, nullptr);
9996
return id<3>(result[0], result[1], result[2]);
10097
}
10198
};
@@ -112,21 +109,21 @@ struct get_device_info<vector_class<info::fp_config>, param> {
112109
return {};
113110
}
114111
cl_device_fp_config result;
115-
PI_CALL(RT::piDeviceGetInfo(
116-
dev, pi::cast<RT::PiDeviceInfo>(param), sizeof(result), &result, NULL));
112+
PI_CALL(RT::piDeviceGetInfo, dev, pi::cast<RT::PiDeviceInfo>(param),
113+
sizeof(result), &result, nullptr);
117114
return read_fp_bitfield(result);
118115
}
119116
};
120117

121118
// Specialization for single_fp_config, no type support check required
122119
template <>
123120
struct get_device_info<vector_class<info::fp_config>,
124-
info::device::single_fp_config> {
121+
info::device::single_fp_config> {
125122
static vector_class<info::fp_config> _(RT::PiDevice dev) {
126123
cl_device_fp_config result;
127-
PI_CALL(RT::piDeviceGetInfo(
128-
dev, pi::cast<RT::PiDeviceInfo>(info::device::single_fp_config),
129-
sizeof(result), &result, NULL));
124+
PI_CALL(RT::piDeviceGetInfo, dev,
125+
pi::cast<RT::PiDeviceInfo>(info::device::single_fp_config),
126+
sizeof(result), &result, nullptr);
130127
return read_fp_bitfield(result);
131128
}
132129
};
@@ -135,9 +132,9 @@ struct get_device_info<vector_class<info::fp_config>,
135132
template <> struct get_device_info<bool, info::device::queue_profiling> {
136133
static bool _(RT::PiDevice dev) {
137134
cl_command_queue_properties result;
138-
PI_CALL(RT::piDeviceGetInfo(
139-
dev, pi::cast<RT::PiDeviceInfo>(info::device::queue_profiling),
140-
sizeof(result), &result, NULL));
135+
PI_CALL(RT::piDeviceGetInfo, dev,
136+
pi::cast<RT::PiDeviceInfo>(info::device::queue_profiling),
137+
sizeof(result), &result, nullptr);
141138
return (result & CL_QUEUE_PROFILING_ENABLE);
142139
}
143140
};
@@ -148,9 +145,9 @@ struct get_device_info<vector_class<info::execution_capability>,
148145
info::device::execution_capabilities> {
149146
static vector_class<info::execution_capability> _(RT::PiDevice dev) {
150147
cl_device_exec_capabilities result;
151-
PI_CALL(RT::piDeviceGetInfo(
152-
dev, pi::cast<RT::PiDeviceInfo>(info::device::execution_capabilities),
153-
sizeof(result), &result, NULL));
148+
PI_CALL(RT::piDeviceGetInfo, dev,
149+
pi::cast<RT::PiDeviceInfo>(info::device::execution_capabilities),
150+
sizeof(result), &result, nullptr);
154151
return read_execution_bitfield(result);
155152
}
156153
};
@@ -168,8 +165,7 @@ struct get_device_info<vector_class<string_class>,
168165

169166
// Specialization for extensions, splits the string returned by OpenCL
170167
template <>
171-
struct get_device_info<vector_class<string_class>,
172-
info::device::extensions> {
168+
struct get_device_info<vector_class<string_class>, info::device::extensions> {
173169
static vector_class<string_class> _(RT::PiDevice dev) {
174170
string_class result =
175171
get_device_info<string_class, info::device::extensions>::_(dev);
@@ -183,19 +179,19 @@ struct get_device_info<vector_class<info::partition_property>,
183179
info::device::partition_properties> {
184180
static vector_class<info::partition_property> _(RT::PiDevice dev) {
185181
auto info_partition =
186-
pi::cast<RT::PiDeviceInfo>(info::device::partition_properties);
182+
pi::cast<RT::PiDeviceInfo>(info::device::partition_properties);
187183

188184
size_t resultSize;
189-
PI_CALL(RT::piDeviceGetInfo(dev, info_partition, 0, NULL, &resultSize));
185+
PI_CALL(RT::piDeviceGetInfo, dev, info_partition, 0, nullptr, &resultSize);
190186

191187
size_t arrayLength = resultSize / sizeof(cl_device_partition_property);
192188
if (arrayLength == 0) {
193189
return {};
194190
}
195191
unique_ptr_class<cl_device_partition_property[]> arrayResult(
196192
new cl_device_partition_property[arrayLength]);
197-
PI_CALL(RT::piDeviceGetInfo(
198-
dev, info_partition, resultSize, arrayResult.get(), NULL));
193+
PI_CALL(RT::piDeviceGetInfo, dev, info_partition, resultSize, arrayResult.get(),
194+
nullptr);
199195

200196
vector_class<info::partition_property> result;
201197
for (size_t i = 0; i < arrayLength - 1; ++i) {
@@ -211,9 +207,10 @@ struct get_device_info<vector_class<info::partition_affinity_domain>,
211207
info::device::partition_affinity_domains> {
212208
static vector_class<info::partition_affinity_domain> _(RT::PiDevice dev) {
213209
cl_device_affinity_domain result;
214-
PI_CALL(RT::piDeviceGetInfo(
215-
dev, pi::cast<RT::PiDeviceInfo>(info::device::partition_affinity_domains),
216-
sizeof(result), &result, NULL));
210+
PI_CALL(
211+
RT::piDeviceGetInfo, dev,
212+
pi::cast<RT::PiDeviceInfo>(info::device::partition_affinity_domains),
213+
sizeof(result), &result, nullptr);
217214
return read_domain_bitfield(result);
218215
}
219216
};
@@ -225,18 +222,18 @@ struct get_device_info<info::partition_affinity_domain,
225222
info::device::partition_type_affinity_domain> {
226223
static info::partition_affinity_domain _(RT::PiDevice dev) {
227224
size_t resultSize;
228-
PI_CALL(RT::piDeviceGetInfo(
229-
dev, pi::cast<RT::PiDeviceInfo>(
230-
info::device::partition_type_affinity_domain),
231-
0, NULL, &resultSize));
225+
PI_CALL(RT::piDeviceGetInfo, dev,
226+
pi::cast<RT::PiDeviceInfo>(
227+
info::device::partition_type_affinity_domain),
228+
0, nullptr, &resultSize);
232229
if (resultSize != 1) {
233230
return info::partition_affinity_domain::not_applicable;
234231
}
235232
cl_device_partition_property result;
236-
PI_CALL(RT::piDeviceGetInfo(
237-
dev, pi::cast<RT::PiDeviceInfo>(
238-
info::device::partition_type_affinity_domain),
239-
sizeof(result), &result, NULL));
233+
PI_CALL(RT::piDeviceGetInfo, dev,
234+
pi::cast<RT::PiDeviceInfo>(
235+
info::device::partition_type_affinity_domain),
236+
sizeof(result), &result, nullptr);
240237
if (result == CL_DEVICE_AFFINITY_DOMAIN_NUMA ||
241238
result == CL_DEVICE_AFFINITY_DOMAIN_L4_CACHE ||
242239
result == CL_DEVICE_AFFINITY_DOMAIN_L3_CACHE ||
@@ -255,36 +252,35 @@ struct get_device_info<info::partition_property,
255252
info::device::partition_type_property> {
256253
static info::partition_property _(RT::PiDevice dev) {
257254
size_t resultSize;
258-
PI_CALL(RT::piDeviceGetInfo(
259-
dev, PI_DEVICE_INFO_PARTITION_TYPE, 0, NULL, &resultSize));
255+
PI_CALL(RT::piDeviceGetInfo, dev, PI_DEVICE_INFO_PARTITION_TYPE, 0, nullptr,
256+
&resultSize);
260257
if (!resultSize)
261258
return info::partition_property::no_partition;
262259

263260
size_t arrayLength = resultSize / sizeof(cl_device_partition_property);
264261

265262
unique_ptr_class<cl_device_partition_property[]> arrayResult(
266263
new cl_device_partition_property[arrayLength]);
267-
PI_CALL(RT::piDeviceGetInfo(
268-
dev, PI_DEVICE_INFO_PARTITION_TYPE, resultSize, arrayResult.get(), 0));
264+
PI_CALL(RT::piDeviceGetInfo, dev, PI_DEVICE_INFO_PARTITION_TYPE, resultSize,
265+
arrayResult.get(), nullptr);
269266
if (!arrayResult[0])
270267
return info::partition_property::no_partition;
271268
return info::partition_property(arrayResult[0]);
272269
}
273270
};
274271
// Specialization for supported subgroup sizes
275272
template <>
276-
struct get_device_info<vector_class<size_t>,
277-
info::device::sub_group_sizes> {
273+
struct get_device_info<vector_class<size_t>, info::device::sub_group_sizes> {
278274
static vector_class<size_t> _(RT::PiDevice dev) {
279275
size_t resultSize = 0;
280-
PI_CALL(RT::piDeviceGetInfo(
281-
dev, pi::cast<RT::PiDeviceInfo>(info::device::sub_group_sizes),
282-
0, nullptr, &resultSize));
283-
284-
vector_class<size_t> result(resultSize/sizeof(size_t));
285-
PI_CALL(RT::piDeviceGetInfo(
286-
dev, pi::cast<RT::PiDeviceInfo>(info::device::sub_group_sizes),
287-
resultSize, result.data(), nullptr));
276+
PI_CALL(RT::piDeviceGetInfo, dev,
277+
pi::cast<RT::PiDeviceInfo>(info::device::sub_group_sizes), 0,
278+
nullptr, &resultSize);
279+
280+
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);
288284
return result;
289285
}
290286
};

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(RT::piEventGetProfilingInfo,
26+
Event, cl_profiling_info(Param), 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(RT::piEventGetInfo,
38+
Event, cl_profiling_info(Param), sizeof(Result), &Result, nullptr);
3939
return Result;
4040
}
4141
};

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

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

237237
RT::PiMemImageFormat Format;
238238
getImageInfo(PI_IMAGE_INFO_FORMAT, Format);
@@ -342,7 +342,7 @@ class image_impl final : public SYCLMemObjT<AllocatorT> {
342342
private:
343343
template <typename T> void getImageInfo(RT::PiMemImageInfo Info, T &Dest) {
344344
RT::PiMem Mem = pi::cast<RT::PiMem>(BaseT::MInteropMemObject);
345-
PI_CALL(RT::piMemImageGetInfo(Mem, Info, sizeof(T), &Dest, nullptr));
345+
PI_CALL(RT::piMemImageGetInfo, Mem, Info, sizeof(T), &Dest, nullptr);
346346
}
347347

348348
template <info::device Param>
@@ -516,7 +516,7 @@ class image_impl final : public SYCLMemObjT<AllocatorT> {
516516
image_channel_order MOrder;
517517
image_channel_type MType;
518518
uint8_t MNumChannels = 0; // Maximum Value - 4
519-
size_t MElementSize = 0; // Maximum Value - 16
519+
size_t MElementSize = 0; // Maximum Value - 16
520520
size_t MRowPitch = 0;
521521
size_t MSlicePitch = 0;
522522
};

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

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,13 @@ class kernel_impl {
3838
IsCreatedFromSource(IsCreatedFromSource) {
3939

4040
RT::PiContext Context = nullptr;
41-
PI_CALL(RT::piKernelGetInfo(
42-
Kernel, CL_KERNEL_CONTEXT, sizeof(Context), &Context, nullptr));
41+
PI_CALL(RT::piKernelGetInfo, Kernel, CL_KERNEL_CONTEXT, sizeof(Context),
42+
&Context, nullptr);
4343
auto ContextImpl = detail::getSyclObjImpl(SyclContext);
4444
if (ContextImpl->getHandleRef() != Context)
4545
throw cl::sycl::invalid_parameter_error(
4646
"Input context must be the same as the context of cl_kernel");
47-
PI_CALL(RT::piKernelRetain(Kernel));
47+
PI_CALL(RT::piKernelRetain, Kernel);
4848
}
4949

5050
// Host kernel constructor
@@ -55,15 +55,15 @@ class kernel_impl {
5555
~kernel_impl() {
5656
// TODO catch an exception and put it to list of asynchronous exceptions
5757
if (!is_host()) {
58-
PI_CALL(RT::piKernelRelease(Kernel));
58+
PI_CALL(RT::piKernelRelease, Kernel);
5959
}
6060
}
6161

6262
cl_kernel get() const {
6363
if (is_host()) {
6464
throw invalid_object_error("This instance of kernel is a host instance");
6565
}
66-
PI_CALL(RT::piKernelRetain(Kernel));
66+
PI_CALL(RT::piKernelRetain, Kernel);
6767
return pi::cast<cl_kernel>(Kernel);
6868
}
6969

@@ -94,8 +94,7 @@ class kernel_impl {
9494
return get_kernel_work_group_info<
9595
typename info::param_traits<info::kernel_work_group,
9696
param>::return_type,
97-
param>::_(this->getHandleRef(),
98-
getSyclObjImpl(Device)->getHandleRef());
97+
param>::_(this->getHandleRef(), getSyclObjImpl(Device)->getHandleRef());
9998
}
10099

101100
template <info::kernel_sub_group param>
@@ -105,10 +104,8 @@ class kernel_impl {
105104
throw runtime_error("Sub-group feature is not supported on HOST device.");
106105
}
107106
return get_kernel_sub_group_info<
108-
typename info::param_traits<info::kernel_sub_group,
109-
param>::return_type, param>::_(
110-
this->getHandleRef(),
111-
getSyclObjImpl(Device)->getHandleRef());
107+
typename info::param_traits<info::kernel_sub_group, param>::return_type,
108+
param>::_(this->getHandleRef(), getSyclObjImpl(Device)->getHandleRef());
112109
}
113110

114111
template <info::kernel_sub_group param>
@@ -123,9 +120,9 @@ class kernel_impl {
123120
return get_kernel_sub_group_info_with_input<
124121
typename info::param_traits<info::kernel_sub_group, param>::return_type,
125122
param,
126-
typename info::param_traits<info::kernel_sub_group, param>::input_type>::_(
127-
this->getHandleRef(),
128-
getSyclObjImpl(Device)->getHandleRef(), Value);
123+
typename info::param_traits<info::kernel_sub_group, param>::
124+
input_type>::_(this->getHandleRef(),
125+
getSyclObjImpl(Device)->getHandleRef(), Value);
129126
}
130127

131128
RT::PiKernel &getHandleRef() { return Kernel; }

0 commit comments

Comments
 (0)