Skip to content

Commit 092367b

Browse files
authored
[SYCL] Replaces some of the CL_* enums with PI_* enums. (#1239)
Signed-off-by: Rehana Begam <[email protected]>
1 parent eb373c4 commit 092367b

File tree

12 files changed

+257
-158
lines changed

12 files changed

+257
-158
lines changed

sycl/include/CL/sycl/detail/pi.h

Lines changed: 218 additions & 122 deletions
Large diffs are not rendered by default.

sycl/include/CL/sycl/queue.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ class queue {
290290
/// \param Length is a number of bytes in the allocation.
291291
/// \param Advice is a device-defined advice for the specified allocation.
292292
/// \return an event representing advice operation.
293-
event mem_advise(const void *Ptr, size_t Length, int Advice);
293+
event mem_advise(const void *Ptr, size_t Length, pi_mem_advice Advice);
294294

295295
/// Provides hints to the runtime library that data should be made available
296296
/// on a device earlier than Unified Shared Memory would normally require it

sycl/source/detail/error_handling/enqueue_kernel.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ bool oclHandleInvalidWorkGroupSize(const device_impl &DeviceImpl,
4040

4141
size_t CompileWGSize[3] = {0};
4242
Plugin.call<PiApiKind::piKernelGetGroupInfo>(
43-
Kernel, Device, PI_KERNEL_COMPILE_GROUP_INFO_SIZE, sizeof(size_t) * 3,
44-
CompileWGSize, nullptr);
43+
Kernel, Device, PI_KERNEL_GROUP_INFO_COMPILE_WORK_GROUP_SIZE,
44+
sizeof(size_t) * 3, CompileWGSize, nullptr);
4545

4646
if (CompileWGSize[0] != 0) {
4747
// OpenCL 1.x && 2.0:
@@ -90,10 +90,11 @@ bool oclHandleInvalidWorkGroupSize(const device_impl &DeviceImpl,
9090
// PI_INVALID_WORK_GROUP_SIZE if local_work_size is specified and the
9191
// total number of work-items in the work-group computed as
9292
// local_work_size[0] * ... * local_work_size[work_dim – 1] is greater
93-
// than the value specified by PI_KERNEL_GROUP_INFO_SIZE in table 5.21.
93+
// than the value specified by PI_KERNEL_GROUP_INFO_WORK_GROUP_SIZE in
94+
// table 5.21.
9495
size_t KernelWGSize = 0;
9596
Plugin.call<PiApiKind::piKernelGetGroupInfo>(
96-
Kernel, Device, PI_KERNEL_GROUP_INFO_SIZE, sizeof(size_t),
97+
Kernel, Device, PI_KERNEL_GROUP_INFO_WORK_GROUP_SIZE, sizeof(size_t),
9798
&KernelWGSize, nullptr);
9899
const size_t TotalNumberOfWIs =
99100
NDRDesc.LocalSize[0] * NDRDesc.LocalSize[1] * NDRDesc.LocalSize[2];

sycl/source/detail/event_impl.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,7 @@ RT::PiEvent &event_impl::getHandleRef() { return MEvent; }
6262

6363
const ContextImplPtr &event_impl::getContextImpl() { return MContext; }
6464

65-
const plugin &event_impl::getPlugin() const {
66-
return MContext->getPlugin();
67-
}
65+
const plugin &event_impl::getPlugin() const { return MContext->getPlugin(); }
6866

6967
void event_impl::setContextImpl(const ContextImplPtr &Context) {
7068
MHostEvent = Context->is_host();
@@ -84,8 +82,9 @@ event_impl::event_impl(RT::PiEvent Event, const context &SyclContext)
8482
}
8583

8684
RT::PiContext TempContext;
87-
getPlugin().call<PiApiKind::piEventGetInfo>(
88-
MEvent, CL_EVENT_CONTEXT, sizeof(RT::PiContext), &TempContext, nullptr);
85+
getPlugin().call<PiApiKind::piEventGetInfo>(MEvent, PI_EVENT_INFO_CONTEXT,
86+
sizeof(RT::PiContext),
87+
&TempContext, nullptr);
8988
if (MContext->getHandleRef() != TempContext) {
9089
throw cl::sycl::invalid_parameter_error(
9190
"The syclContext must match the OpenCL context associated with the "

sycl/source/detail/event_info.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ template <info::event Param> struct get_event_info {
3636
static RetType get(RT::PiEvent Event, const plugin &Plugin) {
3737
RetType Result = (RetType)0;
3838
// TODO catch an exception and put it to list of asynchronous exceptions
39-
Plugin.call<PiApiKind::piEventGetInfo>(Event, cl_profiling_info(Param),
39+
Plugin.call<PiApiKind::piEventGetInfo>(Event, pi_event_info(Param),
4040
sizeof(Result), &Result, nullptr);
4141
return Result;
4242
}

sycl/source/detail/program_impl.cpp

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,11 @@ program_impl::program_impl(ContextImplPtr Context, RT::PiProgram Program)
8484
: MProgram(Program), MContext(Context), MLinkable(true) {
8585

8686
// TODO handle the case when cl_program build is in progress
87-
cl_uint NumDevices;
87+
pi_uint32 NumDevices;
8888
const detail::plugin &Plugin = getPlugin();
89-
Plugin.call<PiApiKind::piProgramGetInfo>(
90-
Program, PI_PROGRAM_INFO_NUM_DEVICES, sizeof(cl_uint), &NumDevices, nullptr);
89+
Plugin.call<PiApiKind::piProgramGetInfo>(Program, PI_PROGRAM_INFO_NUM_DEVICES,
90+
sizeof(pi_uint32), &NumDevices,
91+
nullptr);
9192
vector_class<RT::PiDevice> PiDevices(NumDevices);
9293
Plugin.call<PiApiKind::piProgramGetInfo>(Program, PI_PROGRAM_INFO_DEVICES,
9394
sizeof(RT::PiDevice) * NumDevices,
@@ -267,8 +268,8 @@ vector_class<vector_class<char>> program_impl::get_binaries() const {
267268
if (!is_host()) {
268269
vector_class<size_t> BinarySizes(MDevices.size());
269270
Plugin.call<PiApiKind::piProgramGetInfo>(
270-
MProgram, PI_PROGRAM_INFO_BINARY_SIZES, sizeof(size_t) * BinarySizes.size(),
271-
BinarySizes.data(), nullptr);
271+
MProgram, PI_PROGRAM_INFO_BINARY_SIZES,
272+
sizeof(size_t) * BinarySizes.size(), BinarySizes.data(), nullptr);
272273

273274
vector_class<char *> Pointers;
274275
for (size_t I = 0; I < BinarySizes.size(); ++I) {
@@ -337,12 +338,12 @@ vector_class<RT::PiDevice> program_impl::get_pi_devices() const {
337338
bool program_impl::has_cl_kernel(const string_class &KernelName) const {
338339
size_t Size;
339340
const detail::plugin &Plugin = getPlugin();
340-
Plugin.call<PiApiKind::piProgramGetInfo>(MProgram, PI_PROGRAM_INFO_KERNEL_NAMES, 0,
341-
nullptr, &Size);
341+
Plugin.call<PiApiKind::piProgramGetInfo>(
342+
MProgram, PI_PROGRAM_INFO_KERNEL_NAMES, 0, nullptr, &Size);
342343
string_class ClResult(Size, ' ');
343-
Plugin.call<PiApiKind::piProgramGetInfo>(MProgram, PI_PROGRAM_INFO_KERNEL_NAMES,
344-
ClResult.size(), &ClResult[0],
345-
nullptr);
344+
Plugin.call<PiApiKind::piProgramGetInfo>(
345+
MProgram, PI_PROGRAM_INFO_KERNEL_NAMES, ClResult.size(), &ClResult[0],
346+
nullptr);
346347
// Get rid of the null terminator
347348
ClResult.pop_back();
348349
vector_class<string_class> KernelNames(split_string(ClResult, ';'));
@@ -411,10 +412,11 @@ cl_uint program_impl::get_info<info::program::reference_count>() const {
411412
throw invalid_object_error("This instance of program is a host instance",
412413
PI_INVALID_PROGRAM);
413414
}
414-
cl_uint Result;
415+
pi_uint32 Result;
415416
const detail::plugin &Plugin = getPlugin();
416-
Plugin.call<PiApiKind::piProgramGetInfo>(MProgram, PI_PROGRAM_INFO_REFERENCE_COUNT,
417-
sizeof(cl_uint), &Result, nullptr);
417+
Plugin.call<PiApiKind::piProgramGetInfo>(MProgram,
418+
PI_PROGRAM_INFO_REFERENCE_COUNT,
419+
sizeof(pi_uint32), &Result, nullptr);
418420
return Result;
419421
}
420422

sycl/source/detail/program_manager/program_manager.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ static RT::PiProgram createBinaryProgram(const ContextImplPtr Context,
7070
// FIXME: we don't yet support multiple devices with a single binary.
7171
const detail::plugin &Plugin = Context->getPlugin();
7272
#ifndef _NDEBUG
73-
cl_uint NumDevices = 0;
73+
pi_uint32 NumDevices = 0;
7474
Plugin.call<PiApiKind::piContextGetInfo>(Context->getHandleRef(),
7575
PI_CONTEXT_INFO_NUM_DEVICES,
7676
sizeof(NumDevices), &NumDevices,
@@ -438,7 +438,7 @@ ProgramManager::getClProgramFromClKernel(RT::PiKernel Kernel,
438438
RT::PiProgram Program;
439439
const detail::plugin &Plugin = Context->getPlugin();
440440
Plugin.call<PiApiKind::piKernelGetInfo>(
441-
Kernel, PI_KERNEL_INFO_PROGRAM, sizeof(cl_program), &Program, nullptr);
441+
Kernel, PI_KERNEL_INFO_PROGRAM, sizeof(RT::PiProgram), &Program, nullptr);
442442
return Program;
443443
}
444444

@@ -449,8 +449,8 @@ string_class ProgramManager::getProgramBuildLog(const RT::PiProgram &Program,
449449
Plugin.call<PiApiKind::piProgramGetInfo>(Program, PI_PROGRAM_INFO_DEVICES, 0,
450450
nullptr, &Size);
451451
vector_class<RT::PiDevice> PIDevices(Size / sizeof(RT::PiDevice));
452-
Plugin.call<PiApiKind::piProgramGetInfo>(Program, PI_PROGRAM_INFO_DEVICES, Size,
453-
PIDevices.data(), nullptr);
452+
Plugin.call<PiApiKind::piProgramGetInfo>(Program, PI_PROGRAM_INFO_DEVICES,
453+
Size, PIDevices.data(), nullptr);
454454
string_class Log = "The program was built for " +
455455
std::to_string(PIDevices.size()) + " devices";
456456
for (RT::PiDevice &Device : PIDevices) {

sycl/source/detail/queue_impl.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@ event queue_impl::memcpy(shared_ptr_class<detail::queue_impl> Impl, void *Dest,
6969
return ResEvent;
7070
}
7171

72-
event queue_impl::mem_advise(const void *Ptr, size_t Length, int Advice) {
72+
event queue_impl::mem_advise(const void *Ptr, size_t Length,
73+
pi_mem_advice Advice) {
7374
context Context = get_context();
7475
if (Context.is_host()) {
7576
return event();

sycl/source/detail/queue_impl.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ class queue_impl {
336336
/// \param Ptr is a USM pointer to the allocation.
337337
/// \param Length is a number of bytes in the allocation.
338338
/// \param Advice is a device-defined advice for the specified allocation.
339-
event mem_advise(const void *Ptr, size_t Length, int Advice);
339+
event mem_advise(const void *Ptr, size_t Length, pi_mem_advice Advice);
340340

341341
/// Puts exception to the list of asynchronous ecxeptions.
342342
///

sycl/source/detail/scheduler/commands.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1643,11 +1643,11 @@ cl_int ExecCGCommand::enqueueImp() {
16431643
pi_mem MemArg = (pi_mem)AllocaCmd->getMemAllocation();
16441644
Plugin.call<PiApiKind::piextKernelSetArgMemObj>(Kernel, Arg.MIndex, &MemArg);
16451645
#else
1646-
cl_mem MemArg = (cl_mem)AllocaCmd->getMemAllocation();
1646+
RT::PiMem MemArg = (RT::PiMem)AllocaCmd->getMemAllocation();
16471647
Plugin.call<PiApiKind::piKernelSetArg>(Kernel, Arg.MIndex,
1648-
sizeof(cl_mem), &MemArg);
1648+
sizeof(RT::PiMem), &MemArg);
16491649
Plugin.call<PiApiKind::piKernelSetArg>(Kernel, Arg.MIndex,
1650-
sizeof(cl_mem), &MemArg);
1650+
sizeof(RT::PiMem), &MemArg);
16511651
#endif
16521652
break;
16531653
}

sycl/source/queue.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ event queue::memcpy(void *dest, const void *src, size_t count) {
9999
return impl->memcpy(impl, dest, src, count);
100100
}
101101

102-
event queue::mem_advise(const void *ptr, size_t length, int advice) {
102+
event queue::mem_advise(const void *ptr, size_t length, pi_mem_advice advice) {
103103
return impl->mem_advise(ptr, length, advice);
104104
}
105105

sycl/test/usm/memadvise.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ int main() {
3737
if (s_head == nullptr) {
3838
return -1;
3939
}
40-
q.mem_advise(s_head, sizeof(Node), 42);
40+
q.mem_advise(s_head, sizeof(Node), PI_MEM_ADVICE_SET_READ_MOSTLY);
4141
Node *s_cur = s_head;
4242

4343
for (int i = 0; i < numNodes; i++) {
@@ -48,7 +48,7 @@ int main() {
4848
if (s_cur->pNext == nullptr) {
4949
return -1;
5050
}
51-
q.mem_advise(s_cur->pNext, sizeof(Node), 42);
51+
q.mem_advise(s_cur->pNext, sizeof(Node), PI_MEM_ADVICE_SET_READ_MOSTLY);
5252
} else {
5353
s_cur->pNext = nullptr;
5454
}

0 commit comments

Comments
 (0)