Skip to content

[SYCL] Plugin Interface: Single Call to Plugin to populate a Plugin Datastructure. #808

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

Closed
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
5 changes: 2 additions & 3 deletions sycl/include/CL/sycl/buffer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,8 @@ class buffer {
: Range{0} {

size_t BufSize = 0;
PI_CALL(detail::RT::piMemGetInfo,
detail::pi::cast<detail::RT::PiMem>(MemObject), CL_MEM_SIZE,
sizeof(size_t), &BufSize, nullptr);
PI_CALL(piMemGetInfo, detail::pi::cast<detail::RT::PiMem>(MemObject),
CL_MEM_SIZE, sizeof(size_t), &BufSize, nullptr);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only noticing this now - this somehow reminds me of Lisp 😄

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have never used Lisp. Are you talking about use of comma after the api name?
I have the call interface changed in #843 . Do you think that works?
Maybe I can close this PR and merge the two PRs together.
Let me know what you think.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, sorry for the confusion and the extra work that I now caused - I meant "Lisp" as a positive thing 😿

Both approaches seem ok to me, the one in this PR seems to require less state in the trace class though.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's true. The other way makes it more like calling a constructor and a functor on it.


Range[0] = BufSize / sizeof(T);
impl = std::make_shared<detail::buffer_impl<AllocatorT>>(
Expand Down
4 changes: 2 additions & 2 deletions sycl/include/CL/sycl/detail/context_info.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ template <info::context param> struct get_context_info {
static RetType _(RT::PiContext ctx) {
RetType Result = 0;
// TODO catch an exception and put it to list of asynchronous exceptions
PI_CALL(RT::piContextGetInfo, ctx, pi::cast<pi_context_info>(param),
sizeof(Result), &Result, nullptr);
PI_CALL(piContextGetInfo, ctx, pi::cast<pi_context_info>(param),
sizeof(Result), &Result, nullptr);
return Result;
}
};
Expand Down
36 changes: 18 additions & 18 deletions sycl/include/CL/sycl/detail/device_info.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ template <> struct check_fp_support<info::device::double_fp_config> {
template <typename T, info::device param> struct get_device_info {
static T _(RT::PiDevice dev) {
typename sycl_to_pi<T>::type result;
PI_CALL(RT::piDeviceGetInfo, dev, pi::cast<RT::PiDeviceInfo>(param),
PI_CALL(piDeviceGetInfo, dev, pi::cast<RT::PiDeviceInfo>(param),
sizeof(result), &result, nullptr);
return T(result);
}
Expand All @@ -58,7 +58,7 @@ template <typename T, info::device param> struct get_device_info {
template <info::device param> struct get_device_info<platform, param> {
static platform _(RT::PiDevice dev) {
typename sycl_to_pi<platform>::type result;
PI_CALL(RT::piDeviceGetInfo, dev, pi::cast<RT::PiDeviceInfo>(param),
PI_CALL(piDeviceGetInfo, dev, pi::cast<RT::PiDeviceInfo>(param),
sizeof(result), &result, nullptr);
return createSyclObjFromImpl<platform>(
std::make_shared<platform_impl_pi>(result));
Expand All @@ -69,13 +69,13 @@ template <info::device param> struct get_device_info<platform, param> {
template <info::device param> struct get_device_info<string_class, param> {
static string_class _(RT::PiDevice dev) {
size_t resultSize;
PI_CALL(RT::piDeviceGetInfo, dev, pi::cast<RT::PiDeviceInfo>(param), 0, nullptr,
PI_CALL(piDeviceGetInfo, dev, pi::cast<RT::PiDeviceInfo>(param), 0, nullptr,
&resultSize);
if (resultSize == 0) {
return string_class();
}
unique_ptr_class<char[]> result(new char[resultSize]);
PI_CALL(RT::piDeviceGetInfo, dev, pi::cast<RT::PiDeviceInfo>(param), resultSize,
PI_CALL(piDeviceGetInfo, dev, pi::cast<RT::PiDeviceInfo>(param), resultSize,
result.get(), nullptr);

return string_class(result.get());
Expand All @@ -91,7 +91,7 @@ template <typename T> struct get_device_info<T, info::device::parent_device> {
template <info::device param> struct get_device_info<id<3>, param> {
static id<3> _(RT::PiDevice dev) {
size_t result[3];
PI_CALL(RT::piDeviceGetInfo, dev, pi::cast<RT::PiDeviceInfo>(param),
PI_CALL(piDeviceGetInfo, dev, pi::cast<RT::PiDeviceInfo>(param),
sizeof(result), &result, nullptr);
return id<3>(result[0], result[1], result[2]);
}
Expand All @@ -109,7 +109,7 @@ struct get_device_info<vector_class<info::fp_config>, param> {
return {};
}
cl_device_fp_config result;
PI_CALL(RT::piDeviceGetInfo, dev, pi::cast<RT::PiDeviceInfo>(param),
PI_CALL(piDeviceGetInfo, dev, pi::cast<RT::PiDeviceInfo>(param),
sizeof(result), &result, nullptr);
return read_fp_bitfield(result);
}
Expand All @@ -121,7 +121,7 @@ struct get_device_info<vector_class<info::fp_config>,
info::device::single_fp_config> {
static vector_class<info::fp_config> _(RT::PiDevice dev) {
cl_device_fp_config result;
PI_CALL(RT::piDeviceGetInfo, dev,
PI_CALL(piDeviceGetInfo, dev,
pi::cast<RT::PiDeviceInfo>(info::device::single_fp_config),
sizeof(result), &result, nullptr);
return read_fp_bitfield(result);
Expand All @@ -132,7 +132,7 @@ struct get_device_info<vector_class<info::fp_config>,
template <> struct get_device_info<bool, info::device::queue_profiling> {
static bool _(RT::PiDevice dev) {
cl_command_queue_properties result;
PI_CALL(RT::piDeviceGetInfo, dev,
PI_CALL(piDeviceGetInfo, dev,
pi::cast<RT::PiDeviceInfo>(info::device::queue_profiling),
sizeof(result), &result, nullptr);
return (result & CL_QUEUE_PROFILING_ENABLE);
Expand All @@ -145,7 +145,7 @@ struct get_device_info<vector_class<info::execution_capability>,
info::device::execution_capabilities> {
static vector_class<info::execution_capability> _(RT::PiDevice dev) {
cl_device_exec_capabilities result;
PI_CALL(RT::piDeviceGetInfo, dev,
PI_CALL(piDeviceGetInfo, dev,
pi::cast<RT::PiDeviceInfo>(info::device::execution_capabilities),
sizeof(result), &result, nullptr);
return read_execution_bitfield(result);
Expand Down Expand Up @@ -182,15 +182,15 @@ struct get_device_info<vector_class<info::partition_property>,
pi::cast<RT::PiDeviceInfo>(info::device::partition_properties);

size_t resultSize;
PI_CALL(RT::piDeviceGetInfo, dev, info_partition, 0, nullptr, &resultSize);
PI_CALL(piDeviceGetInfo, dev, info_partition, 0, nullptr, &resultSize);

size_t arrayLength = resultSize / sizeof(cl_device_partition_property);
if (arrayLength == 0) {
return {};
}
unique_ptr_class<cl_device_partition_property[]> arrayResult(
new cl_device_partition_property[arrayLength]);
PI_CALL(RT::piDeviceGetInfo, dev, info_partition, resultSize, arrayResult.get(),
PI_CALL(piDeviceGetInfo, dev, info_partition, resultSize, arrayResult.get(),
nullptr);

vector_class<info::partition_property> result;
Expand All @@ -208,7 +208,7 @@ struct get_device_info<vector_class<info::partition_affinity_domain>,
static vector_class<info::partition_affinity_domain> _(RT::PiDevice dev) {
cl_device_affinity_domain result;
PI_CALL(
RT::piDeviceGetInfo, dev,
piDeviceGetInfo, dev,
pi::cast<RT::PiDeviceInfo>(info::device::partition_affinity_domains),
sizeof(result), &result, nullptr);
return read_domain_bitfield(result);
Expand All @@ -222,15 +222,15 @@ struct get_device_info<info::partition_affinity_domain,
info::device::partition_type_affinity_domain> {
static info::partition_affinity_domain _(RT::PiDevice dev) {
size_t resultSize;
PI_CALL(RT::piDeviceGetInfo, dev,
PI_CALL(piDeviceGetInfo, dev,
pi::cast<RT::PiDeviceInfo>(
info::device::partition_type_affinity_domain),
0, nullptr, &resultSize);
if (resultSize != 1) {
return info::partition_affinity_domain::not_applicable;
}
cl_device_partition_property result;
PI_CALL(RT::piDeviceGetInfo, dev,
PI_CALL(piDeviceGetInfo, dev,
pi::cast<RT::PiDeviceInfo>(
info::device::partition_type_affinity_domain),
sizeof(result), &result, nullptr);
Expand All @@ -252,7 +252,7 @@ struct get_device_info<info::partition_property,
info::device::partition_type_property> {
static info::partition_property _(RT::PiDevice dev) {
size_t resultSize;
PI_CALL(RT::piDeviceGetInfo, dev, PI_DEVICE_INFO_PARTITION_TYPE, 0, nullptr,
PI_CALL(piDeviceGetInfo, dev, PI_DEVICE_INFO_PARTITION_TYPE, 0, nullptr,
&resultSize);
if (!resultSize)
return info::partition_property::no_partition;
Expand All @@ -261,7 +261,7 @@ struct get_device_info<info::partition_property,

unique_ptr_class<cl_device_partition_property[]> arrayResult(
new cl_device_partition_property[arrayLength]);
PI_CALL(RT::piDeviceGetInfo, dev, PI_DEVICE_INFO_PARTITION_TYPE, resultSize,
PI_CALL(piDeviceGetInfo, dev, PI_DEVICE_INFO_PARTITION_TYPE, resultSize,
arrayResult.get(), nullptr);
if (!arrayResult[0])
return info::partition_property::no_partition;
Expand All @@ -273,12 +273,12 @@ template <>
struct get_device_info<vector_class<size_t>, info::device::sub_group_sizes> {
static vector_class<size_t> _(RT::PiDevice dev) {
size_t resultSize = 0;
PI_CALL(RT::piDeviceGetInfo, dev,
PI_CALL(piDeviceGetInfo, dev,
pi::cast<RT::PiDeviceInfo>(info::device::sub_group_sizes), 0,
nullptr, &resultSize);

vector_class<size_t> result(resultSize / sizeof(size_t));
PI_CALL(RT::piDeviceGetInfo, dev,
PI_CALL(piDeviceGetInfo, dev,
pi::cast<RT::PiDeviceInfo>(info::device::sub_group_sizes),
resultSize, result.data(), nullptr);
return result;
Expand Down
8 changes: 4 additions & 4 deletions sycl/include/CL/sycl/detail/event_info.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ template <info::event_profiling Param> struct get_event_profiling_info {
static RetType _(RT::PiEvent Event) {
RetType Result = 0;
// TODO catch an exception and put it to list of asynchronous exceptions
PI_CALL(RT::piEventGetProfilingInfo,
Event, cl_profiling_info(Param), sizeof(Result), &Result, nullptr);
PI_CALL(piEventGetProfilingInfo, Event, cl_profiling_info(Param),
sizeof(Result), &Result, nullptr);
return Result;
}
};
Expand All @@ -34,8 +34,8 @@ template <info::event Param> struct get_event_info {
static RetType _(RT::PiEvent Event) {
RetType Result = (RetType)0;
// TODO catch an exception and put it to list of asynchronous exceptions
PI_CALL(RT::piEventGetInfo,
Event, cl_profiling_info(Param), sizeof(Result), &Result, nullptr);
PI_CALL(piEventGetInfo, Event, cl_profiling_info(Param), sizeof(Result),
&Result, nullptr);
return Result;
}
};
Expand Down
4 changes: 2 additions & 2 deletions sycl/include/CL/sycl/detail/image_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ class image_impl final : public SYCLMemObjT<AllocatorT> {
: BaseT(MemObject, SyclContext, std::move(AvailableEvent)),
MRange(InitializedVal<Dimensions, range>::template get<0>()) {
RT::PiMem Mem = pi::cast<RT::PiMem>(BaseT::MInteropMemObject);
PI_CALL(RT::piMemGetInfo, Mem, CL_MEM_SIZE, sizeof(size_t),
PI_CALL(piMemGetInfo, Mem, CL_MEM_SIZE, sizeof(size_t),
&(BaseT::MSizeInBytes), nullptr);

RT::PiMemImageFormat Format;
Expand Down Expand Up @@ -342,7 +342,7 @@ class image_impl final : public SYCLMemObjT<AllocatorT> {
private:
template <typename T> void getImageInfo(RT::PiMemImageInfo Info, T &Dest) {
RT::PiMem Mem = pi::cast<RT::PiMem>(BaseT::MInteropMemObject);
PI_CALL(RT::piMemImageGetInfo, Mem, Info, sizeof(T), &Dest, nullptr);
PI_CALL(piMemImageGetInfo, Mem, Info, sizeof(T), &Dest, nullptr);
}

template <info::device Param>
Expand Down
8 changes: 4 additions & 4 deletions sycl/include/CL/sycl/detail/kernel_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@ class kernel_impl {
IsCreatedFromSource(IsCreatedFromSource) {

RT::PiContext Context = nullptr;
PI_CALL(RT::piKernelGetInfo, Kernel, CL_KERNEL_CONTEXT, sizeof(Context),
PI_CALL(piKernelGetInfo, Kernel, CL_KERNEL_CONTEXT, sizeof(Context),
&Context, nullptr);
auto ContextImpl = detail::getSyclObjImpl(SyclContext);
if (ContextImpl->getHandleRef() != Context)
throw cl::sycl::invalid_parameter_error(
"Input context must be the same as the context of cl_kernel");
PI_CALL(RT::piKernelRetain, Kernel);
PI_CALL(piKernelRetain, Kernel);
}

// Host kernel constructor
Expand All @@ -55,15 +55,15 @@ class kernel_impl {
~kernel_impl() {
// TODO catch an exception and put it to list of asynchronous exceptions
if (!is_host()) {
PI_CALL(RT::piKernelRelease, Kernel);
PI_CALL(piKernelRelease, Kernel);
}
}

cl_kernel get() const {
if (is_host()) {
throw invalid_object_error("This instance of kernel is a host instance");
}
PI_CALL(RT::piKernelRetain, Kernel);
PI_CALL(piKernelRetain, Kernel);
return pi::cast<cl_kernel>(Kernel);
}

Expand Down
47 changes: 23 additions & 24 deletions sycl/include/CL/sycl/detail/kernel_info.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ template <info::kernel Param> struct get_kernel_info<string_class, Param> {
static string_class _(RT::PiKernel Kernel) {
size_t ResultSize;
// TODO catch an exception and put it to list of asynchronous exceptions
PI_CALL(RT::piKernelGetInfo,
Kernel, cl_kernel_info(Param), 0, nullptr, &ResultSize);
PI_CALL(piKernelGetInfo, Kernel, cl_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
PI_CALL(RT::piKernelGetInfo,
Kernel, cl_kernel_info(Param), ResultSize, Result.data(), nullptr);
PI_CALL(piKernelGetInfo, Kernel, cl_kernel_info(Param), ResultSize,
Result.data(), nullptr);
return string_class(Result.data());
}
};
Expand All @@ -41,8 +41,8 @@ template <info::kernel Param> struct get_kernel_info<cl_uint, Param> {
static cl_uint _(RT::PiKernel Kernel) {
cl_uint Result;
// TODO catch an exception and put it to list of asynchronous exceptions
PI_CALL(RT::piKernelGetInfo,
Kernel, cl_kernel_info(Param), sizeof(cl_uint), &Result, nullptr);
PI_CALL(piKernelGetInfo, Kernel, cl_kernel_info(Param), sizeof(cl_uint),
&Result, nullptr);
return Result;
}
};
Expand All @@ -54,9 +54,8 @@ struct get_kernel_work_group_info {
static T _(RT::PiKernel Kernel, RT::PiDevice Device) {
T Result;
// TODO catch an exception and put it to list of asynchronous exceptions
PI_CALL(RT::piKernelGetGroupInfo,
Kernel, Device, cl_kernel_work_group_info(Param),
sizeof(T), &Result, nullptr);
PI_CALL(piKernelGetGroupInfo, Kernel, Device,
cl_kernel_work_group_info(Param), sizeof(T), &Result, nullptr);
return Result;
}
};
Expand All @@ -66,9 +65,9 @@ struct get_kernel_work_group_info<cl::sycl::range<3>, Param> {
static cl::sycl::range<3> _(RT::PiKernel Kernel, RT::PiDevice Device) {
size_t Result[3];
// TODO catch an exception and put it to list of asynchronous exceptions
PI_CALL(RT::piKernelGetGroupInfo,
Kernel, Device, cl_kernel_work_group_info(Param),
sizeof(size_t) * 3, Result, nullptr);
PI_CALL(piKernelGetGroupInfo, Kernel, Device,
cl_kernel_work_group_info(Param), sizeof(size_t) * 3, Result,
nullptr);
return cl::sycl::range<3>(Result[0], Result[1], Result[2]);
}
};
Expand Down Expand Up @@ -109,9 +108,9 @@ struct get_kernel_sub_group_info {
static TOut _(RT::PiKernel Kernel, RT::PiDevice Device) {
TOut Result;
// TODO catch an exception and put it to list of asynchronous exceptions
PI_CALL(RT::piKernelGetSubGroupInfo,
Kernel, Device, cl_kernel_sub_group_info(Param), 0, nullptr,
sizeof(TOut), &Result, nullptr);
PI_CALL(piKernelGetSubGroupInfo, Kernel, Device,
cl_kernel_sub_group_info(Param), 0, nullptr, sizeof(TOut), &Result,
nullptr);
return Result;
}
};
Expand All @@ -121,9 +120,9 @@ struct get_kernel_sub_group_info_with_input {
static TOut _(RT::PiKernel Kernel, RT::PiDevice Device, TIn In) {
TOut Result;
// TODO catch an exception and put it to list of asynchronous exceptions
PI_CALL(RT::piKernelGetSubGroupInfo,
Kernel, Device, cl_kernel_sub_group_info(Param), sizeof(TIn), &In,
sizeof(TOut), &Result, nullptr);
PI_CALL(piKernelGetSubGroupInfo, Kernel, Device,
cl_kernel_sub_group_info(Param), sizeof(TIn), &In, sizeof(TOut),
&Result, nullptr);
return Result;
}
};
Expand All @@ -135,9 +134,9 @@ struct get_kernel_sub_group_info_with_input<cl::sycl::range<3>, Param,
size_t In) {
size_t Result[3];
// TODO catch an exception and put it to list of asynchronous exceptions
PI_CALL(RT::piKernelGetSubGroupInfo,
Kernel, Device, cl_kernel_sub_group_info(Param), sizeof(size_t),
&In, sizeof(size_t) * 3, Result, nullptr);
PI_CALL(piKernelGetSubGroupInfo, Kernel, Device,
cl_kernel_sub_group_info(Param), sizeof(size_t), &In,
sizeof(size_t) * 3, Result, nullptr);
return cl::sycl::range<3>(Result[0], Result[1], Result[2]);
}
};
Expand All @@ -150,9 +149,9 @@ struct get_kernel_sub_group_info_with_input<size_t, Param,
size_t Input[3] = {In[0], In[1], In[2]};
size_t Result;
// TODO catch an exception and put it to list of asynchronous exceptions
PI_CALL(RT::piKernelGetSubGroupInfo,
Kernel, Device, cl_kernel_sub_group_info(Param), sizeof(size_t) * 3,
Input, sizeof(size_t), &Result, nullptr);
PI_CALL(piKernelGetSubGroupInfo, Kernel, Device,
cl_kernel_sub_group_info(Param), sizeof(size_t) * 3, Input,
sizeof(size_t), &Result, nullptr);
return Result;
}
};
Expand Down
Loading