Skip to content

Commit af4c249

Browse files
smaslov-intelbader
authored andcommitted
[SYCL] Start running OpenCL through PI
Signed-off-by: Sergey V Maslov <[email protected]>
1 parent c451ac3 commit af4c249

File tree

7 files changed

+14
-162
lines changed

7 files changed

+14
-162
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ typedef pi_uint32 pi_bool;
4747
// TODO: populate PI enums.
4848
//
4949
typedef enum {
50-
PI_SUCCESS = CL_SUCCESS
50+
PI_SUCCESS = CL_SUCCESS,
51+
PI_RESULT_INVALID_KERNEL_NAME = CL_INVALID_KERNEL_NAME
5152
} _pi_result;
5253

5354
typedef enum {

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

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212

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

1716
namespace cl {
1817
namespace sycl {
@@ -114,11 +113,7 @@ namespace pi {
114113
#undef _PI_API
115114
} // namespace pi
116115

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

123118
// Report error and no return (keeps compiler happy about no return statements).
124119
[[noreturn]] void piDie(const char *Message);

sycl/include/CL/sycl/detail/pi_opencl.hpp

Lines changed: 0 additions & 131 deletions
This file was deleted.

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,7 @@ class program_impl {
395395
RT::PiResult Err;
396396
Err = PI_CALL_RESULT((Kernel = RT::piKernelCreate(
397397
Program, KernelName.c_str(), &Err), Err));
398-
if (Err == CL_INVALID_KERNEL_NAME) {
398+
if (Err == PI_RESULT_INVALID_KERNEL_NAME) {
399399
throw invalid_object_error(
400400
"This instance of program does not contain the kernel requested");
401401
}

sycl/source/detail/platform_impl.cpp

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,7 @@ platform_impl_pi::get_platforms() {
1818
vector_class<platform> platforms;
1919

2020
pi_uint32 num_platforms = 0;
21-
auto Err = PI_CALL_RESULT(RT::piPlatformsGet(0, 0, &num_platforms));
22-
23-
// TODO: remove this check when switch to PI, which will just return 0 in
24-
// num_platforms.
25-
//
26-
if (Err == CL_PLATFORM_NOT_FOUND_KHR)
27-
return platforms;
28-
29-
PI_CHECK(Err);
21+
PI_CALL(RT::piPlatformsGet(0, 0, &num_platforms));
3022
info::device_type forced_type = detail::get_forced_type();
3123

3224
if (num_platforms) {
@@ -61,20 +53,12 @@ platform_impl_pi::get_devices(info::device_type deviceType) const {
6153
return res;
6254

6355
pi_uint32 num_devices;
64-
auto err = PI_CALL_RESULT(RT::piDevicesGet(
65-
m_platform, pi_cast<RT::PiDeviceType>(deviceType), 0, 0, &num_devices));
66-
67-
// TODO: remove this check when switched to PI as it would just return
68-
// zero in num_devices.
69-
if (err == CL_DEVICE_NOT_FOUND)
70-
return res;
56+
PI_CALL(RT::piDevicesGet(
57+
m_platform, pi_cast<RT::PiDeviceType>(deviceType), 0, 0, &num_devices));
7158

7259
if (num_devices == 0)
7360
return res;
7461

75-
// TODO catch an exception and put it to list of asynchronous exceptions
76-
PI_CHECK(err);
77-
7862
vector_class<RT::PiDevice> pi_devices(num_devices);
7963
// TODO catch an exception and put it to list of asynchronous exceptions
8064
PI_CALL(RT::piDevicesGet(

sycl/source/detail/sampler_impl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ RT::PiSampler sampler_impl::getOrCreateSampler(const context &Context) {
6060
getSyclObjImpl(Context)->getHandleRef(), sprops, &errcode_ret),
6161
errcode_ret));
6262
#else
63-
// TODO: do we reall need this old interface into PI and here?
63+
// TODO: do we really need this old interface into PI and here?
6464
cl_int cl_errcode_ret;
6565
m_contextToSampler[Context] =
6666
clCreateSampler(getSyclObjImpl(Context)->getHandleRef(),

sycl/source/detail/scheduler/commands.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -265,8 +265,8 @@ cl_int MemCpyCommandHost::enqueueImp() {
265265
// number of work - groups, such that the size of each group is chosen by the
266266
// runtime, or by the number of work - groups and number of work - items for
267267
// users who need more control.
268-
static void adjustNDRangePerKernel(NDRDescT &NDR, cl_kernel Kernel,
269-
cl_device_id Device) {
268+
static void adjustNDRangePerKernel(NDRDescT &NDR, RT::PiKernel Kernel,
269+
RT::PiDevice Device) {
270270
if (NDR.GlobalSize[0] != 0)
271271
return; // GlobalSize is set - no need to adjust
272272
// check the prerequisites:
@@ -422,7 +422,10 @@ cl_int ExecCGCommand::enqueueImp() {
422422
assert(!"Unhandled");
423423
}
424424
}
425-
adjustNDRangePerKernel(NDRDesc, Kernel, MQueue->get_device().get());
425+
adjustNDRangePerKernel(NDRDesc, Kernel,
426+
detail::getSyclObjImpl(
427+
MQueue->get_device())->getHandleRef());
428+
426429
PI_CALL(RT::piEnqueueKernelLaunch(
427430
MQueue->getHandleRef(), Kernel, NDRDesc.Dims, &NDRDesc.GlobalOffset[0],
428431
&NDRDesc.GlobalSize[0],

0 commit comments

Comments
 (0)