Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SYCL] Replaces some of the CL_* enums with PI_* enums. #1149

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion sycl/include/CL/sycl/detail/event_info.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ template <info::event Param> struct get_event_info {
static RetType get(RT::PiEvent Event, const plugin &Plugin) {
RetType Result = (RetType)0;
// TODO catch an exception and put it to list of asynchronous exceptions
Plugin.call<PiApiKind::piEventGetInfo>(Event, cl_profiling_info(Param),
Plugin.call<PiApiKind::piEventGetInfo>(Event, pi_event_info(Param),
sizeof(Result), &Result, nullptr);
return Result;
}
Expand Down
10 changes: 5 additions & 5 deletions sycl/include/CL/sycl/detail/kernel_info.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,26 +26,26 @@ template <info::kernel Param> struct get_kernel_info<string_class, Param> {
size_t ResultSize;

// TODO catch an exception and put it to list of asynchronous exceptions
Plugin.call<PiApiKind::piKernelGetInfo>(Kernel, cl_kernel_info(Param), 0,
Plugin.call<PiApiKind::piKernelGetInfo>(Kernel, pi_kernel_info(Param), 0,
nullptr, &ResultSize);
if (ResultSize == 0) {
return "";
}
vector_class<char> Result(ResultSize);
// TODO catch an exception and put it to list of asynchronous exceptions
Plugin.call<PiApiKind::piKernelGetInfo>(Kernel, cl_kernel_info(Param),
Plugin.call<PiApiKind::piKernelGetInfo>(Kernel, pi_kernel_info(Param),
ResultSize, Result.data(), nullptr);
return string_class(Result.data());
}
};

template <info::kernel Param> struct get_kernel_info<cl_uint, Param> {
static cl_uint get(RT::PiKernel Kernel, const plugin &Plugin) {
cl_uint Result;
pi_uint32 Result;

// TODO catch an exception and put it to list of asynchronous exceptions
Plugin.call<PiApiKind::piKernelGetInfo>(Kernel, cl_kernel_info(Param),
sizeof(cl_uint), &Result, nullptr);
Plugin.call<PiApiKind::piKernelGetInfo>(Kernel, pi_kernel_info(Param),
sizeof(pi_uint32), &Result, nullptr);
return Result;
}
};
Expand Down
235 changes: 215 additions & 20 deletions sycl/include/CL/sycl/detail/pi.h

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion sycl/include/CL/sycl/detail/queue_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ class queue_impl {
/// @param Ptr is a USM pointer to the allocation.
/// @param Length is a number of bytes in the allocation.
/// @param Advice is a device-defined advice for the specified allocation.
event mem_advise(const void *Ptr, size_t Length, int Advice);
event mem_advise(const void *Ptr, size_t Length, pi_mem_advice Advice);

/// Puts exception to the list of asynchronous ecxeptions.
///
Expand Down
2 changes: 1 addition & 1 deletion sycl/include/CL/sycl/queue.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ class queue {
/// @param Length is a number of bytes in the allocation.
/// @param Advice is a device-defined advice for the specified allocation.
/// @return an event representing advice operation.
event mem_advise(const void *Ptr, size_t Length, int Advice);
event mem_advise(const void *Ptr, size_t Length, pi_mem_advice Advice);

/// Provides hints to the runtime library that data should be made available
/// on a device earlier than Unified Shared Memory would normally require it
Expand Down
2 changes: 1 addition & 1 deletion sycl/source/detail/error_handling/enqueue_kernel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ bool handleInvalidWorkGroupSize(const device_impl &DeviceImpl, pi_kernel Kernel,

pi_program Program = nullptr;
Plugin.call<PiApiKind::piKernelGetInfo>(
Kernel, CL_KERNEL_PROGRAM, sizeof(pi_program), &Program, nullptr);
Kernel, PI_KERNEL_INFO_PROGRAM, sizeof(pi_program), &Program, nullptr);
size_t OptsSize = 0;
Plugin.call<PiApiKind::piProgramGetBuildInfo>(
Program, Device, CL_PROGRAM_BUILD_OPTIONS, 0, nullptr, &OptsSize);
Expand Down
2 changes: 1 addition & 1 deletion sycl/source/detail/event_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ event_impl::event_impl(RT::PiEvent Event, const context &SyclContext)

RT::PiContext TempContext;
getPlugin().call<PiApiKind::piEventGetInfo>(
MEvent, CL_EVENT_CONTEXT, sizeof(RT::PiContext), &TempContext, nullptr);
MEvent, PI_EVENT_INFO_CONTEXT, sizeof(RT::PiContext), &TempContext, nullptr);
if (MContext->getHandleRef() != TempContext) {
throw cl::sycl::invalid_parameter_error(
"The syclContext must match the OpenCL context associated with the "
Expand Down
2 changes: 1 addition & 1 deletion sycl/source/detail/kernel_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ kernel_impl::kernel_impl(RT::PiKernel Kernel, ContextImplPtr ContextImpl,
RT::PiContext Context = nullptr;
// Using the plugin from the passed ContextImpl
getPlugin().call<PiApiKind::piKernelGetInfo>(
MKernel, CL_KERNEL_CONTEXT, sizeof(Context), &Context, nullptr);
MKernel, PI_KERNEL_INFO_CONTEXT, sizeof(Context), &Context, nullptr);
if (ContextImpl->getHandleRef() != Context)
throw cl::sycl::invalid_parameter_error(
"Input context must be the same as the context of cl_kernel");
Expand Down
20 changes: 10 additions & 10 deletions sycl/source/detail/program_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,12 @@ program_impl::program_impl(ContextImplPtr Context, RT::PiProgram Program)
: MProgram(Program), MContext(Context), MLinkable(true) {

// TODO handle the case when cl_program build is in progress
cl_uint NumDevices;
pi_uint32 NumDevices;
const detail::plugin &Plugin = getPlugin();
Plugin.call<PiApiKind::piProgramGetInfo>(
Program, CL_PROGRAM_NUM_DEVICES, sizeof(cl_uint), &NumDevices, nullptr);
Program, PI_PROGRAM_INFO_NUM_DEVICES, sizeof(pi_uint32), &NumDevices, nullptr);
vector_class<RT::PiDevice> PiDevices(NumDevices);
Plugin.call<PiApiKind::piProgramGetInfo>(Program, CL_PROGRAM_DEVICES,
Plugin.call<PiApiKind::piProgramGetInfo>(Program, PI_PROGRAM_INFO_DEVICES,
sizeof(RT::PiDevice) * NumDevices,
PiDevices.data(), nullptr);
vector_class<device> SyclContextDevices =
Expand Down Expand Up @@ -262,15 +262,15 @@ vector_class<vector_class<char>> program_impl::get_binaries() const {
if (!is_host()) {
vector_class<size_t> BinarySizes(MDevices.size());
Plugin.call<PiApiKind::piProgramGetInfo>(
MProgram, CL_PROGRAM_BINARY_SIZES, sizeof(size_t) * BinarySizes.size(),
MProgram, PI_PROGRAM_INFO_BINARY_SIZES, sizeof(size_t) * BinarySizes.size(),
BinarySizes.data(), nullptr);

vector_class<char *> Pointers;
for (size_t I = 0; I < BinarySizes.size(); ++I) {
Result.emplace_back(BinarySizes[I]);
Pointers.push_back(Result[I].data());
}
Plugin.call<PiApiKind::piProgramGetInfo>(MProgram, CL_PROGRAM_BINARIES,
Plugin.call<PiApiKind::piProgramGetInfo>(MProgram, PI_PROGRAM_INFO_BINARIES,
sizeof(char *) * Pointers.size(),
Pointers.data(), nullptr);
}
Expand Down Expand Up @@ -330,10 +330,10 @@ vector_class<RT::PiDevice> program_impl::get_pi_devices() const {
bool program_impl::has_cl_kernel(const string_class &KernelName) const {
size_t Size;
const detail::plugin &Plugin = getPlugin();
Plugin.call<PiApiKind::piProgramGetInfo>(MProgram, CL_PROGRAM_KERNEL_NAMES, 0,
Plugin.call<PiApiKind::piProgramGetInfo>(MProgram, PI_PROGRAM_INFO_KERNEL_NAMES, 0,
nullptr, &Size);
string_class ClResult(Size, ' ');
Plugin.call<PiApiKind::piProgramGetInfo>(MProgram, CL_PROGRAM_KERNEL_NAMES,
Plugin.call<PiApiKind::piProgramGetInfo>(MProgram, PI_PROGRAM_INFO_KERNEL_NAMES,
ClResult.size(), &ClResult[0],
nullptr);
// Get rid of the null terminator
Expand Down Expand Up @@ -402,10 +402,10 @@ cl_uint program_impl::get_info<info::program::reference_count>() const {
if (is_host()) {
throw invalid_object_error("This instance of program is a host instance");
}
cl_uint Result;
pi_uint32 Result;
const detail::plugin &Plugin = getPlugin();
Plugin.call<PiApiKind::piProgramGetInfo>(MProgram, CL_PROGRAM_REFERENCE_COUNT,
sizeof(cl_uint), &Result, nullptr);
Plugin.call<PiApiKind::piProgramGetInfo>(MProgram, PI_PROGRAM_INFO_REFERENCE_COUNT,
sizeof(pi_uint32), &Result, nullptr);
return Result;
}

Expand Down
12 changes: 6 additions & 6 deletions sycl/source/detail/program_manager/program_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ ProgramManager &ProgramManager::getInstance() {
}

static RT::PiDevice getFirstDevice(const ContextImplPtr &Context) {
cl_uint NumDevices = 0;
pi_uint32 NumDevices = 0;
const detail::plugin &Plugin = Context->getPlugin();
Plugin.call<PiApiKind::piContextGetInfo>(Context->getHandleRef(),
PI_CONTEXT_INFO_NUM_DEVICES,
Expand All @@ -70,7 +70,7 @@ static RT::PiProgram createBinaryProgram(const ContextImplPtr Context,
// FIXME: we don't yet support multiple devices with a single binary.
const detail::plugin &Plugin = Context->getPlugin();
#ifndef _NDEBUG
cl_uint NumDevices = 0;
pi_uint32 NumDevices = 0;
Plugin.call<PiApiKind::piContextGetInfo>(Context->getHandleRef(),
PI_CONTEXT_INFO_NUM_DEVICES,
sizeof(NumDevices), &NumDevices,
Expand Down Expand Up @@ -382,19 +382,19 @@ ProgramManager::getClProgramFromClKernel(RT::PiKernel Kernel,
RT::PiProgram Program;
const detail::plugin &Plugin = Context->getPlugin();
Plugin.call<PiApiKind::piKernelGetInfo>(
Kernel, CL_KERNEL_PROGRAM, sizeof(cl_program), &Program, nullptr);
Kernel, PI_KERNEL_INFO_PROGRAM, sizeof(RT::PiProgram), &Program, nullptr);
return Program;
}

string_class ProgramManager::getProgramBuildLog(const RT::PiProgram &Program,
const ContextImplPtr Context) {
size_t Size = 0;
const detail::plugin &Plugin = Context->getPlugin();
Plugin.call<PiApiKind::piProgramGetInfo>(Program, CL_PROGRAM_DEVICES, 0,
Plugin.call<PiApiKind::piProgramGetInfo>(Program, PI_PROGRAM_INFO_DEVICES, 0,
nullptr, &Size);
vector_class<RT::PiDevice> PIDevices(Size / sizeof(RT::PiDevice));
Plugin.call<PiApiKind::piProgramGetInfo>(Program, CL_PROGRAM_DEVICES, Size,
PIDevices.data(), nullptr);
Plugin.call<PiApiKind::piProgramGetInfo>(Program, PI_PROGRAM_INFO_DEVICES,
Size, PIDevices.data(), nullptr);
string_class Log = "The program was built for " +
std::to_string(PIDevices.size()) + " devices";
for (RT::PiDevice &Device : PIDevices) {
Expand Down
2 changes: 1 addition & 1 deletion sycl/source/detail/queue_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ event queue_impl::memcpy(shared_ptr_class<detail::queue_impl> Impl, void *Dest,
return event(pi::cast<cl_event>(Event), Context);
}

event queue_impl::mem_advise(const void *Ptr, size_t Length, int Advice) {
event queue_impl::mem_advise(const void *Ptr, size_t Length, pi_mem_advice Advice) {
context Context = get_context();
if (Context.is_host()) {
return event();
Expand Down
4 changes: 2 additions & 2 deletions sycl/source/detail/scheduler/commands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -930,9 +930,9 @@ cl_int ExecCGCommand::enqueueImp() {
case kernel_param_kind_t::kind_accessor: {
Requirement *Req = (Requirement *)(Arg.MPtr);
AllocaCommandBase *AllocaCmd = getAllocaForReq(Req);
cl_mem MemArg = (cl_mem)AllocaCmd->getMemAllocation();
RT::PiMem MemArg = (RT::PiMem)AllocaCmd->getMemAllocation();
Plugin.call<PiApiKind::piKernelSetArg>(Kernel, Arg.MIndex,
sizeof(cl_mem), &MemArg);
sizeof(RT::PiMem), &MemArg);
break;
}
case kernel_param_kind_t::kind_std_layout: {
Expand Down
2 changes: 1 addition & 1 deletion sycl/source/queue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ event queue::memcpy(void *dest, const void *src, size_t count) {
return impl->memcpy(impl, dest, src, count);
}

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

Expand Down
4 changes: 2 additions & 2 deletions sycl/test/usm/memadvise.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ int main() {
if (s_head == nullptr) {
return -1;
}
q.mem_advise(s_head, sizeof(Node), 42);
q.mem_advise(s_head, sizeof(Node), PI_MEM_ADVICE_SET_READ_MOSTLY);
Node *s_cur = s_head;

for (int i = 0; i < numNodes; i++) {
Expand All @@ -47,7 +47,7 @@ int main() {
if (s_cur->pNext == nullptr) {
return -1;
}
q.mem_advise(s_cur->pNext, sizeof(Node), 42);
q.mem_advise(s_cur->pNext, sizeof(Node), PI_MEM_ADVICE_SET_READ_MOSTLY);
} else {
s_cur->pNext = nullptr;
}
Expand Down