Skip to content

Commit 8d75566

Browse files
committed
make RefCount public and remove getRefCount().
1 parent a0ff136 commit 8d75566

20 files changed

+43
-77
lines changed

unified-runtime/source/adapters/opencl/adapter.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ urAdapterGet(uint32_t NumEntries, ur_adapter_handle_t *phAdapters,
7878
}
7979

8080
auto &adapter = *phAdapters;
81-
adapter->getRefCount().retain();
81+
adapter->RefCount.retain();
8282
}
8383

8484
if (pNumAdapters) {
@@ -90,13 +90,13 @@ urAdapterGet(uint32_t NumEntries, ur_adapter_handle_t *phAdapters,
9090

9191
UR_APIEXPORT ur_result_t UR_APICALL
9292
urAdapterRetain(ur_adapter_handle_t hAdapter) {
93-
hAdapter->getRefCount().retain();
93+
hAdapter->RefCount.retain();
9494
return UR_RESULT_SUCCESS;
9595
}
9696

9797
UR_APIEXPORT ur_result_t UR_APICALL
9898
urAdapterRelease(ur_adapter_handle_t hAdapter) {
99-
if (hAdapter->getRefCount().release()) {
99+
if (hAdapter->RefCount.release()) {
100100
delete hAdapter;
101101
}
102102
return UR_RESULT_SUCCESS;
@@ -119,7 +119,7 @@ urAdapterGetInfo(ur_adapter_handle_t hAdapter, ur_adapter_info_t propName,
119119
case UR_ADAPTER_INFO_BACKEND:
120120
return ReturnValue(UR_BACKEND_OPENCL);
121121
case UR_ADAPTER_INFO_REFERENCE_COUNT:
122-
return ReturnValue(hAdapter->getRefCount().getCount());
122+
return ReturnValue(hAdapter->RefCount.getCount());
123123
case UR_ADAPTER_INFO_VERSION:
124124
return ReturnValue(uint32_t{1});
125125
default:

unified-runtime/source/adapters/opencl/adapter.hpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,17 +31,14 @@ struct ur_adapter_handle_t_ : ur::opencl::handle_base {
3131
std::vector<std::unique_ptr<ur_platform_handle_t_>> URPlatforms;
3232
uint32_t NumPlatforms = 0;
3333

34+
ur::RefCount RefCount;
35+
3436
// Function pointers to core OpenCL entry points which may not exist in older
3537
// versions of the OpenCL-ICD-Loader are tracked here and initialized by
3638
// dynamically loading the symbol by name.
3739
#define CL_CORE_FUNCTION(FUNC) decltype(::FUNC) *FUNC = nullptr;
3840
#include "core_functions.def"
3941
#undef CL_CORE_FUNCTION
40-
41-
ur::RefCount &getRefCount() noexcept { return RefCount; }
42-
43-
private:
44-
ur::RefCount RefCount;
4542
};
4643

4744
namespace ur {

unified-runtime/source/adapters/opencl/command_buffer.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,13 +108,13 @@ UR_APIEXPORT ur_result_t UR_APICALL urCommandBufferCreateExp(
108108

109109
UR_APIEXPORT ur_result_t UR_APICALL
110110
urCommandBufferRetainExp(ur_exp_command_buffer_handle_t hCommandBuffer) {
111-
hCommandBuffer->getRefCount().retain();
111+
hCommandBuffer->RefCount.retain();
112112
return UR_RESULT_SUCCESS;
113113
}
114114

115115
UR_APIEXPORT ur_result_t UR_APICALL
116116
urCommandBufferReleaseExp(ur_exp_command_buffer_handle_t hCommandBuffer) {
117-
if (hCommandBuffer->getRefCount().release()) {
117+
if (hCommandBuffer->RefCount.release()) {
118118
delete hCommandBuffer;
119119
}
120120

@@ -783,7 +783,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urCommandBufferGetInfoExp(
783783

784784
switch (propName) {
785785
case UR_EXP_COMMAND_BUFFER_INFO_REFERENCE_COUNT:
786-
return ReturnValue(hCommandBuffer->getRefCount().getCount());
786+
return ReturnValue(hCommandBuffer->RefCount.getCount());
787787
case UR_EXP_COMMAND_BUFFER_INFO_DESCRIPTOR: {
788788
ur_exp_command_buffer_desc_t Descriptor{};
789789
Descriptor.stype = UR_STRUCTURE_TYPE_EXP_COMMAND_BUFFER_DESC;

unified-runtime/source/adapters/opencl/command_buffer.hpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ struct ur_exp_command_buffer_handle_t_ : ur::opencl::handle_base {
5757
/// Track last submission of the command-buffer
5858
cl_event LastSubmission;
5959

60+
ur::RefCount RefCount;
61+
6062
ur_exp_command_buffer_handle_t_(ur_queue_handle_t hQueue,
6163
ur_context_handle_t hContext,
6264
ur_device_handle_t hDevice,
@@ -68,9 +70,4 @@ struct ur_exp_command_buffer_handle_t_ : ur::opencl::handle_base {
6870
LastSubmission(nullptr) {}
6971

7072
~ur_exp_command_buffer_handle_t_();
71-
72-
ur::RefCount &getRefCount() noexcept { return RefCount; }
73-
74-
private:
75-
ur::RefCount RefCount;
7673
};

unified-runtime/source/adapters/opencl/context.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ urContextGetInfo(ur_context_handle_t hContext, ur_context_info_t propName,
108108
return ReturnValue(&hContext->Devices[0], hContext->DeviceCount);
109109
}
110110
case UR_CONTEXT_INFO_REFERENCE_COUNT: {
111-
return ReturnValue(hContext->getRefCount().getCount());
111+
return ReturnValue(hContext->RefCount.getCount());
112112
}
113113
default:
114114
return UR_RESULT_ERROR_INVALID_ENUMERATION;
@@ -117,7 +117,7 @@ urContextGetInfo(ur_context_handle_t hContext, ur_context_info_t propName,
117117

118118
UR_APIEXPORT ur_result_t UR_APICALL
119119
urContextRelease(ur_context_handle_t hContext) {
120-
if (hContext->getRefCount().release()) {
120+
if (hContext->RefCount.release()) {
121121
delete hContext;
122122
}
123123

@@ -126,7 +126,7 @@ urContextRelease(ur_context_handle_t hContext) {
126126

127127
UR_APIEXPORT ur_result_t UR_APICALL
128128
urContextRetain(ur_context_handle_t hContext) {
129-
hContext->getRefCount().retain();
129+
hContext->RefCount.retain();
130130
return UR_RESULT_SUCCESS;
131131
}
132132

unified-runtime/source/adapters/opencl/context.hpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ struct ur_context_handle_t_ : ur::opencl::handle_base {
2222
std::vector<ur_device_handle_t> Devices;
2323
uint32_t DeviceCount;
2424
bool IsNativeHandleOwned = true;
25+
ur::RefCount RefCount;
2526

2627
ur_context_handle_t_(native_type Ctx, uint32_t DevCount,
2728
const ur_device_handle_t *phDevices)
@@ -50,8 +51,4 @@ struct ur_context_handle_t_ : ur::opencl::handle_base {
5051
}
5152
}
5253

53-
ur::RefCount &getRefCount() noexcept { return RefCount; }
54-
55-
private:
56-
ur::RefCount RefCount;
5754
};

unified-runtime/source/adapters/opencl/device.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1019,7 +1019,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice,
10191019
return UR_RESULT_SUCCESS;
10201020
}
10211021
case UR_DEVICE_INFO_REFERENCE_COUNT: {
1022-
return ReturnValue(hDevice->getRefCount().getCount());
1022+
return ReturnValue(hDevice->RefCount.getCount());
10231023
}
10241024
case UR_DEVICE_INFO_PARTITION_MAX_SUB_DEVICES: {
10251025
CL_RETURN_ON_FAILURE(clGetDeviceInfo(hDevice->CLDevice,
@@ -1561,7 +1561,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urDevicePartition(
15611561
// Root devices ref count are unchanged through out the program lifetime.
15621562
UR_APIEXPORT ur_result_t UR_APICALL urDeviceRetain(ur_device_handle_t hDevice) {
15631563
if (hDevice->ParentDevice) {
1564-
hDevice->getRefCount().retain();
1564+
hDevice->RefCount.retain();
15651565
}
15661566

15671567
return UR_RESULT_SUCCESS;
@@ -1571,7 +1571,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceRetain(ur_device_handle_t hDevice) {
15711571
UR_APIEXPORT ur_result_t UR_APICALL
15721572
urDeviceRelease(ur_device_handle_t hDevice) {
15731573
if (hDevice->ParentDevice) {
1574-
if (hDevice->getRefCount().release()) {
1574+
if (hDevice->RefCount.release()) {
15751575
delete hDevice;
15761576
}
15771577
}

unified-runtime/source/adapters/opencl/device.hpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ struct ur_device_handle_t_ : ur::opencl::handle_base {
2121
cl_device_type Type = 0;
2222
ur_device_handle_t ParentDevice = nullptr;
2323
bool IsNativeHandleOwned = true;
24+
ur::RefCount RefCount;
2425

2526
ur_device_handle_t_(native_type Dev, ur_platform_handle_t Plat,
2627
ur_device_handle_t Parent)
@@ -108,8 +109,4 @@ struct ur_device_handle_t_ : ur::opencl::handle_base {
108109
return UR_RESULT_SUCCESS;
109110
}
110111

111-
ur::RefCount &getRefCount() noexcept { return RefCount; }
112-
113-
private:
114-
ur::RefCount RefCount;
115112
};

unified-runtime/source/adapters/opencl/event.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,14 +136,14 @@ UR_APIEXPORT ur_result_t UR_APICALL urEventGetNativeHandle(
136136
}
137137

138138
UR_APIEXPORT ur_result_t UR_APICALL urEventRelease(ur_event_handle_t hEvent) {
139-
if (hEvent->getRefCount().release()) {
139+
if (hEvent->RefCount.release()) {
140140
delete hEvent;
141141
}
142142
return UR_RESULT_SUCCESS;
143143
}
144144

145145
UR_APIEXPORT ur_result_t UR_APICALL urEventRetain(ur_event_handle_t hEvent) {
146-
hEvent->getRefCount().retain();
146+
hEvent->RefCount.retain();
147147
return UR_RESULT_SUCCESS;
148148
}
149149

@@ -188,7 +188,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urEventGetInfo(ur_event_handle_t hEvent,
188188
return ReturnValue(hEvent->Queue);
189189
}
190190
case UR_EVENT_INFO_REFERENCE_COUNT: {
191-
return ReturnValue(hEvent->getRefCount().getCount());
191+
return ReturnValue(hEvent->RefCount.getCount());
192192
}
193193
default: {
194194
size_t CheckPropSize = 0;

unified-runtime/source/adapters/opencl/event.hpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ struct ur_event_handle_t_ : ur::opencl::handle_base {
2121
ur_context_handle_t Context;
2222
ur_queue_handle_t Queue;
2323
bool IsNativeHandleOwned = true;
24+
ur::RefCount RefCount;
2425

2526
ur_event_handle_t_(native_type Event, ur_context_handle_t Ctx,
2627
ur_queue_handle_t Queue)
@@ -53,11 +54,6 @@ struct ur_event_handle_t_ : ur::opencl::handle_base {
5354

5455
return UR_RESULT_SUCCESS;
5556
}
56-
57-
ur::RefCount &getRefCount() noexcept { return RefCount; }
58-
59-
private:
60-
ur::RefCount RefCount;
6157
};
6258

6359
inline cl_event *ifUrEvent(ur_event_handle_t *ReturnedEvent, cl_event &Event) {

unified-runtime/source/adapters/opencl/kernel.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urKernelGetInfo(ur_kernel_handle_t hKernel,
152152
return ReturnValue(hKernel->Context);
153153
}
154154
case UR_KERNEL_INFO_REFERENCE_COUNT: {
155-
return ReturnValue(hKernel->getRefCount().getCount());
155+
return ReturnValue(hKernel->RefCount.getCount());
156156
}
157157
default: {
158158
size_t CheckPropSize = 0;
@@ -343,13 +343,13 @@ urKernelGetSubGroupInfo(ur_kernel_handle_t hKernel, ur_device_handle_t hDevice,
343343
}
344344

345345
UR_APIEXPORT ur_result_t UR_APICALL urKernelRetain(ur_kernel_handle_t hKernel) {
346-
hKernel->getRefCount().retain();
346+
hKernel->RefCount.retain();
347347
return UR_RESULT_SUCCESS;
348348
}
349349

350350
UR_APIEXPORT ur_result_t UR_APICALL
351351
urKernelRelease(ur_kernel_handle_t hKernel) {
352-
if (hKernel->getRefCount().release()) {
352+
if (hKernel->RefCount.release()) {
353353
delete hKernel;
354354
}
355355
return UR_RESULT_SUCCESS;

unified-runtime/source/adapters/opencl/kernel.hpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ struct ur_kernel_handle_t_ : ur::opencl::handle_base {
2424
ur_context_handle_t Context;
2525
bool IsNativeHandleOwned = true;
2626
clSetKernelArgMemPointerINTEL_fn clSetKernelArgMemPointerINTEL = nullptr;
27+
ur::RefCount RefCount;
2728

2829
ur_kernel_handle_t_(native_type Kernel, ur_program_handle_t Program,
2930
ur_context_handle_t Context)
@@ -49,9 +50,4 @@ struct ur_kernel_handle_t_ : ur::opencl::handle_base {
4950
ur_program_handle_t Program,
5051
ur_context_handle_t Context,
5152
ur_kernel_handle_t &Kernel);
52-
53-
ur::RefCount &getRefCount() noexcept { return RefCount; }
54-
55-
private:
56-
ur::RefCount RefCount;
5753
};

unified-runtime/source/adapters/opencl/memory.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -521,7 +521,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urMemGetInfo(ur_mem_handle_t hMemory,
521521
return ReturnValue(hMemory->Context);
522522
}
523523
case UR_MEM_INFO_REFERENCE_COUNT: {
524-
return ReturnValue(hMemory->getRefCount().getCount());
524+
return ReturnValue(hMemory->RefCount.getCount());
525525
}
526526
default: {
527527
size_t CheckPropSize = 0;
@@ -569,12 +569,12 @@ UR_APIEXPORT ur_result_t UR_APICALL urMemImageGetInfo(ur_mem_handle_t hMemory,
569569
}
570570

571571
UR_APIEXPORT ur_result_t UR_APICALL urMemRetain(ur_mem_handle_t hMem) {
572-
hMem->getRefCount().retain();
572+
hMem->RefCount.retain();
573573
return UR_RESULT_SUCCESS;
574574
}
575575

576576
UR_APIEXPORT ur_result_t UR_APICALL urMemRelease(ur_mem_handle_t hMem) {
577-
if (hMem->getRefCount().release()) {
577+
if (hMem->RefCount.release()) {
578578
delete hMem;
579579
}
580580
return UR_RESULT_SUCCESS;

unified-runtime/source/adapters/opencl/memory.hpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ struct ur_mem_handle_t_ : ur::opencl::handle_base {
2020
native_type CLMemory;
2121
ur_context_handle_t Context;
2222
bool IsNativeHandleOwned = true;
23+
ur::RefCount RefCount;
2324

2425
ur_mem_handle_t_(native_type Mem, ur_context_handle_t Ctx)
2526
: handle_base(), CLMemory(Mem), Context(Ctx) {
@@ -37,8 +38,4 @@ struct ur_mem_handle_t_ : ur::opencl::handle_base {
3738
ur_context_handle_t Ctx,
3839
ur_mem_handle_t &Mem);
3940

40-
ur::RefCount &getRefCount() noexcept { return RefCount; }
41-
42-
private:
43-
ur::RefCount RefCount;
4441
};

unified-runtime/source/adapters/opencl/program.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ urProgramGetInfo(ur_program_handle_t hProgram, ur_program_info_t propName,
223223
return ReturnValue(hProgram->Devices.data(), hProgram->NumDevices);
224224
}
225225
case UR_PROGRAM_INFO_REFERENCE_COUNT: {
226-
return ReturnValue(hProgram->getRefCount().getCount());
226+
return ReturnValue(hProgram->RefCount.getCount());
227227
}
228228
default: {
229229
size_t CheckPropSize = 0;
@@ -383,13 +383,13 @@ urProgramGetBuildInfo(ur_program_handle_t hProgram, ur_device_handle_t hDevice,
383383

384384
UR_APIEXPORT ur_result_t UR_APICALL
385385
urProgramRetain(ur_program_handle_t hProgram) {
386-
hProgram->getRefCount().retain();
386+
hProgram->RefCount.retain();
387387
return UR_RESULT_SUCCESS;
388388
}
389389

390390
UR_APIEXPORT ur_result_t UR_APICALL
391391
urProgramRelease(ur_program_handle_t hProgram) {
392-
if (hProgram->getRefCount().release()) {
392+
if (hProgram->RefCount.release()) {
393393
delete hProgram;
394394
}
395395
return UR_RESULT_SUCCESS;

unified-runtime/source/adapters/opencl/program.hpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ struct ur_program_handle_t_ : ur::opencl::handle_base {
2222
bool IsNativeHandleOwned = true;
2323
uint32_t NumDevices = 0;
2424
std::vector<ur_device_handle_t> Devices;
25+
ur::RefCount RefCount;
2526

2627
ur_program_handle_t_(native_type Prog, ur_context_handle_t Ctx,
2728
uint32_t NumDevices, ur_device_handle_t *Devs)
@@ -43,8 +44,4 @@ struct ur_program_handle_t_ : ur::opencl::handle_base {
4344
ur_context_handle_t Context,
4445
ur_program_handle_t &Program);
4546

46-
ur::RefCount &getRefCount() noexcept { return RefCount; }
47-
48-
private:
49-
ur::RefCount RefCount;
5047
};

unified-runtime/source/adapters/opencl/queue.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urQueueGetInfo(ur_queue_handle_t hQueue,
234234
return ReturnValue(mapCLQueuePropsToUR(QueueProperties));
235235
}
236236
case UR_QUEUE_INFO_REFERENCE_COUNT: {
237-
return ReturnValue(hQueue->getRefCount().getCount());
237+
return ReturnValue(hQueue->RefCount.getCount());
238238
}
239239
default: {
240240
size_t CheckPropSize = 0;
@@ -289,12 +289,12 @@ UR_APIEXPORT ur_result_t UR_APICALL urQueueFlush(ur_queue_handle_t hQueue) {
289289
}
290290

291291
UR_APIEXPORT ur_result_t UR_APICALL urQueueRetain(ur_queue_handle_t hQueue) {
292-
hQueue->getRefCount().retain();
292+
hQueue->RefCount.retain();
293293
return UR_RESULT_SUCCESS;
294294
}
295295

296296
UR_APIEXPORT ur_result_t UR_APICALL urQueueRelease(ur_queue_handle_t hQueue) {
297-
if (hQueue->getRefCount().release()) {
297+
if (hQueue->RefCount.release()) {
298298
delete hQueue;
299299
}
300300
return UR_RESULT_SUCCESS;

unified-runtime/source/adapters/opencl/queue.hpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ struct ur_queue_handle_t_ : ur::opencl::handle_base {
2727
// Used to implement UR_QUEUE_INFO_EMPTY query
2828
bool IsInOrder;
2929
ur_event_handle_t LastEvent = nullptr;
30+
ur::RefCount RefCount;
3031

3132
ur_queue_handle_t_(native_type Queue, ur_context_handle_t Ctx,
3233
ur_device_handle_t Dev, bool InOrder)
@@ -67,9 +68,4 @@ struct ur_queue_handle_t_ : ur::opencl::handle_base {
6768
}
6869
return UR_RESULT_SUCCESS;
6970
}
70-
71-
ur::RefCount &getRefCount() noexcept { return RefCount; }
72-
73-
private:
74-
ur::RefCount RefCount;
7571
};

0 commit comments

Comments
 (0)