Skip to content

Commit 381356c

Browse files
author
Fábio Mestre
committed
[SYCL][OpenCL] Change variable naming to match LLVM Coding Style guidelines
1 parent 7120019 commit 381356c

File tree

18 files changed

+1000
-1179
lines changed

18 files changed

+1000
-1179
lines changed

sycl/plugins/unified_runtime/pi2ur.hpp

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ inline pi_result ur2piDeviceInfoValue(ur_device_info_t ParamName,
343343
/* Helper function to perform conversions in-place */
344344
ConvertHelper Value(ParamValueSize, ParamValue, ParamValueSizeRet);
345345

346-
pi_result error = PI_SUCCESS;
346+
pi_result Error = PI_SUCCESS;
347347
if (ParamName == UR_DEVICE_INFO_TYPE) {
348348
auto ConvertFunc = [](ur_device_type_t UrValue) {
349349
switch (UrValue) {
@@ -435,25 +435,24 @@ inline pi_result ur2piDeviceInfoValue(ur_device_info_t ParamName,
435435
sizeof(ur_device_partition_property_t),
436436
PI_ERROR_UNKNOWN);
437437

438-
const uint32_t ur_number_elements =
438+
const uint32_t UrNumberElements =
439439
*ParamValueSizeRet / sizeof(ur_device_partition_property_t);
440440

441441
if (ParamValue) {
442-
auto param_value_copy =
443-
std::make_unique<ur_device_partition_property_t[]>(
444-
ur_number_elements);
445-
std::memcpy(param_value_copy.get(), ParamValue,
446-
ur_number_elements * sizeof(ur_device_partition_property_t));
442+
auto ParamValueCopy =
443+
std::make_unique<ur_device_partition_property_t[]>(UrNumberElements);
444+
std::memcpy(ParamValueCopy.get(), ParamValue,
445+
UrNumberElements * sizeof(ur_device_partition_property_t));
447446
pi_device_partition_property *pValuePI =
448447
reinterpret_cast<pi_device_partition_property *>(ParamValue);
449448
ur_device_partition_property_t *pValueUR =
450449
reinterpret_cast<ur_device_partition_property_t *>(
451-
param_value_copy.get());
452-
const ur_device_partition_t type = pValueUR->type;
453-
*pValuePI = ConvertFunc(type);
450+
ParamValueCopy.get());
451+
const ur_device_partition_t Type = pValueUR->type;
452+
*pValuePI = ConvertFunc(Type);
454453
++pValuePI;
455454

456-
for (uint32_t i = 0; i < ur_number_elements; ++i) {
455+
for (uint32_t i = 0; i < UrNumberElements; ++i) {
457456
switch (pValueUR->type) {
458457
case UR_DEVICE_PARTITION_EQUALLY: {
459458
*pValuePI = pValueUR->value.equally;
@@ -480,7 +479,7 @@ inline pi_result ur2piDeviceInfoValue(ur_device_info_t ParamName,
480479
/* Add 2 extra elements to the return value (one for the type at the
481480
* beginning and another to terminate the array with a 0 */
482481
*ParamValueSizeRet =
483-
(ur_number_elements + 2) * sizeof(pi_device_partition_property);
482+
(UrNumberElements + 2) * sizeof(pi_device_partition_property);
484483
}
485484
}
486485

@@ -610,7 +609,7 @@ inline pi_result ur2piDeviceInfoValue(ur_device_info_t ParamName,
610609
(int)ParamValueSize, (int)*ParamValueSizeRet);
611610
die("ur2piDeviceInfoValue: size mismatch");
612611
}
613-
return error;
612+
return Error;
614613
}
615614

616615
inline pi_result ur2piSamplerInfoValue(ur_sampler_info_t ParamName,

sycl/plugins/unified_runtime/ur/adapters/opencl/common.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@ namespace cl_adapter {
1414
thread_local int32_t ErrorMessageCode = 0;
1515
thread_local char ErrorMessage[MaxMessageSize];
1616

17-
[[maybe_unused]] void setErrorMessage(const char *message, int32_t error_code) {
18-
assert(strlen(message) <= cl_adapter::MaxMessageSize);
19-
strcpy(cl_adapter::ErrorMessage, message);
20-
ErrorMessageCode = error_code;
17+
[[maybe_unused]] void setErrorMessage(const char *Message, int32_t ErrorCode) {
18+
assert(strlen(Message) <= cl_adapter::MaxMessageSize);
19+
strcpy(cl_adapter::ErrorMessage, Message);
20+
ErrorMessageCode = ErrorCode;
2121
}
2222
} // namespace cl_adapter
2323

24-
ur_result_t map_cl_error_to_ur(cl_int result) {
25-
switch (result) {
24+
ur_result_t mapCLErrorToUR(cl_int Result) {
25+
switch (Result) {
2626
case CL_SUCCESS:
2727
return UR_RESULT_SUCCESS;
2828
case CL_OUT_OF_HOST_MEMORY:
@@ -70,13 +70,13 @@ void cl_adapter::die(const char *Message) {
7070

7171
/// Common API for getting the native handle of a UR object
7272
///
73-
/// \param urObj is the UR object to get the native handle of
74-
/// \param nativeHandle is a pointer to be set to the native handle
73+
/// \param URObj is the UR object to get the native handle of
74+
/// \param NativeHandle is a pointer to be set to the native handle
7575
///
7676
/// UR_RESULT_SUCCESS
77-
ur_result_t urGetNativeHandle(void *urObj, ur_native_handle_t *nativeHandle) {
78-
UR_ASSERT(nativeHandle, UR_RESULT_ERROR_INVALID_NULL_POINTER)
79-
*nativeHandle = reinterpret_cast<ur_native_handle_t>(urObj);
77+
ur_result_t getNativeHandle(void *URObj, ur_native_handle_t *NativeHandle) {
78+
UR_ASSERT(NativeHandle, UR_RESULT_ERROR_INVALID_NULL_POINTER)
79+
*NativeHandle = reinterpret_cast<ur_native_handle_t>(URObj);
8080
return UR_RESULT_SUCCESS;
8181
}
8282

sycl/plugins/unified_runtime/ur/adapters/opencl/common.hpp

Lines changed: 70 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
#include <climits>
1111
#include <regex>
1212
#include <sycl/detail/cl.h>
13-
#include <sycl/detail/pi.h>
1413
#include <sycl/detail/defines.hpp>
14+
#include <sycl/detail/pi.h>
1515
#include <ur/ur.hpp>
1616

1717
/**
@@ -20,7 +20,7 @@
2020
*/
2121
#define CL_RETURN_ON_FAILURE(clCall) \
2222
if (const cl_int cl_result_macro = clCall; cl_result_macro != CL_SUCCESS) { \
23-
return map_cl_error_to_ur(cl_result_macro); \
23+
return mapCLErrorToUR(cl_result_macro); \
2424
}
2525

2626
/**
@@ -43,10 +43,10 @@
4343
if (outPtr != nullptr) { \
4444
*outPtr = nullptr; \
4545
} \
46-
return map_cl_error_to_ur(cl_result_macro); \
46+
return mapCLErrorToUR(cl_result_macro); \
4747
}
4848

49-
namespace OCLV {
49+
namespace oclv {
5050
class OpenCLVersion {
5151
protected:
5252
unsigned int ocl_major;
@@ -55,56 +55,56 @@ class OpenCLVersion {
5555
public:
5656
OpenCLVersion() : ocl_major(0), ocl_minor(0) {}
5757

58-
OpenCLVersion(unsigned int ocl_major, unsigned int ocl_minor)
59-
: ocl_major(ocl_major), ocl_minor(ocl_minor) {
58+
OpenCLVersion(unsigned int OclMajor, unsigned int OclMinor)
59+
: ocl_major(OclMajor), ocl_minor(OclMinor) {
6060
if (!isValid()) {
61-
ocl_major = ocl_minor = 0;
61+
OclMajor = OclMinor = 0;
6262
}
6363
}
6464

65-
OpenCLVersion(const char *version) : OpenCLVersion(std::string(version)) {}
65+
OpenCLVersion(const char *Version) : OpenCLVersion(std::string(Version)) {}
6666

67-
OpenCLVersion(const std::string &version) : ocl_major(0), ocl_minor(0) {
67+
OpenCLVersion(const std::string &Version) : ocl_major(0), ocl_minor(0) {
6868
/* The OpenCL specification defines the full version string as
6969
* 'OpenCL<space><ocl_major_version.ocl_minor_version><space><platform-specific
7070
* information>' for platforms and as
7171
* 'OpenCL<space><ocl_major_version.ocl_minor_version><space><vendor-specific
7272
* information>' for devices.
7373
*/
74-
std::regex rx("OpenCL ([0-9]+)\\.([0-9]+)");
75-
std::smatch match;
74+
std::regex Rx("OpenCL ([0-9]+)\\.([0-9]+)");
75+
std::smatch Match;
7676

77-
if (std::regex_search(version, match, rx) && (match.size() == 3)) {
78-
ocl_major = strtoul(match[1].str().c_str(), nullptr, 10);
79-
ocl_minor = strtoul(match[2].str().c_str(), nullptr, 10);
77+
if (std::regex_search(Version, Match, Rx) && (Match.size() == 3)) {
78+
ocl_major = strtoul(Match[1].str().c_str(), nullptr, 10);
79+
ocl_minor = strtoul(Match[2].str().c_str(), nullptr, 10);
8080

8181
if (!isValid()) {
8282
ocl_major = ocl_minor = 0;
8383
}
8484
}
8585
}
8686

87-
bool operator==(const OpenCLVersion &v) const {
88-
return ocl_major == v.ocl_major && ocl_minor == v.ocl_minor;
87+
bool operator==(const OpenCLVersion &V) const {
88+
return ocl_major == V.ocl_major && ocl_minor == V.ocl_minor;
8989
}
9090

91-
bool operator!=(const OpenCLVersion &v) const { return !(*this == v); }
91+
bool operator!=(const OpenCLVersion &V) const { return !(*this == V); }
9292

93-
bool operator<(const OpenCLVersion &v) const {
94-
if (ocl_major == v.ocl_major)
95-
return ocl_minor < v.ocl_minor;
93+
bool operator<(const OpenCLVersion &V) const {
94+
if (ocl_major == V.ocl_major)
95+
return ocl_minor < V.ocl_minor;
9696

97-
return ocl_major < v.ocl_major;
97+
return ocl_major < V.ocl_major;
9898
}
9999

100-
bool operator>(const OpenCLVersion &v) const { return v < *this; }
100+
bool operator>(const OpenCLVersion &V) const { return V < *this; }
101101

102-
bool operator<=(const OpenCLVersion &v) const {
103-
return (*this < v) || (*this == v);
102+
bool operator<=(const OpenCLVersion &V) const {
103+
return (*this < V) || (*this == V);
104104
}
105105

106-
bool operator>=(const OpenCLVersion &v) const {
107-
return (*this > v) || (*this == v);
106+
bool operator>=(const OpenCLVersion &V) const {
107+
return (*this > V) || (*this == V);
108108
}
109109

110110
bool isValid() const {
@@ -133,30 +133,30 @@ inline const OpenCLVersion V2_1(2, 1);
133133
inline const OpenCLVersion V2_2(2, 2);
134134
inline const OpenCLVersion V3_0(3, 0);
135135

136-
} // namespace OCLV
136+
} // namespace oclv
137137

138138
namespace cl_adapter {
139139
constexpr size_t MaxMessageSize = 256;
140140
extern thread_local int32_t ErrorMessageCode;
141141
extern thread_local char ErrorMessage[MaxMessageSize];
142142

143143
// Utility function for setting a message and warning
144-
[[maybe_unused]] void setErrorMessage(const char *message,
145-
ur_result_t error_code);
144+
[[maybe_unused]] void setErrorMessage(const char *Message,
145+
ur_result_t ErrorCode);
146146

147147
[[noreturn]] void die(const char *Message);
148148

149-
template <class To, class From> To cast(From value) {
149+
template <class To, class From> To cast(From Value) {
150150

151151
if constexpr (std::is_pointer_v<From>) {
152152
static_assert(std::is_pointer_v<From> == std::is_pointer_v<To>,
153153
"Cast failed pointer check");
154-
return reinterpret_cast<To>(value);
154+
return reinterpret_cast<To>(Value);
155155
} else {
156156
static_assert(sizeof(From) == sizeof(To), "Cast failed size check");
157157
static_assert(std::is_signed_v<From> == std::is_signed_v<To>,
158158
"Cast failed sign check");
159-
return static_cast<To>(value);
159+
return static_cast<To>(Value);
160160
}
161161
}
162162
} // namespace cl_adapter
@@ -170,27 +170,27 @@ namespace cl_ext {
170170
#endif
171171

172172
// Names of USM functions that are queried from OpenCL
173-
CONSTFIX char clHostMemAllocName[] = "clHostMemAllocINTEL";
174-
CONSTFIX char clDeviceMemAllocName[] = "clDeviceMemAllocINTEL";
175-
CONSTFIX char clSharedMemAllocName[] = "clSharedMemAllocINTEL";
176-
CONSTFIX char clMemBlockingFreeName[] = "clMemBlockingFreeINTEL";
177-
CONSTFIX char clCreateBufferWithPropertiesName[] =
173+
CONSTFIX char HostMemAllocName[] = "clHostMemAllocINTEL";
174+
CONSTFIX char DeviceMemAllocName[] = "clDeviceMemAllocINTEL";
175+
CONSTFIX char SharedMemAllocName[] = "clSharedMemAllocINTEL";
176+
CONSTFIX char MemBlockingFreeName[] = "clMemBlockingFreeINTEL";
177+
CONSTFIX char CreateBufferWithPropertiesName[] =
178178
"clCreateBufferWithPropertiesINTEL";
179-
CONSTFIX char clSetKernelArgMemPointerName[] = "clSetKernelArgMemPointerINTEL";
180-
CONSTFIX char clEnqueueMemFillName[] = "clEnqueueMemFillINTEL";
181-
CONSTFIX char clEnqueueMemcpyName[] = "clEnqueueMemcpyINTEL";
182-
CONSTFIX char clGetMemAllocInfoName[] = "clGetMemAllocInfoINTEL";
183-
CONSTFIX char clSetProgramSpecializationConstantName[] =
179+
CONSTFIX char SetKernelArgMemPointerName[] = "clSetKernelArgMemPointerINTEL";
180+
CONSTFIX char EnqueueMemFillName[] = "clEnqueueMemFillINTEL";
181+
CONSTFIX char EnqueueMemcpyName[] = "clEnqueueMemcpyINTEL";
182+
CONSTFIX char GetMemAllocInfoName[] = "clGetMemAllocInfoINTEL";
183+
CONSTFIX char SetProgramSpecializationConstantName[] =
184184
"clSetProgramSpecializationConstant";
185-
CONSTFIX char clGetDeviceFunctionPointerName[] =
185+
CONSTFIX char GetDeviceFunctionPointerName[] =
186186
"clGetDeviceFunctionPointerINTEL";
187-
CONSTFIX char clEnqueueWriteGlobalVariableName[] =
187+
CONSTFIX char EnqueueWriteGlobalVariableName[] =
188188
"clEnqueueWriteGlobalVariableINTEL";
189-
CONSTFIX char clEnqueueReadGlobalVariableName[] =
189+
CONSTFIX char EnqueueReadGlobalVariableName[] =
190190
"clEnqueueReadGlobalVariableINTEL";
191191
// Names of host pipe functions queried from OpenCL
192-
CONSTFIX char clEnqueueReadHostPipeName[] = "clEnqueueReadHostPipeINTEL";
193-
CONSTFIX char clEnqueueWriteHostPipeName[] = "clEnqueueWriteHostPipeINTEL";
192+
CONSTFIX char EnqueueReadHostPipeName[] = "clEnqueueReadHostPipeINTEL";
193+
CONSTFIX char EnqueueWriteHostPipeName[] = "clEnqueueWriteHostPipeINTEL";
194194

195195
#undef CONSTFIX
196196

@@ -263,64 +263,64 @@ inline ExtFuncPtrCacheT *ExtFuncPtrCache;
263263

264264
// USM helper function to get an extension function pointer
265265
template <typename T>
266-
static ur_result_t getExtFuncFromContext(cl_context context,
266+
static ur_result_t getExtFuncFromContext(cl_context Context,
267267
FuncPtrCache<T> &FPtrCache,
268-
const char *FuncName, T *fptr) {
268+
const char *FuncName, T *Fptr) {
269269
// TODO
270270
// Potentially redo caching as UR interface changes.
271271
// if cached, return cached FuncPtr
272272
std::lock_guard<std::mutex> CacheLock{FPtrCache.Mutex};
273273
std::map<cl_context, T> &FPtrMap = FPtrCache.Map;
274-
auto It = FPtrMap.find(context);
274+
auto It = FPtrMap.find(Context);
275275
if (It != FPtrMap.end()) {
276276
auto F = It->second;
277277
// if cached that extension is not available return nullptr and
278278
// UR_RESULT_ERROR_INVALID_VALUE
279-
*fptr = F;
279+
*Fptr = F;
280280
return F ? UR_RESULT_SUCCESS : UR_RESULT_ERROR_INVALID_VALUE;
281281
}
282282

283-
cl_uint deviceCount;
284-
cl_int ret_err = clGetContextInfo(context, CL_CONTEXT_NUM_DEVICES,
285-
sizeof(cl_uint), &deviceCount, nullptr);
283+
cl_uint DeviceCount;
284+
cl_int RetErr = clGetContextInfo(Context, CL_CONTEXT_NUM_DEVICES,
285+
sizeof(cl_uint), &DeviceCount, nullptr);
286286

287-
if (ret_err != CL_SUCCESS || deviceCount < 1) {
287+
if (RetErr != CL_SUCCESS || DeviceCount < 1) {
288288
return UR_RESULT_ERROR_INVALID_CONTEXT;
289289
}
290290

291-
std::vector<cl_device_id> devicesInCtx(deviceCount);
292-
ret_err = clGetContextInfo(context, CL_CONTEXT_DEVICES,
293-
deviceCount * sizeof(cl_device_id),
294-
devicesInCtx.data(), nullptr);
291+
std::vector<cl_device_id> DevicesInCtx(DeviceCount);
292+
RetErr = clGetContextInfo(Context, CL_CONTEXT_DEVICES,
293+
DeviceCount * sizeof(cl_device_id),
294+
DevicesInCtx.data(), nullptr);
295295

296-
if (ret_err != CL_SUCCESS) {
296+
if (RetErr != CL_SUCCESS) {
297297
return UR_RESULT_ERROR_INVALID_CONTEXT;
298298
}
299299

300-
cl_platform_id curPlatform;
301-
ret_err = clGetDeviceInfo(devicesInCtx[0], CL_DEVICE_PLATFORM,
302-
sizeof(cl_platform_id), &curPlatform, nullptr);
300+
cl_platform_id CurPlatform;
301+
RetErr = clGetDeviceInfo(DevicesInCtx[0], CL_DEVICE_PLATFORM,
302+
sizeof(cl_platform_id), &CurPlatform, nullptr);
303303

304-
if (ret_err != CL_SUCCESS) {
304+
if (RetErr != CL_SUCCESS) {
305305
return UR_RESULT_ERROR_INVALID_CONTEXT;
306306
}
307307

308308
T FuncPtr =
309-
(T)clGetExtensionFunctionAddressForPlatform(curPlatform, FuncName);
309+
(T)clGetExtensionFunctionAddressForPlatform(CurPlatform, FuncName);
310310

311311
if (!FuncPtr) {
312312
// Cache that the extension is not available
313-
FPtrMap[context] = nullptr;
313+
FPtrMap[Context] = nullptr;
314314
return UR_RESULT_ERROR_INVALID_VALUE;
315315
}
316316

317-
*fptr = FuncPtr;
318-
FPtrMap[context] = FuncPtr;
317+
*Fptr = FuncPtr;
318+
FPtrMap[Context] = FuncPtr;
319319

320320
return UR_RESULT_SUCCESS;
321321
}
322322
} // namespace cl_ext
323323

324-
ur_result_t map_cl_error_to_ur(cl_int result);
324+
ur_result_t mapCLErrorToUR(cl_int Result);
325325

326-
ur_result_t urGetNativeHandle(void *urObj, ur_native_handle_t *nativeHandle);
326+
ur_result_t getNativeHandle(void *URObj, ur_native_handle_t *NativeHandle);

0 commit comments

Comments
 (0)