Skip to content

Commit 6b17a96

Browse files
committed
Formating
1 parent 379ca1a commit 6b17a96

File tree

14 files changed

+130
-138
lines changed

14 files changed

+130
-138
lines changed

source/adapters/opencl/context.cpp

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ UR_APIEXPORT ur_result_t UR_APICALL urContextCreate(
4242
CLDevices[i] = phDevices[i]->get();
4343
}
4444

45-
cl_context Ctx = clCreateContext(nullptr, cl_adapter::cast<cl_uint>(DeviceCount),
46-
CLDevices.data(),
47-
nullptr, nullptr, cl_adapter::cast<cl_int *>(&Ret));
45+
cl_context Ctx = clCreateContext(
46+
nullptr, cl_adapter::cast<cl_uint>(DeviceCount), CLDevices.data(),
47+
nullptr, nullptr, cl_adapter::cast<cl_int *>(&Ret));
4848

4949
*phContext = new ur_context_handle_t_(Ctx, DeviceCount, phDevices);
5050
return mapCLErrorToUR(Ret);
@@ -95,9 +95,8 @@ urContextGetInfo(ur_context_handle_t hContext, ur_context_info_t propName,
9595
case UR_CONTEXT_INFO_DEVICES:
9696
case UR_CONTEXT_INFO_REFERENCE_COUNT: {
9797
size_t CheckPropSize = 0;
98-
auto ClResult =
99-
clGetContextInfo(hContext->get(), CLPropName,
100-
propSize, pPropValue, &CheckPropSize);
98+
auto ClResult = clGetContextInfo(hContext->get(), CLPropName, propSize,
99+
pPropValue, &CheckPropSize);
101100
if (pPropValue && CheckPropSize != propSize) {
102101
return UR_RESULT_ERROR_INVALID_SIZE;
103102
}
@@ -134,11 +133,11 @@ UR_APIEXPORT ur_result_t UR_APICALL urContextGetNativeHandle(
134133
}
135134

136135
UR_APIEXPORT ur_result_t UR_APICALL urContextCreateWithNativeHandle(
137-
ur_native_handle_t hNativeContext, uint32_t numDevices, const ur_device_handle_t *phDevices,
138-
const ur_context_native_properties_t *, ur_context_handle_t *phContext) {
136+
ur_native_handle_t hNativeContext, uint32_t numDevices,
137+
const ur_device_handle_t *phDevices, const ur_context_native_properties_t *,
138+
ur_context_handle_t *phContext) {
139139

140-
cl_context NativeHandle =
141-
reinterpret_cast<cl_context>(hNativeContext);
140+
cl_context NativeHandle = reinterpret_cast<cl_context>(hNativeContext);
142141
*phContext = new ur_context_handle_t_(NativeHandle, numDevices, phDevices);
143142
return UR_RESULT_SUCCESS;
144143
}
@@ -189,8 +188,8 @@ UR_APIEXPORT ur_result_t UR_APICALL urContextSetExtendedDeleter(
189188
auto *C = static_cast<ContextCallback *>(pUserData);
190189
C->execute();
191190
};
192-
CL_RETURN_ON_FAILURE(clSetContextDestructorCallback(
193-
hContext->get(), ClCallback, Callback));
191+
CL_RETURN_ON_FAILURE(
192+
clSetContextDestructorCallback(hContext->get(), ClCallback, Callback));
194193

195194
return UR_RESULT_SUCCESS;
196195
}

source/adapters/opencl/context.hpp

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,20 @@ getDevicesFromContext(ur_context_handle_t hContext,
2121
}
2222

2323
struct ur_context_handle_t_ {
24-
using native_type = cl_context;
25-
native_type Context;
26-
std::vector<ur_device_handle_t> Devices;
27-
uint32_t DeviceCount;
24+
using native_type = cl_context;
25+
native_type Context;
26+
std::vector<ur_device_handle_t> Devices;
27+
uint32_t DeviceCount;
2828

29-
ur_context_handle_t_(native_type Ctx, uint32_t DevCount, const ur_device_handle_t *phDevices) : Context(Ctx), DeviceCount(DevCount) {
30-
for (uint32_t i = 0; i < DeviceCount; i++) {
31-
Devices.emplace_back(phDevices[i]);
32-
}
29+
ur_context_handle_t_(native_type Ctx, uint32_t DevCount,
30+
const ur_device_handle_t *phDevices)
31+
: Context(Ctx), DeviceCount(DevCount) {
32+
for (uint32_t i = 0; i < DeviceCount; i++) {
33+
Devices.emplace_back(phDevices[i]);
3334
}
35+
}
3436

35-
~ur_context_handle_t_() {}
37+
~ur_context_handle_t_() {}
3638

37-
native_type get() { return Context; }
39+
native_type get() { return Context; }
3840
};

source/adapters/opencl/device.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,10 @@ ur_result_t cl_adapter::checkDeviceExtensions(
5252
return UR_RESULT_SUCCESS;
5353
}
5454

55-
UR_APIEXPORT ur_result_t UR_APICALL urDeviceGet(ur_platform_handle_t hPlatform,
56-
ur_device_type_t DeviceType,
57-
[[maybe_unused]] uint32_t NumEntries,
58-
ur_device_handle_t *phDevices,
59-
uint32_t *pNumDevices) {
55+
UR_APIEXPORT ur_result_t UR_APICALL
56+
urDeviceGet(ur_platform_handle_t hPlatform, ur_device_type_t DeviceType,
57+
[[maybe_unused]] uint32_t NumEntries, ur_device_handle_t *phDevices,
58+
uint32_t *pNumDevices) {
6059

6160
cl_device_type Type;
6261
switch (DeviceType) {
@@ -1000,7 +999,8 @@ UR_APIEXPORT ur_result_t UR_APICALL urDevicePartition(
1000999
CLNumDevicesRet,
10011000
CLSubDevices.data(), nullptr));
10021001
for (uint32_t i = 0; i < NumDevices; i++) {
1003-
phSubDevices[i] = new ur_device_handle_t_(CLSubDevices[i], hDevice->Platform, hDevice);
1002+
phSubDevices[i] =
1003+
new ur_device_handle_t_(CLSubDevices[i], hDevice->Platform, hDevice);
10041004
}
10051005
}
10061006

source/adapters/opencl/device.hpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,16 @@ struct ur_device_handle_t_ {
2424
native_type Device;
2525
ur_platform_handle_t Platform;
2626
cl_device_type Type = 0;
27-
ur_device_handle_t ParentDevice = nullptr;
27+
ur_device_handle_t ParentDevice = nullptr;
2828

29-
ur_device_handle_t_(native_type Dev, ur_platform_handle_t Plat, ur_device_handle_t Parent)
29+
ur_device_handle_t_(native_type Dev, ur_platform_handle_t Plat,
30+
ur_device_handle_t Parent)
3031
: Device(Dev), Platform(Plat), ParentDevice(Parent) {
3132
if (Parent) {
3233
Type = Parent->Type;
3334
} else {
34-
clGetDeviceInfo(Device, CL_DEVICE_TYPE, sizeof(cl_device_type), &Type, nullptr);
35+
clGetDeviceInfo(Device, CL_DEVICE_TYPE, sizeof(cl_device_type), &Type,
36+
nullptr);
3537
}
3638
}
3739

source/adapters/opencl/enqueue.cpp

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -345,9 +345,8 @@ UR_APIEXPORT ur_result_t UR_APICALL urEnqueueDeviceGlobalVariableWrite(
345345
if (!F || Res != CL_SUCCESS)
346346
return UR_RESULT_ERROR_INVALID_OPERATION;
347347

348-
Res = F(cl_adapter::cast<cl_command_queue>(hQueue),
349-
hProgram->get(), name, blockingWrite, count,
350-
offset, pSrc, numEventsInWaitList,
348+
Res = F(cl_adapter::cast<cl_command_queue>(hQueue), hProgram->get(), name,
349+
blockingWrite, count, offset, pSrc, numEventsInWaitList,
351350
cl_adapter::cast<const cl_event *>(phEventWaitList),
352351
cl_adapter::cast<cl_event *>(phEvent));
353352

@@ -376,9 +375,8 @@ UR_APIEXPORT ur_result_t UR_APICALL urEnqueueDeviceGlobalVariableRead(
376375
if (!F || Res != CL_SUCCESS)
377376
return UR_RESULT_ERROR_INVALID_OPERATION;
378377

379-
Res = F(cl_adapter::cast<cl_command_queue>(hQueue),
380-
hProgram->get(), name, blockingRead, count,
381-
offset, pDst, numEventsInWaitList,
378+
Res = F(cl_adapter::cast<cl_command_queue>(hQueue), hProgram->get(), name,
379+
blockingRead, count, offset, pDst, numEventsInWaitList,
382380
cl_adapter::cast<const cl_event *>(phEventWaitList),
383381
cl_adapter::cast<cl_event *>(phEvent));
384382

@@ -407,9 +405,8 @@ UR_APIEXPORT ur_result_t UR_APICALL urEnqueueReadHostPipe(
407405

408406
if (FuncPtr) {
409407
RetVal = mapCLErrorToUR(
410-
FuncPtr(cl_adapter::cast<cl_command_queue>(hQueue),
411-
hProgram->get(), pipe_symbol, blocking,
412-
pDst, size, numEventsInWaitList,
408+
FuncPtr(cl_adapter::cast<cl_command_queue>(hQueue), hProgram->get(),
409+
pipe_symbol, blocking, pDst, size, numEventsInWaitList,
413410
cl_adapter::cast<const cl_event *>(phEventWaitList),
414411
cl_adapter::cast<cl_event *>(phEvent)));
415412
}
@@ -439,9 +436,8 @@ UR_APIEXPORT ur_result_t UR_APICALL urEnqueueWriteHostPipe(
439436

440437
if (FuncPtr) {
441438
RetVal = mapCLErrorToUR(
442-
FuncPtr(cl_adapter::cast<cl_command_queue>(hQueue),
443-
hProgram->get(), pipe_symbol, blocking,
444-
pSrc, size, numEventsInWaitList,
439+
FuncPtr(cl_adapter::cast<cl_command_queue>(hQueue), hProgram->get(),
440+
pipe_symbol, blocking, pSrc, size, numEventsInWaitList,
445441
cl_adapter::cast<const cl_event *>(phEventWaitList),
446442
cl_adapter::cast<cl_event *>(phEvent)));
447443
}

source/adapters/opencl/kernel.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ urKernelCreate(ur_program_handle_t hProgram, const char *pKernelName,
1919
ur_kernel_handle_t *phKernel) {
2020

2121
cl_int CLResult;
22-
*phKernel = cl_adapter::cast<ur_kernel_handle_t>(clCreateKernel(
23-
hProgram->get(), pKernelName, &CLResult));
22+
*phKernel = cl_adapter::cast<ur_kernel_handle_t>(
23+
clCreateKernel(hProgram->get(), pKernelName, &CLResult));
2424
CL_RETURN_ON_FAILURE(CLResult);
2525
return UR_RESULT_SUCCESS;
2626
}

source/adapters/opencl/memory.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -270,9 +270,9 @@ UR_APIEXPORT ur_result_t UR_APICALL urMemBufferCreate(
270270
}
271271

272272
void *HostPtr = pProperties ? pProperties->pHost : nullptr;
273-
*phBuffer = reinterpret_cast<ur_mem_handle_t>(clCreateBuffer(
274-
hContext->get(), static_cast<cl_mem_flags>(flags),
275-
size, HostPtr, cl_adapter::cast<cl_int *>(&RetErr)));
273+
*phBuffer = reinterpret_cast<ur_mem_handle_t>(
274+
clCreateBuffer(hContext->get(), static_cast<cl_mem_flags>(flags), size,
275+
HostPtr, cl_adapter::cast<cl_int *>(&RetErr)));
276276
CL_RETURN_ON_FAILURE(RetErr);
277277

278278
return UR_RESULT_SUCCESS;
@@ -289,9 +289,9 @@ UR_APIEXPORT ur_result_t UR_APICALL urMemImageCreate(
289289
cl_image_desc ImageDesc = mapURImageDescToCL(pImageDesc);
290290
cl_map_flags MapFlags = convertURMemFlagsToCL(flags);
291291

292-
*phMem = reinterpret_cast<ur_mem_handle_t>(clCreateImage(
293-
hContext->get(), MapFlags, &ImageFormat,
294-
&ImageDesc, pHost, cl_adapter::cast<cl_int *>(&RetErr)));
292+
*phMem = reinterpret_cast<ur_mem_handle_t>(
293+
clCreateImage(hContext->get(), MapFlags, &ImageFormat, &ImageDesc, pHost,
294+
cl_adapter::cast<cl_int *>(&RetErr)));
295295
CL_RETURN_ON_FAILURE(RetErr);
296296

297297
return UR_RESULT_SUCCESS;

source/adapters/opencl/platform.cpp

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,9 @@ urPlatformGetInfo(ur_platform_handle_t hPlatform, ur_platform_info_t propName,
6666
if (hPlatform) {
6767
Plat = hPlatform->get();
6868
}
69-
CL_RETURN_ON_FAILURE(clGetPlatformInfo(Plat, CLPropName,
70-
propSize, pPropValue, pSizeRet));
71-
69+
CL_RETURN_ON_FAILURE(
70+
clGetPlatformInfo(Plat, CLPropName, propSize, pPropValue, pSizeRet));
71+
7272
return UR_RESULT_SUCCESS;
7373
}
7474
default:
@@ -93,26 +93,25 @@ urPlatformGet(ur_adapter_handle_t *, uint32_t, uint32_t NumEntries,
9393
cl_int Result = CL_SUCCESS;
9494

9595
std::call_once(
96-
InitFlag,
97-
[](cl_int &Result) {
98-
Result = clGetPlatformIDs(0, nullptr, &NumPlatforms);
99-
if (Result != CL_SUCCESS) {
100-
return Result;
101-
}
102-
std::vector<cl_platform_id> CLPlatforms(NumPlatforms);
103-
Result = clGetPlatformIDs(cl_adapter::cast<cl_uint>(NumPlatforms),
104-
CLPlatforms.data(),
105-
nullptr);
106-
if (Result != CL_SUCCESS) {
96+
InitFlag,
97+
[](cl_int &Result) {
98+
Result = clGetPlatformIDs(0, nullptr, &NumPlatforms);
99+
if (Result != CL_SUCCESS) {
100+
return Result;
101+
}
102+
std::vector<cl_platform_id> CLPlatforms(NumPlatforms);
103+
Result = clGetPlatformIDs(cl_adapter::cast<cl_uint>(NumPlatforms),
104+
CLPlatforms.data(), nullptr);
105+
if (Result != CL_SUCCESS) {
106+
return Result;
107+
}
108+
URPlatforms.resize(NumPlatforms);
109+
for (uint32_t i = 0; i < NumPlatforms; i++) {
110+
URPlatforms[i] = new ur_platform_handle_t_(CLPlatforms[i]);
111+
}
107112
return Result;
108-
}
109-
URPlatforms.resize(NumPlatforms);
110-
for (uint32_t i = 0; i < NumPlatforms; i++) {
111-
URPlatforms[i] = new ur_platform_handle_t_(CLPlatforms[i]);
112-
}
113-
return Result;
114-
},
115-
Result);
113+
},
114+
Result);
116115

117116
/* Absorb the CL_PLATFORM_NOT_FOUND_KHR and just return 0 in num_platforms */
118117
if (Result == CL_PLATFORM_NOT_FOUND_KHR) {

source/adapters/opencl/platform.hpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -202,14 +202,16 @@ struct ur_platform_handle_t_ {
202202

203203
ur_result_t InitDevices() {
204204
cl_uint DeviceNum = 0;
205-
CL_RETURN_ON_FAILURE(clGetDeviceIDs(Platform, CL_DEVICE_TYPE_ALL, 0, nullptr, &DeviceNum));
205+
CL_RETURN_ON_FAILURE(
206+
clGetDeviceIDs(Platform, CL_DEVICE_TYPE_ALL, 0, nullptr, &DeviceNum));
206207

207208
std::vector<cl_device_id> CLDevices(DeviceNum);
208-
CL_RETURN_ON_FAILURE(clGetDeviceIDs(Platform, CL_DEVICE_TYPE_ALL, DeviceNum, CLDevices.data(), nullptr));
209+
CL_RETURN_ON_FAILURE(clGetDeviceIDs(Platform, CL_DEVICE_TYPE_ALL, DeviceNum,
210+
CLDevices.data(), nullptr));
209211

210212
Devices = std::vector<ur_device_handle_t>(DeviceNum);
211213
for (size_t i = 0; i < DeviceNum; i++) {
212-
Devices[i] = new ur_device_handle_t_(CLDevices[i], this, nullptr);
214+
Devices[i] = new ur_device_handle_t_(CLDevices[i], this, nullptr);
213215
}
214216

215217
return UR_RESULT_SUCCESS;

0 commit comments

Comments
 (0)