Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SYCL][UR][L0 v2] Fixes for coverity issues #17874

Open
wants to merge 5 commits into
base: sycl
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,13 @@ struct ur_command_list_manager {
ur_device_handle_t device,
v2::raii::command_list_unique_handle &&commandList,
v2::event_flags_t flags, ur_queue_t_ *queue);
ur_command_list_manager(const ur_command_list_manager &src) = delete;
ur_command_list_manager(ur_command_list_manager &&src) = default;

ur_command_list_manager &
operator=(const ur_command_list_manager &src) = delete;
ur_command_list_manager &operator=(ur_command_list_manager &&src) = default;

~ur_command_list_manager();

ur_result_t appendKernelLaunch(ur_kernel_handle_t hKernel, uint32_t workDim,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ class event_pool {
event_pool(const event_pool &) = delete;
event_pool &operator=(const event_pool &) = delete;

~event_pool() = default;

// Allocate an event from the pool. Thread safe.
ur_event_handle_t allocate();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace v2 {
event_pool_cache::event_pool_cache(ur_context_handle_t hContext,
size_t max_devices,
ProviderCreateFunc ProviderCreate)
: hContext(hContext), providerCreate(ProviderCreate) {
: hContext(hContext), providerCreate(std::move(ProviderCreate)) {
pools.resize(max_devices * (1ULL << EVENT_FLAGS_USED_BITS));
}

Expand Down
9 changes: 5 additions & 4 deletions unified-runtime/source/adapters/level_zero/v2/kernel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,11 @@ ur_result_t ur_kernel_handle_t_::release() {
void ur_kernel_handle_t_::completeInitialization() {
// Cache kernel name. Should be the same for all devices
assert(deviceKernels.size() > 0);
nonEmptyKernel =
&std::find_if(deviceKernels.begin(), deviceKernels.end(),
[](const auto &kernel) { return kernel.has_value(); })
->value();
auto nonEmptyKernelIt =
std::find_if(deviceKernels.begin(), deviceKernels.end(),
[](const auto &kernel) { return kernel.has_value(); });
assert(nonEmptyKernelIt != deviceKernels.end());
nonEmptyKernel = &nonEmptyKernelIt->value();

zeCommonProperties.Compute = [kernel = nonEmptyKernel](
common_properties_t &props) {
Expand Down
10 changes: 6 additions & 4 deletions unified-runtime/source/adapters/level_zero/v2/memory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,13 +161,15 @@ getSyncCommandListForCopy(ur_context_handle_t hContext,

static ur_result_t synchronousZeCopy(ur_context_handle_t hContext,
ur_device_handle_t hDevice, void *dst,
const void *src, size_t size) {
const void *src, size_t size) try {
auto commandList = getSyncCommandListForCopy(hContext, hDevice);

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

return UR_RESULT_SUCCESS;
} catch (...) {
return exceptionToResult(std::current_exception());
}

void *ur_discrete_buffer_handle_t::allocateOnDevice(ur_device_handle_t hDevice,
Expand Down Expand Up @@ -419,20 +421,20 @@ void *ur_mem_sub_buffer_t::getDevicePtr(
ur_device_handle_t hDevice, device_access_mode_t access, size_t offset,
size_t size, std::function<void(void *src, void *dst, size_t)> migrate) {
return hParent->getBuffer()->getDevicePtr(
hDevice, access, offset + this->offset, size, migrate);
hDevice, access, offset + this->offset, size, std::move(migrate));
}

void *ur_mem_sub_buffer_t::mapHostPtr(
ur_map_flags_t flags, size_t offset, size_t size,
std::function<void(void *src, void *dst, size_t)> migrate) {
return hParent->getBuffer()->mapHostPtr(flags, offset + this->offset, size,
migrate);
std::move(migrate));
}

void ur_mem_sub_buffer_t::unmapHostPtr(
void *pMappedPtr,
std::function<void(void *src, void *dst, size_t)> migrate) {
return hParent->getBuffer()->unmapHostPtr(pMappedPtr, migrate);
return hParent->getBuffer()->unmapHostPtr(pMappedPtr, std::move(migrate));
}

ur_shared_mutex &ur_mem_sub_buffer_t::getMutex() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -872,7 +872,7 @@ ur_result_t ur_queue_immediate_in_order_t::enqueueTimestampRecordingExp(
"ur_queue_immediate_in_order_t::enqueueTimestampRecordingExp");

auto commandListLocked = commandListManager.lock();
if (!phEvent && !*phEvent) {
if (!phEvent || !*phEvent) {
return UR_RESULT_ERROR_INVALID_NULL_HANDLE;
}
getSignalEvent(commandListLocked, phEvent,
Expand Down
Loading