Skip to content

Commit 61a8f30

Browse files
igchorKornevNikita
authored andcommitted
[SYCL][UR][L0 v2] Fixes for coverity issues (#17874)
1 parent df5d1ac commit 61a8f30

File tree

6 files changed

+21
-10
lines changed

6 files changed

+21
-10
lines changed

unified-runtime/source/adapters/level_zero/v2/command_list_manager.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,13 @@ struct ur_command_list_manager {
3737
ur_device_handle_t device,
3838
v2::raii::command_list_unique_handle &&commandList,
3939
v2::event_flags_t flags, ur_queue_t_ *queue);
40+
ur_command_list_manager(const ur_command_list_manager &src) = delete;
4041
ur_command_list_manager(ur_command_list_manager &&src) = default;
42+
43+
ur_command_list_manager &
44+
operator=(const ur_command_list_manager &src) = delete;
45+
ur_command_list_manager &operator=(ur_command_list_manager &&src) = default;
46+
4147
~ur_command_list_manager();
4248

4349
ur_result_t appendKernelLaunch(ur_kernel_handle_t hKernel, uint32_t workDim,

unified-runtime/source/adapters/level_zero/v2/event_pool.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ class event_pool {
4040
event_pool(const event_pool &) = delete;
4141
event_pool &operator=(const event_pool &) = delete;
4242

43+
~event_pool() = default;
44+
4345
// Allocate an event from the pool. Thread safe.
4446
ur_event_handle_t allocate();
4547

unified-runtime/source/adapters/level_zero/v2/event_pool_cache.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ namespace v2 {
1616
event_pool_cache::event_pool_cache(ur_context_handle_t hContext,
1717
size_t max_devices,
1818
ProviderCreateFunc ProviderCreate)
19-
: hContext(hContext), providerCreate(ProviderCreate) {
19+
: hContext(hContext), providerCreate(std::move(ProviderCreate)) {
2020
pools.resize(max_devices * (1ULL << EVENT_FLAGS_USED_BITS));
2121
}
2222

unified-runtime/source/adapters/level_zero/v2/kernel.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,10 +117,11 @@ ur_result_t ur_kernel_handle_t_::release() {
117117
void ur_kernel_handle_t_::completeInitialization() {
118118
// Cache kernel name. Should be the same for all devices
119119
assert(deviceKernels.size() > 0);
120-
nonEmptyKernel =
121-
&std::find_if(deviceKernels.begin(), deviceKernels.end(),
122-
[](const auto &kernel) { return kernel.has_value(); })
123-
->value();
120+
auto nonEmptyKernelIt =
121+
std::find_if(deviceKernels.begin(), deviceKernels.end(),
122+
[](const auto &kernel) { return kernel.has_value(); });
123+
assert(nonEmptyKernelIt != deviceKernels.end());
124+
nonEmptyKernel = &nonEmptyKernelIt->value();
124125

125126
zeCommonProperties.Compute = [kernel = nonEmptyKernel](
126127
common_properties_t &props) {

unified-runtime/source/adapters/level_zero/v2/memory.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -161,13 +161,15 @@ getSyncCommandListForCopy(ur_context_handle_t hContext,
161161

162162
static ur_result_t synchronousZeCopy(ur_context_handle_t hContext,
163163
ur_device_handle_t hDevice, void *dst,
164-
const void *src, size_t size) {
164+
const void *src, size_t size) try {
165165
auto commandList = getSyncCommandListForCopy(hContext, hDevice);
166166

167167
ZE2UR_CALL(zeCommandListAppendMemoryCopy,
168168
(commandList.get(), dst, src, size, nullptr, 0, nullptr));
169169

170170
return UR_RESULT_SUCCESS;
171+
} catch (...) {
172+
return exceptionToResult(std::current_exception());
171173
}
172174

173175
void *ur_discrete_buffer_handle_t::allocateOnDevice(ur_device_handle_t hDevice,
@@ -419,20 +421,20 @@ void *ur_mem_sub_buffer_t::getDevicePtr(
419421
ur_device_handle_t hDevice, device_access_mode_t access, size_t offset,
420422
size_t size, std::function<void(void *src, void *dst, size_t)> migrate) {
421423
return hParent->getBuffer()->getDevicePtr(
422-
hDevice, access, offset + this->offset, size, migrate);
424+
hDevice, access, offset + this->offset, size, std::move(migrate));
423425
}
424426

425427
void *ur_mem_sub_buffer_t::mapHostPtr(
426428
ur_map_flags_t flags, size_t offset, size_t size,
427429
std::function<void(void *src, void *dst, size_t)> migrate) {
428430
return hParent->getBuffer()->mapHostPtr(flags, offset + this->offset, size,
429-
migrate);
431+
std::move(migrate));
430432
}
431433

432434
void ur_mem_sub_buffer_t::unmapHostPtr(
433435
void *pMappedPtr,
434436
std::function<void(void *src, void *dst, size_t)> migrate) {
435-
return hParent->getBuffer()->unmapHostPtr(pMappedPtr, migrate);
437+
return hParent->getBuffer()->unmapHostPtr(pMappedPtr, std::move(migrate));
436438
}
437439

438440
ur_shared_mutex &ur_mem_sub_buffer_t::getMutex() {

unified-runtime/source/adapters/level_zero/v2/queue_immediate_in_order.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -870,7 +870,7 @@ ur_result_t ur_queue_immediate_in_order_t::enqueueTimestampRecordingExp(
870870
"ur_queue_immediate_in_order_t::enqueueTimestampRecordingExp");
871871

872872
auto commandListLocked = commandListManager.lock();
873-
if (!phEvent && !*phEvent) {
873+
if (!phEvent) {
874874
return UR_RESULT_ERROR_INVALID_NULL_HANDLE;
875875
}
876876
getSignalEvent(commandListLocked, phEvent,

0 commit comments

Comments
 (0)