Skip to content

Commit 6a8183c

Browse files
smaslov-intelbader
authored andcommitted
[SYCL][NFC] Remove "pi" prefix from the SYCL utilities names in the "pi" namespace (#524)
Now only types and functions directly constituting the PI API have "pi" in their names. Signed-off-by: Sergey V Maslov <[email protected]>
1 parent e438d2b commit 6a8183c

30 files changed

+132
-133
lines changed

sycl/include/CL/sycl/buffer.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ class buffer {
139139

140140
size_t BufSize = 0;
141141
PI_CALL(detail::RT::piMemGetInfo(
142-
detail::pi::pi_cast<detail::RT::PiMem>(MemObject), CL_MEM_SIZE,
142+
detail::pi::cast<detail::RT::PiMem>(MemObject), CL_MEM_SIZE,
143143
sizeof(size_t), &BufSize, nullptr));
144144

145145
Range[0] = BufSize / sizeof(T);

sycl/include/CL/sycl/detail/clusm.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,8 @@ inline cl::sycl::detail::usm::CLUSM *GetCLUSM() {
122122
}
123123

124124
cl::sycl::detail::usm::CLUSM *retVal = nullptr;
125-
if (cl::sycl::detail::pi::piUseBackend(
126-
cl::sycl::detail::pi::PiBackend::SYCL_BE_PI_OPENCL)) {
125+
if (cl::sycl::detail::pi::useBackend(
126+
cl::sycl::detail::pi::Backend::SYCL_BE_PI_OPENCL)) {
127127
retVal = gCLUSM;
128128
}
129129
return retVal;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ 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::pi_cast<pi_context_info>(param),
25+
PI_CALL(RT::piContextGetInfo(ctx, pi::cast<pi_context_info>(param),
2626
sizeof(Result), &Result, nullptr));
2727
return Result;
2828
}

sycl/include/CL/sycl/detail/device_impl.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ class device_impl_pi : public device_impl {
122122
PI_CALL(RT::piDeviceRetain(m_device));
123123
}
124124
// TODO: check that device is an OpenCL interop one
125-
return pi::pi_cast<cl_device_id>(m_device);
125+
return pi::cast<cl_device_id>(m_device);
126126
}
127127

128128
RT::PiDevice &getHandleRef() override { return m_device; }

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

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ template <typename T, info::device param> struct get_device_info {
4949
static T _(RT::PiDevice dev) {
5050
typename sycl_to_pi<T>::type result;
5151
PI_CALL(RT::piDeviceGetInfo(
52-
dev, pi::pi_cast<RT::PiDeviceInfo>(param), sizeof(result), &result, NULL));
52+
dev, pi::cast<RT::PiDeviceInfo>(param), sizeof(result), &result, NULL));
5353
return T(result);
5454
}
5555
};
@@ -60,7 +60,7 @@ struct get_device_info<platform, param> {
6060
static platform _(RT::PiDevice dev) {
6161
typename sycl_to_pi<platform>::type result;
6262
PI_CALL(RT::piDeviceGetInfo(
63-
dev, pi::pi_cast<RT::PiDeviceInfo>(param), sizeof(result), &result, NULL));
63+
dev, pi::cast<RT::PiDeviceInfo>(param), sizeof(result), &result, NULL));
6464
return createSyclObjFromImpl<platform>(
6565
std::make_shared<platform_impl_pi>(result));
6666
}
@@ -71,13 +71,13 @@ template <info::device param> struct get_device_info<string_class, param> {
7171
static string_class _(RT::PiDevice dev) {
7272
size_t resultSize;
7373
PI_CALL(RT::piDeviceGetInfo(
74-
dev, pi::pi_cast<RT::PiDeviceInfo>(param), 0, NULL, &resultSize));
74+
dev, pi::cast<RT::PiDeviceInfo>(param), 0, NULL, &resultSize));
7575
if (resultSize == 0) {
7676
return string_class();
7777
}
7878
unique_ptr_class<char[]> result(new char[resultSize]);
7979
PI_CALL(RT::piDeviceGetInfo(
80-
dev, pi::pi_cast<RT::PiDeviceInfo>(param),
80+
dev, pi::cast<RT::PiDeviceInfo>(param),
8181
resultSize, result.get(), NULL));
8282

8383
return string_class(result.get());
@@ -95,7 +95,7 @@ template <info::device param> struct get_device_info<id<3>, param> {
9595
static id<3> _(RT::PiDevice dev) {
9696
size_t result[3];
9797
PI_CALL(RT::piDeviceGetInfo(
98-
dev, pi::pi_cast<RT::PiDeviceInfo>(param), sizeof(result), &result, NULL));
98+
dev, pi::cast<RT::PiDeviceInfo>(param), sizeof(result), &result, NULL));
9999
return id<3>(result[0], result[1], result[2]);
100100
}
101101
};
@@ -113,7 +113,7 @@ struct get_device_info<vector_class<info::fp_config>, param> {
113113
}
114114
cl_device_fp_config result;
115115
PI_CALL(RT::piDeviceGetInfo(
116-
dev, pi::pi_cast<RT::PiDeviceInfo>(param), sizeof(result), &result, NULL));
116+
dev, pi::cast<RT::PiDeviceInfo>(param), sizeof(result), &result, NULL));
117117
return read_fp_bitfield(result);
118118
}
119119
};
@@ -125,7 +125,7 @@ struct get_device_info<vector_class<info::fp_config>,
125125
static vector_class<info::fp_config> _(RT::PiDevice dev) {
126126
cl_device_fp_config result;
127127
PI_CALL(RT::piDeviceGetInfo(
128-
dev, pi::pi_cast<RT::PiDeviceInfo>(info::device::single_fp_config),
128+
dev, pi::cast<RT::PiDeviceInfo>(info::device::single_fp_config),
129129
sizeof(result), &result, NULL));
130130
return read_fp_bitfield(result);
131131
}
@@ -136,7 +136,7 @@ template <> struct get_device_info<bool, info::device::queue_profiling> {
136136
static bool _(RT::PiDevice dev) {
137137
cl_command_queue_properties result;
138138
PI_CALL(RT::piDeviceGetInfo(
139-
dev, pi::pi_cast<RT::PiDeviceInfo>(info::device::queue_profiling),
139+
dev, pi::cast<RT::PiDeviceInfo>(info::device::queue_profiling),
140140
sizeof(result), &result, NULL));
141141
return (result & CL_QUEUE_PROFILING_ENABLE);
142142
}
@@ -149,7 +149,7 @@ struct get_device_info<vector_class<info::execution_capability>,
149149
static vector_class<info::execution_capability> _(RT::PiDevice dev) {
150150
cl_device_exec_capabilities result;
151151
PI_CALL(RT::piDeviceGetInfo(
152-
dev, pi::pi_cast<RT::PiDeviceInfo>(info::device::execution_capabilities),
152+
dev, pi::cast<RT::PiDeviceInfo>(info::device::execution_capabilities),
153153
sizeof(result), &result, NULL));
154154
return read_execution_bitfield(result);
155155
}
@@ -183,7 +183,7 @@ struct get_device_info<vector_class<info::partition_property>,
183183
info::device::partition_properties> {
184184
static vector_class<info::partition_property> _(RT::PiDevice dev) {
185185
auto info_partition =
186-
pi::pi_cast<RT::PiDeviceInfo>(info::device::partition_properties);
186+
pi::cast<RT::PiDeviceInfo>(info::device::partition_properties);
187187

188188
size_t resultSize;
189189
PI_CALL(RT::piDeviceGetInfo(dev, info_partition, 0, NULL, &resultSize));
@@ -212,7 +212,7 @@ struct get_device_info<vector_class<info::partition_affinity_domain>,
212212
static vector_class<info::partition_affinity_domain> _(RT::PiDevice dev) {
213213
cl_device_affinity_domain result;
214214
PI_CALL(RT::piDeviceGetInfo(
215-
dev, pi::pi_cast<RT::PiDeviceInfo>(info::device::partition_affinity_domains),
215+
dev, pi::cast<RT::PiDeviceInfo>(info::device::partition_affinity_domains),
216216
sizeof(result), &result, NULL));
217217
return read_domain_bitfield(result);
218218
}
@@ -226,15 +226,15 @@ struct get_device_info<info::partition_affinity_domain,
226226
static info::partition_affinity_domain _(RT::PiDevice dev) {
227227
size_t resultSize;
228228
PI_CALL(RT::piDeviceGetInfo(
229-
dev, pi::pi_cast<RT::PiDeviceInfo>(
229+
dev, pi::cast<RT::PiDeviceInfo>(
230230
info::device::partition_type_affinity_domain),
231231
0, NULL, &resultSize));
232232
if (resultSize != 1) {
233233
return info::partition_affinity_domain::not_applicable;
234234
}
235235
cl_device_partition_property result;
236236
PI_CALL(RT::piDeviceGetInfo(
237-
dev, pi::pi_cast<RT::PiDeviceInfo>(
237+
dev, pi::cast<RT::PiDeviceInfo>(
238238
info::device::partition_type_affinity_domain),
239239
sizeof(result), &result, NULL));
240240
if (result == CL_DEVICE_AFFINITY_DOMAIN_NUMA ||
@@ -278,12 +278,12 @@ struct get_device_info<vector_class<size_t>,
278278
static vector_class<size_t> _(RT::PiDevice dev) {
279279
size_t resultSize = 0;
280280
PI_CALL(RT::piDeviceGetInfo(
281-
dev, pi::pi_cast<RT::PiDeviceInfo>(info::device::sub_group_sizes),
281+
dev, pi::cast<RT::PiDeviceInfo>(info::device::sub_group_sizes),
282282
0, nullptr, &resultSize));
283283

284284
vector_class<size_t> result(resultSize/sizeof(size_t));
285285
PI_CALL(RT::piDeviceGetInfo(
286-
dev, pi::pi_cast<RT::PiDeviceInfo>(info::device::sub_group_sizes),
286+
dev, pi::cast<RT::PiDeviceInfo>(info::device::sub_group_sizes),
287287
resultSize, result.data(), nullptr));
288288
return result;
289289
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ class image_impl final : public SYCLMemObjT<AllocatorT> {
229229
image_impl(cl_mem MemObject, const context &SyclContext,
230230
event AvailableEvent = {})
231231
: BaseT(MemObject, SyclContext, std::move(AvailableEvent)) {
232-
RT::PiMem Mem = pi::pi_cast<RT::PiMem>(BaseT::MInteropMemObject);
232+
RT::PiMem Mem = pi::cast<RT::PiMem>(BaseT::MInteropMemObject);
233233
PI_CALL(RT::piMemGetInfo(Mem, CL_MEM_SIZE, sizeof(size_t),
234234
&(BaseT::MSizeInBytes), nullptr));
235235

@@ -340,7 +340,7 @@ class image_impl final : public SYCLMemObjT<AllocatorT> {
340340

341341
private:
342342
template <typename T> void getImageInfo(RT::PiMemImageInfo Info, T &Dest) {
343-
RT::PiMem Mem = pi::pi_cast<RT::PiMem>(BaseT::MInteropMemObject);
343+
RT::PiMem Mem = pi::cast<RT::PiMem>(BaseT::MInteropMemObject);
344344
PI_CALL(RT::piMemImageGetInfo(Mem, Info, sizeof(T), &Dest, nullptr));
345345
}
346346

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ class kernel_impl {
6363
throw invalid_object_error("This instance of kernel is a host instance");
6464
}
6565
PI_CALL(RT::piKernelRetain(Kernel));
66-
return pi::pi_cast<cl_kernel>(Kernel);
66+
return pi::cast<cl_kernel>(Kernel);
6767
}
6868

6969
bool is_host() const { return Context.is_host(); }

sycl/include/CL/sycl/detail/pi.hpp

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ namespace pi {
2121
// For selection of SYCL RT back-end, now manually through the "SYCL_BE"
2222
// environment variable.
2323
//
24-
enum PiBackend {
24+
enum Backend {
2525
SYCL_BE_PI_OPENCL,
2626
SYCL_BE_PI_OTHER
2727
};
2828

2929
// Check for manually selected BE at run-time.
30-
bool piUseBackend(PiBackend Backend);
30+
bool useBackend(Backend Backend);
3131

3232
using PiResult = ::pi_result;
3333
using PiPlatform = ::pi_platform;
@@ -55,19 +55,19 @@ namespace pi {
5555
std::string platformInfoToString(pi_platform_info info);
5656

5757
// Report error and no return (keeps compiler happy about no return statements).
58-
[[noreturn]] void piDie(const char *Message);
59-
void piAssert(bool Condition, const char *Message = nullptr);
58+
[[noreturn]] void die(const char *Message);
59+
void assertion(bool Condition, const char *Message = nullptr);
6060

6161
// Want all the needed casts be explicit, do not define conversion operators.
6262
template<class To, class From>
63-
To pi_cast(From value);
63+
To cast(From value);
6464

6565
// Forward declarations of the PI dispatch entries.
6666
#define _PI_API(api) __SYCL_EXPORTED extern decltype(::api) * api;
6767
#include <CL/sycl/detail/pi.def>
6868

6969
// Performs PI one-time initialization.
70-
void piInitialize();
70+
void initialize();
7171

7272
// The PiCall helper structure facilitates performing a call to PI.
7373
// It holds utilities to do the tracing and to check the returned result.
@@ -126,7 +126,7 @@ namespace pi {
126126
if (m_TraceEnabled)
127127
printArgs(args...);
128128

129-
piInitialize();
129+
initialize();
130130
auto r = m_FnPtr(args...);
131131

132132
if (m_TraceEnabled) {
@@ -145,35 +145,35 @@ namespace pi {
145145
namespace RT = cl::sycl::detail::pi;
146146

147147
#define PI_ASSERT(cond, msg) \
148-
RT::piAssert((cond), "assert @ " __FILE__ ":" STRINGIFY_LINE(__LINE__) msg);
148+
RT::assertion((cond), "assert @ " __FILE__ ":" STRINGIFY_LINE(__LINE__) msg);
149149

150150
#define PI_TRACE(func) RT::Trace<decltype(func)>(func, #func)
151151

152152
// This does the call, the trace and the check for no errors.
153153
#define PI_CALL(pi) \
154-
RT::piInitialize(), \
154+
RT::initialize(), \
155155
RT::PiCall(#pi).check<cl::sycl::runtime_error>( \
156-
RT::pi_cast<detail::RT::PiResult>(pi))
156+
RT::cast<detail::RT::PiResult>(pi))
157157

158158
// This does the trace, the call, and returns the result
159159
#define PI_CALL_RESULT(pi) \
160-
RT::PiCall(#pi).get(detail::RT::pi_cast<detail::RT::PiResult>(pi))
160+
RT::PiCall(#pi).get(detail::RT::cast<detail::RT::PiResult>(pi))
161161

162162
// This does the check for no errors and possibly throws
163163
#define PI_CHECK(pi) \
164164
RT::PiCall().check<cl::sycl::runtime_error>( \
165-
RT::pi_cast<detail::RT::PiResult>(pi))
165+
RT::cast<detail::RT::PiResult>(pi))
166166

167167
// This does the check for no errors and possibly throws x
168168
#define PI_CHECK_THROW(pi, x) \
169169
RT::PiCall().check<x>( \
170-
RT::pi_cast<detail::RT::PiResult>(pi))
170+
RT::cast<detail::RT::PiResult>(pi))
171171

172172
// Want all the needed casts be explicit, do not define conversion operators.
173173
template<class To, class From>
174-
To pi::pi_cast(From value) {
174+
To pi::cast(From value) {
175175
// TODO: see if more sanity checks are possible.
176-
PI_ASSERT(sizeof(From) == sizeof(To), "pi_cast failed size check");
176+
PI_ASSERT(sizeof(From) == sizeof(To), "cast failed size check");
177177
return (To)(value);
178178
}
179179

sycl/include/CL/sycl/detail/platform_impl.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ class platform_impl_pi : public platform_impl {
7070
return (all_extension_names.find(extension_name) != std::string::npos);
7171
}
7272

73-
cl_platform_id get() const override { return pi::pi_cast<cl_platform_id>(m_platform); }
73+
cl_platform_id get() const override { return pi::cast<cl_platform_id>(m_platform); }
7474

7575
const RT::PiPlatform &getHandleRef() const override { return m_platform; }
7676

sycl/include/CL/sycl/detail/platform_info.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,14 @@ struct get_platform_info<string_class, param> {
2525
size_t resultSize;
2626
// TODO catch an exception and put it to list of asynchronous exceptions
2727
PI_CALL(RT::piPlatformGetInfo(
28-
plt, pi::pi_cast<pi_platform_info>(param), 0, 0, &resultSize));
28+
plt, pi::cast<pi_platform_info>(param), 0, 0, &resultSize));
2929
if (resultSize == 0) {
3030
return "";
3131
}
3232
unique_ptr_class<char[]> result(new char[resultSize]);
3333
// TODO catch an exception and put it to list of asynchronous exceptions
3434
PI_CALL(RT::piPlatformGetInfo(
35-
plt, pi::pi_cast<pi_platform_info>(param), resultSize, result.get(), 0));
35+
plt, pi::cast<pi_platform_info>(param), resultSize, result.get(), 0));
3636
return result.get();
3737
}
3838
};

sycl/include/CL/sycl/detail/program_impl.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ class program_impl {
169169
throw invalid_object_error("This instance of program is a host instance");
170170
}
171171
PI_CALL(RT::piProgramRetain(Program));
172-
return pi::pi_cast<cl_program>(Program);
172+
return pi::cast<cl_program>(Program);
173173
}
174174

175175
bool is_host() const { return Context.is_host(); }

sycl/include/CL/sycl/detail/queue_impl.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class queue_impl {
4545
: m_Context(SyclContext), m_AsyncHandler(AsyncHandler),
4646
m_OpenCLInterop(true), m_HostQueue(false) {
4747

48-
m_CommandQueue = pi::pi_cast<RT::PiQueue>(CLQueue);
48+
m_CommandQueue = pi::cast<RT::PiQueue>(CLQueue);
4949

5050
RT::PiDevice Device = nullptr;
5151
// TODO catch an exception and put it to list of asynchronous exceptions
@@ -73,7 +73,7 @@ class queue_impl {
7373
cl_command_queue get() {
7474
if (m_OpenCLInterop) {
7575
PI_CALL(RT::piQueueRetain(m_CommandQueue));
76-
return pi::pi_cast<cl_command_queue>(m_CommandQueue);
76+
return pi::cast<cl_command_queue>(m_CommandQueue);
7777
}
7878
throw invalid_object_error(
7979
"This instance of queue doesn't support OpenCL interoperability");

sycl/include/CL/sycl/detail/sycl_mem_obj_t.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ template <typename AllocatorT> class SYCLMemObjT : public SYCLMemObjI {
8484
"Creation of interoperability memory object using host context is "
8585
"not allowed");
8686

87-
RT::PiMem Mem = pi::pi_cast<RT::PiMem>(MInteropMemObject);
87+
RT::PiMem Mem = pi::cast<RT::PiMem>(MInteropMemObject);
8888
RT::PiContext Context = nullptr;
8989
PI_CALL(RT::piMemGetInfo(Mem, CL_MEM_CONTEXT, sizeof(Context), &Context,
9090
nullptr));
@@ -225,7 +225,7 @@ template <typename AllocatorT> class SYCLMemObjT : public SYCLMemObjI {
225225
releaseHostMem(MShadowCopy);
226226

227227
if (MOpenCLInterop)
228-
PI_CALL(RT::piMemRelease(pi::pi_cast<RT::PiMem>(MInteropMemObject)));
228+
PI_CALL(RT::piMemRelease(pi::cast<RT::PiMem>(MInteropMemObject)));
229229
}
230230

231231
bool useHostPtr() {

sycl/include/CL/sycl/kernel.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class kernel {
2828
public:
2929
kernel(cl_kernel clKernel, const context &syclContext)
3030
: impl(std::make_shared<detail::kernel_impl>(
31-
detail::pi::pi_cast<detail::RT::PiKernel>(clKernel), syclContext)) {}
31+
detail::pi::cast<detail::RT::PiKernel>(clKernel), syclContext)) {}
3232

3333
kernel(const kernel &rhs) = default;
3434

sycl/include/CL/sycl/program.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class program {
4747

4848
program(const context &context, cl_program clProgram)
4949
: impl(std::make_shared<detail::program_impl>(
50-
context, detail::pi::pi_cast<detail::RT::PiProgram>(clProgram))) {}
50+
context, detail::pi::cast<detail::RT::PiProgram>(clProgram))) {}
5151

5252
program(const program &rhs) = default;
5353

sycl/source/detail/context_impl.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ context_impl::context_impl(cl_context ClContext, async_handler AsyncHandler)
5050
: m_AsyncHandler(AsyncHandler), m_Devices(),
5151
m_Platform(), m_OpenCLInterop(true), m_HostContext(false) {
5252

53-
m_Context = pi::pi_cast<RT::PiContext>(ClContext);
53+
m_Context = pi::cast<RT::PiContext>(ClContext);
5454
vector_class<RT::PiDevice> DeviceIds;
5555
size_t DevicesNum = 0;
5656
// TODO catch an exception and put it to list of asynchronous exceptions
@@ -77,7 +77,7 @@ cl_context context_impl::get() const {
7777
if (m_OpenCLInterop) {
7878
// TODO catch an exception and put it to list of asynchronous exceptions
7979
PI_CALL(RT::piContextRetain(m_Context));
80-
return pi::pi_cast<cl_context>(m_Context);
80+
return pi::cast<cl_context>(m_Context);
8181
}
8282
throw invalid_object_error(
8383
"This instance of event doesn't support OpenCL interoperability.");

0 commit comments

Comments
 (0)