Skip to content

Commit 62ada2c

Browse files
committed
[SYCL] fixed typos, use less C
Signed-off-by: Sergey V Maslov <[email protected]>
1 parent fcb840f commit 62ada2c

File tree

9 files changed

+421
-417
lines changed

9 files changed

+421
-417
lines changed

sycl/include/CL/sycl/detail/device_impl.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ class device_impl_pi : public device_impl {
181181
RT::pi_device m_device = 0;
182182
RT::pi_device_type m_type;
183183
bool m_isRootDevice = false;
184-
}; // class device_impl_pi
184+
}; // class device_impl_pi
185185

186186
// TODO: 4.6.4 Partitioning into multiple SYCL devices
187187
// TODO: 4.6.4.2 Device information descriptors

sycl/include/CL/sycl/detail/device_info.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ template <> struct check_fp_support<info::device::double_fp_config> {
4242

4343
// Structs for emulating function template partial specialization
4444
// Default template for the general case
45-
// TODO: get rid of remainig uses of OpenCL directly
45+
// TODO: get rid of remaining uses of OpenCL directly
4646
//
4747
template <typename T, info::device param> struct get_device_info {
4848
static T _(RT::pi_device dev) {
@@ -70,7 +70,7 @@ template <info::device param> struct get_device_info<string_class, param> {
7070
return string_class(result.get());
7171
}
7272
};
73-
73+
7474
// Specialization for parent device
7575
template <typename T>
7676
struct get_device_info<T, info::device::parent_device> {

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ struct pi_device_binary_struct {
125125
_pi_offload_entry EntriesBegin;
126126
_pi_offload_entry EntriesEnd;
127127
};
128-
typedef pi_device_binary_struct * pi_device_binary;
128+
typedef pi_device_binary_struct * pi_device_binary;
129129

130130
// Offload binaries descriptor version supported by this library.
131131
static const uint16_t PI_DEVICE_BINARIES_VERSION = 1;
@@ -146,7 +146,7 @@ struct pi_device_binaries_struct {
146146
_pi_offload_entry *HostEntriesBegin;
147147
_pi_offload_entry *HostEntriesEnd;
148148
};
149-
typedef pi_device_binaries_struct * pi_device_binaries;
149+
typedef pi_device_binaries_struct * pi_device_binaries;
150150

151151
// Opaque types that make reading build log errors easier.
152152
class _pi_platform;
@@ -162,7 +162,7 @@ typedef cl_program pi_program;
162162
//
163163
// Following section contains SYCL RT Plugin Interface (PI) methods
164164
// having direct analogy in OpenCL, and needed for the core SYCL
165-
// functionality. The convention is to prefix such interfaces with "pi".
165+
// functionality. The convention is to prefix such interfaces with "pi".
166166
//
167167
// TODO: describe interfaces in Doxygen format
168168
//

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

Lines changed: 79 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -1,77 +1,79 @@
1-
//==---------- pi.hpp - Plugin Interface for SYCL RT -----------------------==//
2-
//
3-
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4-
// See https://llvm.org/LICENSE.txt for license information.
5-
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6-
//
7-
//===----------------------------------------------------------------------===//
8-
9-
// C++ wrapper of extern "C" PI interfaces
10-
//
11-
#pragma once
12-
13-
#include <CL/sycl/detail/pi.h>
14-
15-
namespace cl {
16-
namespace sycl {
17-
namespace detail {
18-
19-
class pi {
20-
public:
21-
using pi_result = ::pi_result;
22-
using pi_platform = ::pi_platform;
23-
using pi_device = ::pi_device;
24-
using pi_device_type = ::pi_device_type;
25-
using pi_device_binary_type = ::pi_device_binary_type;
26-
using pi_device_info = ::pi_device_info;
27-
using pi_program = ::pi_program;
28-
29-
// Convinience macro to have things look compact.
30-
#define PI_API(pi_api) \
31-
static constexpr decltype(::pi_api) * pi_api = &::pi_api;
32-
33-
// Platform
34-
PI_API(piPlatformsGet)
35-
PI_API(piPlatformGetInfo)
36-
// Device
37-
PI_API(piDevicesGet)
38-
PI_API(piDeviceGetInfo)
39-
PI_API(piDevicePartition)
40-
PI_API(piDeviceRetain)
41-
PI_API(piDeviceRelease)
42-
// IR
43-
PI_API(piextDeviceSelectBinary)
44-
};
45-
46-
// Report error and no return (keeps compiler happy about no return statements).
47-
[[noreturn]] void pi_die(const char *message);
48-
void pi_assert(bool condition, const char *message = 0);
49-
50-
#define STRINGIZE(x) STRINGIZE2(x)
51-
#define STRINGIZE2(x) #x
52-
#define PI_ASSERT(cond, msg) \
53-
pi_assert(condition, "assert @ " __FILE__ ":" STRINGIZE(__LINE__) msg);
54-
55-
// This does the call, the trace and the check for no errors.
56-
// TODO: remove dependency on CHECK_OCL_CODE.
57-
// TODO: implement a more mature and controllable tracing of PI calls.
58-
void pi_trace(const char *format, ...);
59-
#define PI_CALL(pi_call) { \
60-
pi_trace("PI ---> %s\n", #pi_call); \
61-
auto __result = (pi_call); \
62-
pi_trace("PI <--- %d\n", __result); \
63-
CHECK_OCL_CODE(__result); \
64-
}
65-
66-
// Want all the needed casts be explicit, do not define conversion operators.
67-
template<class To, class From>
68-
To pi_cast(From value) {
69-
// TODO: see if more sanity checks are possible.
70-
pi_assert(sizeof(From) == sizeof(To));
71-
return (To)(value);
72-
}
73-
74-
} // namespace detail
75-
} // namespace sycl
76-
} // namespace cl
77-
1+
//==---------- pi.hpp - Plugin Interface for SYCL RT -----------------------==//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
// C++ wrapper of extern "C" PI interfaces
10+
//
11+
#pragma once
12+
13+
#include <CL/sycl/detail/pi.h>
14+
15+
namespace cl {
16+
namespace sycl {
17+
namespace detail {
18+
19+
class pi {
20+
public:
21+
using pi_result = ::pi_result;
22+
using pi_platform = ::pi_platform;
23+
using pi_device = ::pi_device;
24+
using pi_device_type = ::pi_device_type;
25+
using pi_device_binary_type = ::pi_device_binary_type;
26+
using pi_device_info = ::pi_device_info;
27+
using pi_program = ::pi_program;
28+
29+
// Convinience macro to have things look compact.
30+
#define _PI_API(pi_api) \
31+
static constexpr decltype(::pi_api) * pi_api = &::pi_api;
32+
33+
// Platform
34+
_PI_API(piPlatformsGet)
35+
_PI_API(piPlatformGetInfo)
36+
// Device
37+
_PI_API(piDevicesGet)
38+
_PI_API(piDeviceGetInfo)
39+
_PI_API(piDevicePartition)
40+
_PI_API(piDeviceRetain)
41+
_PI_API(piDeviceRelease)
42+
// IR
43+
_PI_API(piextDeviceSelectBinary)
44+
45+
#undef _PI_API
46+
};
47+
48+
// Report error and no return (keeps compiler happy about no return statements).
49+
[[noreturn]] void pi_die(const char *message);
50+
void pi_assert(bool condition, const char *message = 0);
51+
52+
#define _PI_STRINGIZE(x) _PI_STRINGIZE2(x)
53+
#define _PI_STRINGIZE2(x) #x
54+
#define PI_ASSERT(cond, msg) \
55+
pi_assert(condition, "assert @ " __FILE__ ":" _PI_STRINGIZE(__LINE__) msg);
56+
57+
// This does the call, the trace and the check for no errors.
58+
// TODO: remove dependency on CHECK_OCL_CODE.
59+
// TODO: implement a more mature and controllable tracing of PI calls.
60+
void pi_trace(const char *format, ...);
61+
#define PI_CALL(pi_call) { \
62+
pi_trace("PI ---> %s\n", #pi_call); \
63+
auto __result = (pi_call); \
64+
pi_trace("PI <--- %d\n", __result); \
65+
CHECK_OCL_CODE(__result); \
66+
}
67+
68+
// Want all the needed casts be explicit, do not define conversion operators.
69+
template<class To, class From>
70+
To pi_cast(From value) {
71+
// TODO: see if more sanity checks are possible.
72+
pi_assert(sizeof(From) == sizeof(To));
73+
return (To)(value);
74+
}
75+
76+
} // namespace detail
77+
} // namespace sycl
78+
} // namespace cl
79+
Lines changed: 52 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,52 @@
1-
#pragma once
2-
3-
#include <CL/opencl.h>
4-
#include <CL/sycl/detail/pi.hpp>
5-
6-
namespace cl {
7-
namespace sycl {
8-
namespace detail {
9-
10-
//
11-
// TODO: there is no such functionality in OpenCL so call PI OpenCL
12-
// plugin directly for now, the whole "opencl" class is temporary anyway.
13-
//
14-
extern "C" decltype(::piextDeviceSelectBinary) ocl_piextDeviceSelectBinary;
15-
using cl_device_binary_type = ::pi_device_binary_type;
16-
17-
// Mapping of PI interfaces to OpenCL at compile-time.
18-
// This is the default config until the entire SYCL RT is transferred to PI.
19-
// TODO: we can just remove this when default is change to PI.
20-
//
21-
class opencl {
22-
public:
23-
using pi_result = cl_int;
24-
using pi_platform = cl_platform_id;
25-
using pi_device = cl_device_id;
26-
using pi_device_type = cl_device_type;
27-
using pi_device_binary_type = cl_device_binary_type;
28-
using pi_device_info = cl_device_info;
29-
using pi_program = cl_program;
30-
31-
// Convinience macro to have mapping look like a compact table.
32-
#define PI_CL(pi_api, cl_api) \
33-
static constexpr decltype(cl_api) * pi_api = &cl_api;
34-
35-
// Platform
36-
PI_CL(piPlatformsGet, clGetPlatformIDs)
37-
PI_CL(piPlatformGetInfo, clGetPlatformInfo)
38-
// Device
39-
PI_CL(piDevicesGet, clGetDeviceIDs)
40-
PI_CL(piDeviceGetInfo, clGetDeviceInfo)
41-
PI_CL(piDevicePartition, clCreateSubDevices)
42-
PI_CL(piDeviceRetain, clRetainDevice)
43-
PI_CL(piDeviceRelease, clReleaseDevice)
44-
// IR
45-
PI_CL(piextDeviceSelectBinary, ocl_piextDeviceSelectBinary)
46-
47-
#undef PI_CL
48-
};
49-
50-
} // namespace detail
51-
} // namespace sycl
52-
} // namespace cl
1+
#pragma once
2+
3+
#include <CL/opencl.h>
4+
#include <CL/sycl/detail/pi.hpp>
5+
6+
namespace cl {
7+
namespace sycl {
8+
namespace detail {
9+
10+
//
11+
// TODO: there is no such functionality in OpenCL so call PI OpenCL
12+
// plugin directly for now, the whole "opencl" class is temporary anyway.
13+
//
14+
extern "C" decltype(::piextDeviceSelectBinary) ocl_piextDeviceSelectBinary;
15+
using cl_device_binary_type = ::pi_device_binary_type;
16+
17+
// Mapping of PI interfaces to OpenCL at compile-time.
18+
// This is the default config until the entire SYCL RT is transferred to PI.
19+
// TODO: we can just remove this when default is change to PI.
20+
//
21+
class opencl {
22+
public:
23+
using pi_result = cl_int;
24+
using pi_platform = cl_platform_id;
25+
using pi_device = cl_device_id;
26+
using pi_device_type = cl_device_type;
27+
using pi_device_binary_type = cl_device_binary_type;
28+
using pi_device_info = cl_device_info;
29+
using pi_program = cl_program;
30+
31+
// Convinience macro to have mapping look like a compact table.
32+
#define PI_CL(pi_api, cl_api) \
33+
static constexpr decltype(cl_api) * pi_api = &cl_api;
34+
35+
// Platform
36+
PI_CL(piPlatformsGet, clGetPlatformIDs)
37+
PI_CL(piPlatformGetInfo, clGetPlatformInfo)
38+
// Device
39+
PI_CL(piDevicesGet, clGetDeviceIDs)
40+
PI_CL(piDeviceGetInfo, clGetDeviceInfo)
41+
PI_CL(piDevicePartition, clCreateSubDevices)
42+
PI_CL(piDeviceRetain, clRetainDevice)
43+
PI_CL(piDeviceRelease, clReleaseDevice)
44+
// IR
45+
PI_CL(piextDeviceSelectBinary, ocl_piextDeviceSelectBinary)
46+
47+
#undef PI_CL
48+
};
49+
50+
} // namespace detail
51+
} // namespace sycl
52+
} // namespace cl

0 commit comments

Comments
 (0)