Skip to content

Commit c11bb9c

Browse files
authored
[UR][CUDA][HIP] Remove unnecessary device retain/release (#17937)
`urDeviceRetain` and `urDeviceRelease` are no-ops, so this patch removes all uses. Uses of it in the context will be removed in #17571
1 parent 9433a80 commit c11bb9c

File tree

6 files changed

+5
-28
lines changed

6 files changed

+5
-28
lines changed

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

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,17 +61,13 @@ ur_exp_command_buffer_handle_t_::ur_exp_command_buffer_handle_t_(
6161
CudaGraph{nullptr}, CudaGraphExec{nullptr}, RefCount{1},
6262
NextSyncPoint{0} {
6363
urContextRetain(Context);
64-
urDeviceRetain(Device);
6564
}
6665

6766
/// The ur_exp_command_buffer_handle_t_ destructor releases
6867
/// all the memory objects allocated for command_buffer managment
6968
ur_exp_command_buffer_handle_t_::~ur_exp_command_buffer_handle_t_() {
7069
// Release the memory allocated to the Context stored in the command_buffer
7170
UR_CALL_NOCHECK(urContextRelease(Context));
72-
73-
// Release the device
74-
UR_CALL_NOCHECK(urDeviceRelease(Device));
7571
}
7672

7773
// This may throw so it must be called from within a try...catch

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

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1198,8 +1198,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice,
11981198

11991199
/// \return PI_SUCCESS if the function is executed successfully
12001200
/// CUDA devices are always root devices so retain always returns success.
1201-
UR_APIEXPORT ur_result_t UR_APICALL urDeviceRetain(ur_device_handle_t hDevice) {
1202-
std::ignore = hDevice;
1201+
UR_APIEXPORT ur_result_t UR_APICALL urDeviceRetain(ur_device_handle_t) {
12031202
return UR_RESULT_SUCCESS;
12041203
}
12051204

@@ -1211,9 +1210,7 @@ urDevicePartition(ur_device_handle_t, const ur_device_partition_properties_t *,
12111210

12121211
/// \return UR_RESULT_SUCCESS always since CUDA devices are always root
12131212
/// devices.
1214-
UR_APIEXPORT ur_result_t UR_APICALL
1215-
urDeviceRelease(ur_device_handle_t hDevice) {
1216-
std::ignore = hDevice;
1213+
UR_APIEXPORT ur_result_t UR_APICALL urDeviceRelease(ur_device_handle_t) {
12171214
return UR_RESULT_SUCCESS;
12181215
}
12191216

unified-runtime/source/adapters/cuda/physical_mem.hpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,9 @@ struct ur_physical_mem_handle_t_ {
3636
: RefCount(1), PhysicalMem(PhysMem), Context(Ctx), Device(Device),
3737
Size(Size), Properties(Properties) {
3838
urContextRetain(Context);
39-
urDeviceRetain(Device);
4039
}
4140

42-
~ur_physical_mem_handle_t_() {
43-
urContextRelease(Context);
44-
urDeviceRelease(Device);
45-
}
41+
~ur_physical_mem_handle_t_() { urContextRelease(Context); }
4642

4743
native_type get() const noexcept { return PhysicalMem; }
4844

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

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,9 @@ struct ur_program_handle_t_ {
5353
KernelMaxWorkGroupSizeMD{}, KernelMaxLinearWorkGroupSizeMD{},
5454
KernelReqdSubGroupSizeMD{} {
5555
urContextRetain(Context);
56-
urDeviceRetain(Device);
5756
}
5857

59-
~ur_program_handle_t_() {
60-
urContextRelease(Context);
61-
urDeviceRelease(Device);
62-
}
58+
~ur_program_handle_t_() { urContextRelease(Context); }
6359

6460
ur_result_t setMetadata(const ur_program_metadata_t *Metadata, size_t Length);
6561

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

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ ur_exp_command_buffer_handle_t_::ur_exp_command_buffer_handle_t_(
2626
: Context(hContext), Device(hDevice), IsUpdatable(IsUpdatable),
2727
HIPGraph{nullptr}, HIPGraphExec{nullptr}, RefCount{1}, NextSyncPoint{0} {
2828
urContextRetain(hContext);
29-
urDeviceRetain(hDevice);
3029
}
3130

3231
/// The ur_exp_command_buffer_handle_t_ destructor releases
@@ -35,9 +34,6 @@ ur_exp_command_buffer_handle_t_::~ur_exp_command_buffer_handle_t_() {
3534
// Release the memory allocated to the Context stored in the command_buffer
3635
UR_CALL_NOCHECK(urContextRelease(Context));
3736

38-
// Release the device
39-
UR_CALL_NOCHECK(urDeviceRelease(Device));
40-
4137
// Release the memory allocated to the HIPGraph
4238
(void)hipGraphDestroy(HIPGraph);
4339

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

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,9 @@ struct ur_program_handle_t_ {
5252
Context{Ctxt}, Device{Device}, KernelReqdWorkGroupSizeMD{},
5353
KernelReqdSubGroupSizeMD{} {
5454
urContextRetain(Context);
55-
urDeviceRetain(Device);
5655
}
5756

58-
~ur_program_handle_t_() {
59-
urContextRelease(Context);
60-
urDeviceRelease(Device);
61-
}
57+
~ur_program_handle_t_() { urContextRelease(Context); }
6258

6359
ur_result_t setMetadata(const ur_program_metadata_t *Metadata, size_t Length);
6460

0 commit comments

Comments
 (0)