Skip to content

Commit 79f28f6

Browse files
authored
[UR][CUDA][HIP] Cleanup adapter code (#18370)
- Inline createProgram function in CUDA adapter, and catch ur result exceptions in both adapters. - Fix pattern of unnecessarily storing error code in a variable instead of just returning it. - Fix incorrect setErrorMessage uses, the adapter specific code signals that there is a specific error code and message in get last error, it doesn't make sense to use it as the code in the last error. - Remove now unrelated comment on now removed primary context extension. - Don't use `unique_ptr` when `delete` is enough.
1 parent 603feac commit 79f28f6

File tree

16 files changed

+197
-291
lines changed

16 files changed

+197
-291
lines changed

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

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,6 @@ ur_context_handle_t_::getOwningURPool(umf_memory_pool_t *UMFPool) {
3636
}
3737

3838
/// Create a UR CUDA context.
39-
///
40-
/// By default creates a scoped context and keeps the last active CUDA context
41-
/// on top of the CUDA context stack.
42-
/// With the __SYCL_PI_CONTEXT_PROPERTIES_CUDA_PRIMARY key/id and a value of
43-
/// PI_TRUE creates a primary CUDA context and activates it on the CUDA context
44-
/// stack.
45-
///
4639
UR_APIEXPORT ur_result_t UR_APICALL
4740
urContextCreate(uint32_t DeviceCount, const ur_device_handle_t *phDevices,
4841
const ur_context_properties_t * /*pProperties*/,
@@ -94,8 +87,7 @@ urContextRelease(ur_context_handle_t hContext) {
9487
return UR_RESULT_SUCCESS;
9588
}
9689
hContext->invokeExtendedDeleters();
97-
98-
std::unique_ptr<ur_context_handle_t_> Context{hContext};
90+
delete hContext;
9991

10092
return UR_RESULT_SUCCESS;
10193
}

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1216,7 +1216,6 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGet(ur_platform_handle_t hPlatform,
12161216
uint32_t NumEntries,
12171217
ur_device_handle_t *phDevices,
12181218
uint32_t *pNumDevices) {
1219-
ur_result_t Result = UR_RESULT_SUCCESS;
12201219
const bool AskingForAll = DeviceType == UR_DEVICE_TYPE_ALL;
12211220
const bool AskingForDefault = DeviceType == UR_DEVICE_TYPE_DEFAULT;
12221221
const bool AskingForGPU = DeviceType == UR_DEVICE_TYPE_GPU;
@@ -1234,13 +1233,13 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGet(ur_platform_handle_t hPlatform,
12341233
phDevices[i] = hPlatform->Devices[i].get();
12351234
}
12361235
}
1237-
1238-
return Result;
12391236
} catch (ur_result_t Err) {
12401237
return Err;
12411238
} catch (...) {
12421239
return UR_RESULT_ERROR_OUT_OF_RESOURCES;
12431240
}
1241+
1242+
return UR_RESULT_SUCCESS;
12441243
}
12451244

12461245
/// Gets the native CUDA handle of a UR device object

0 commit comments

Comments
 (0)