Skip to content

[SYCL] Start running OpenCL through PI #281

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

Merged
merged 1 commit into from
Jul 11, 2019
Merged
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
3 changes: 2 additions & 1 deletion sycl/include/CL/sycl/detail/pi.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ typedef pi_uint32 pi_bool;
// TODO: populate PI enums.
//
typedef enum {
PI_SUCCESS = CL_SUCCESS
PI_SUCCESS = CL_SUCCESS,
PI_RESULT_INVALID_KERNEL_NAME = CL_INVALID_KERNEL_NAME
} _pi_result;

typedef enum {
Expand Down
7 changes: 1 addition & 6 deletions sycl/include/CL/sycl/detail/pi.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

#include <CL/sycl/detail/pi.h>
#include <CL/sycl/detail/common.hpp>
#include <CL/sycl/detail/pi_opencl.hpp> // TODO: remove when switched to PI

namespace cl {
namespace sycl {
Expand Down Expand Up @@ -114,11 +113,7 @@ namespace pi {
#undef _PI_API
} // namespace pi

// Select underlying runtime interface in compile-time (OpenCL or PI).
// As such only one path (OpenCL today) is being regularily tested.
// TODO: change to
// namespace RT = cl::sycl::detail::pi;
namespace RT = cl::sycl::detail::pi_opencl;
namespace RT = cl::sycl::detail::pi;

// Report error and no return (keeps compiler happy about no return statements).
[[noreturn]] void piDie(const char *Message);
Expand Down
131 changes: 0 additions & 131 deletions sycl/include/CL/sycl/detail/pi_opencl.hpp

This file was deleted.

2 changes: 1 addition & 1 deletion sycl/include/CL/sycl/detail/program_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ class program_impl {
RT::PiResult Err;
Err = PI_CALL_RESULT((Kernel = RT::piKernelCreate(
Program, KernelName.c_str(), &Err), Err));
if (Err == CL_INVALID_KERNEL_NAME) {
if (Err == PI_RESULT_INVALID_KERNEL_NAME) {
throw invalid_object_error(
"This instance of program does not contain the kernel requested");
}
Expand Down
22 changes: 3 additions & 19 deletions sycl/source/detail/platform_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,7 @@ platform_impl_pi::get_platforms() {
vector_class<platform> platforms;

pi_uint32 num_platforms = 0;
auto Err = PI_CALL_RESULT(RT::piPlatformsGet(0, 0, &num_platforms));

// TODO: remove this check when switch to PI, which will just return 0 in
// num_platforms.
//
if (Err == CL_PLATFORM_NOT_FOUND_KHR)
return platforms;

PI_CHECK(Err);
PI_CALL(RT::piPlatformsGet(0, 0, &num_platforms));
info::device_type forced_type = detail::get_forced_type();

if (num_platforms) {
Expand Down Expand Up @@ -61,20 +53,12 @@ platform_impl_pi::get_devices(info::device_type deviceType) const {
return res;

pi_uint32 num_devices;
auto err = PI_CALL_RESULT(RT::piDevicesGet(
m_platform, pi_cast<RT::PiDeviceType>(deviceType), 0, 0, &num_devices));

// TODO: remove this check when switched to PI as it would just return
// zero in num_devices.
if (err == CL_DEVICE_NOT_FOUND)
return res;
PI_CALL(RT::piDevicesGet(
m_platform, pi_cast<RT::PiDeviceType>(deviceType), 0, 0, &num_devices));

if (num_devices == 0)
return res;

// TODO catch an exception and put it to list of asynchronous exceptions
PI_CHECK(err);

vector_class<RT::PiDevice> pi_devices(num_devices);
// TODO catch an exception and put it to list of asynchronous exceptions
PI_CALL(RT::piDevicesGet(
Expand Down
2 changes: 1 addition & 1 deletion sycl/source/detail/sampler_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ RT::PiSampler sampler_impl::getOrCreateSampler(const context &Context) {
getSyclObjImpl(Context)->getHandleRef(), sprops, &errcode_ret),
errcode_ret));
#else
// TODO: do we reall need this old interface into PI and here?
// TODO: do we really need this old interface into PI and here?
cl_int cl_errcode_ret;
m_contextToSampler[Context] =
clCreateSampler(getSyclObjImpl(Context)->getHandleRef(),
Expand Down
9 changes: 6 additions & 3 deletions sycl/source/detail/scheduler/commands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -265,8 +265,8 @@ cl_int MemCpyCommandHost::enqueueImp() {
// number of work - groups, such that the size of each group is chosen by the
// runtime, or by the number of work - groups and number of work - items for
// users who need more control.
static void adjustNDRangePerKernel(NDRDescT &NDR, cl_kernel Kernel,
cl_device_id Device) {
static void adjustNDRangePerKernel(NDRDescT &NDR, RT::PiKernel Kernel,
RT::PiDevice Device) {
if (NDR.GlobalSize[0] != 0)
return; // GlobalSize is set - no need to adjust
// check the prerequisites:
Expand Down Expand Up @@ -422,7 +422,10 @@ cl_int ExecCGCommand::enqueueImp() {
assert(!"Unhandled");
}
}
adjustNDRangePerKernel(NDRDesc, Kernel, MQueue->get_device().get());
adjustNDRangePerKernel(NDRDesc, Kernel,
detail::getSyclObjImpl(
MQueue->get_device())->getHandleRef());

PI_CALL(RT::piEnqueueKernelLaunch(
MQueue->getHandleRef(), Kernel, NDRDesc.Dims, &NDRDesc.GlobalOffset[0],
&NDRDesc.GlobalSize[0],
Expand Down