Skip to content

Commit 81ab1d6

Browse files
committed
[SYCL] Start running OpenCL through PI
Signed-off-by: Sergey V Maslov <[email protected]>
1 parent 82e9712 commit 81ab1d6

File tree

6 files changed

+8
-159
lines changed

6 files changed

+8
-159
lines changed

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ typedef pi_uint32 pi_bool;
4646
// TODO: populate PI enums.
4747
//
4848
typedef enum {
49-
PI_SUCCESS = CL_SUCCESS
49+
PI_SUCCESS = CL_SUCCESS,
50+
PI_RESULT_INVALID_KERNEL_NAME = CL_INVALID_KERNEL_NAME
5051
} _pi_result;
5152

5253
typedef enum {

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

+1-6
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

-131
This file was deleted.

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

+1-1
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

+3-19
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

+1-1
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(),

0 commit comments

Comments
 (0)