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

Fix command_buffer coverity issues #2379

Open
wants to merge 1 commit into
base: main
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
29 changes: 15 additions & 14 deletions source/adapters/cuda/command_buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ ur_result_t ur_exp_command_buffer_handle_t_::addWaitNodes(
}
// Set DepsLists as an output parameter for communicating the list of wait
// nodes created.
DepsList = WaitNodes;
DepsList = std::move(WaitNodes);
return UR_RESULT_SUCCESS;
}

Expand All @@ -115,7 +115,7 @@ kernel_command_handle::kernel_command_handle(
const size_t *GlobalWorkOffsetPtr, const size_t *GlobalWorkSizePtr,
const size_t *LocalWorkSizePtr, uint32_t NumKernelAlternatives,
ur_kernel_handle_t *KernelAlternatives, CUgraphNode SignalNode,
std::vector<CUgraphNode> WaitNodes)
const std::vector<CUgraphNode> &WaitNodes)
: ur_exp_command_buffer_command_handle_t_(CommandBuffer, Node, SignalNode,
WaitNodes),
Kernel(Kernel), Params(Params), WorkDim(WorkDim) {
Expand Down Expand Up @@ -146,7 +146,7 @@ kernel_command_handle::kernel_command_handle(
ur_exp_command_buffer_command_handle_t_::
ur_exp_command_buffer_command_handle_t_(
ur_exp_command_buffer_handle_t CommandBuffer, CUgraphNode Node,
CUgraphNode SignalNode, std::vector<CUgraphNode> WaitNodes)
CUgraphNode SignalNode, const std::vector<CUgraphNode> &WaitNodes)
: CommandBuffer(CommandBuffer), Node(Node), SignalNode(SignalNode),
WaitNodes(WaitNodes), RefCountInternal(1), RefCountExternal(1) {
CommandBuffer->incrementInternalReferenceCount();
Expand Down Expand Up @@ -339,7 +339,7 @@ static ur_result_t enqueueCommandBufferFillHelper(
}

std::vector<CUgraphNode> WaitNodes =
NumEventsInWaitList ? DepsList : std::vector<CUgraphNode>();
NumEventsInWaitList ? std::move(DepsList) : std::vector<CUgraphNode>();
auto NewCommand = new T(CommandBuffer, GraphNode, SignalNode, WaitNodes);
CommandBuffer->CommandHandles.push_back(NewCommand);

Expand Down Expand Up @@ -540,7 +540,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urCommandBufferAppendKernelLaunchExp(
}

std::vector<CUgraphNode> WaitNodes =
numEventsInWaitList ? DepsList : std::vector<CUgraphNode>();
numEventsInWaitList ? std::move(DepsList) : std::vector<CUgraphNode>();
auto NewCommand = new kernel_command_handle(
hCommandBuffer, hKernel, GraphNode, NodeParams, workDim,
pGlobalWorkOffset, pGlobalWorkSize, pLocalWorkSize,
Expand Down Expand Up @@ -598,7 +598,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urCommandBufferAppendUSMMemcpyExp(
}

std::vector<CUgraphNode> WaitNodes =
numEventsInWaitList ? DepsList : std::vector<CUgraphNode>();
numEventsInWaitList ? std::move(DepsList) : std::vector<CUgraphNode>();
auto NewCommand = new usm_memcpy_command_handle(hCommandBuffer, GraphNode,
SignalNode, WaitNodes);
hCommandBuffer->CommandHandles.push_back(NewCommand);
Expand Down Expand Up @@ -666,9 +666,10 @@ UR_APIEXPORT ur_result_t UR_APICALL urCommandBufferAppendMemBufferCopyExp(
}

std::vector<CUgraphNode> WaitNodes =
numEventsInWaitList ? DepsList : std::vector<CUgraphNode>();
numEventsInWaitList ? std::move(DepsList) : std::vector<CUgraphNode>();
auto NewCommand = new buffer_copy_command_handle(hCommandBuffer, GraphNode,
SignalNode, WaitNodes);
hCommandBuffer->CommandHandles.push_back(NewCommand);

if (phCommand) {
NewCommand->incrementInternalReferenceCount();
Expand Down Expand Up @@ -730,7 +731,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urCommandBufferAppendMemBufferCopyRectExp(
}

std::vector<CUgraphNode> WaitNodes =
numEventsInWaitList ? DepsList : std::vector<CUgraphNode>();
numEventsInWaitList ? std::move(DepsList) : std::vector<CUgraphNode>();
auto NewCommand = new buffer_copy_rect_command_handle(
hCommandBuffer, GraphNode, SignalNode, WaitNodes);
hCommandBuffer->CommandHandles.push_back(NewCommand);
Expand Down Expand Up @@ -791,7 +792,7 @@ ur_result_t UR_APICALL urCommandBufferAppendMemBufferWriteExp(
}

std::vector<CUgraphNode> WaitNodes =
numEventsInWaitList ? DepsList : std::vector<CUgraphNode>();
numEventsInWaitList ? std::move(DepsList) : std::vector<CUgraphNode>();
auto NewCommand = new buffer_write_command_handle(hCommandBuffer, GraphNode,
SignalNode, WaitNodes);
hCommandBuffer->CommandHandles.push_back(NewCommand);
Expand Down Expand Up @@ -851,7 +852,7 @@ ur_result_t UR_APICALL urCommandBufferAppendMemBufferReadExp(
}

std::vector<CUgraphNode> WaitNodes =
numEventsInWaitList ? DepsList : std::vector<CUgraphNode>();
numEventsInWaitList ? std::move(DepsList) : std::vector<CUgraphNode>();
auto NewCommand = new buffer_read_command_handle(hCommandBuffer, GraphNode,
SignalNode, WaitNodes);
hCommandBuffer->CommandHandles.push_back(NewCommand);
Expand Down Expand Up @@ -916,7 +917,7 @@ ur_result_t UR_APICALL urCommandBufferAppendMemBufferWriteRectExp(
}

std::vector<CUgraphNode> WaitNodes =
numEventsInWaitList ? DepsList : std::vector<CUgraphNode>();
numEventsInWaitList ? std::move(DepsList) : std::vector<CUgraphNode>();
auto NewCommand = new buffer_write_rect_command_handle(
hCommandBuffer, GraphNode, SignalNode, WaitNodes);
hCommandBuffer->CommandHandles.push_back(NewCommand);
Expand Down Expand Up @@ -981,7 +982,7 @@ ur_result_t UR_APICALL urCommandBufferAppendMemBufferReadRectExp(
}

std::vector<CUgraphNode> WaitNodes =
numEventsInWaitList ? DepsList : std::vector<CUgraphNode>();
numEventsInWaitList ? std::move(DepsList) : std::vector<CUgraphNode>();
auto NewCommand = new buffer_read_rect_command_handle(
hCommandBuffer, GraphNode, SignalNode, WaitNodes);
hCommandBuffer->CommandHandles.push_back(NewCommand);
Expand Down Expand Up @@ -1037,7 +1038,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urCommandBufferAppendUSMPrefetchExp(
}

std::vector<CUgraphNode> WaitNodes =
numEventsInWaitList ? DepsList : std::vector<CUgraphNode>();
numEventsInWaitList ? std::move(DepsList) : std::vector<CUgraphNode>();
auto NewCommand = new usm_prefetch_command_handle(hCommandBuffer, GraphNode,
SignalNode, WaitNodes);
hCommandBuffer->CommandHandles.push_back(NewCommand);
Expand Down Expand Up @@ -1093,7 +1094,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urCommandBufferAppendUSMAdviseExp(
}

std::vector<CUgraphNode> WaitNodes =
numEventsInWaitList ? DepsList : std::vector<CUgraphNode>();
numEventsInWaitList ? std::move(DepsList) : std::vector<CUgraphNode>();
auto NewCommand = new usm_advise_command_handle(hCommandBuffer, GraphNode,
SignalNode, WaitNodes);
hCommandBuffer->CommandHandles.push_back(NewCommand);
Expand Down
26 changes: 13 additions & 13 deletions source/adapters/cuda/command_buffer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ enum class CommandType {
struct ur_exp_command_buffer_command_handle_t_ {
ur_exp_command_buffer_command_handle_t_(
ur_exp_command_buffer_handle_t CommandBuffer, CUgraphNode Node,
CUgraphNode SignalNode, std::vector<CUgraphNode> WaitNodes);
CUgraphNode SignalNode, const std::vector<CUgraphNode> &WaitNodes);

virtual ~ur_exp_command_buffer_command_handle_t_() {}

Expand Down Expand Up @@ -102,7 +102,7 @@ struct kernel_command_handle : ur_exp_command_buffer_command_handle_t_ {
const size_t *GlobalWorkOffsetPtr, const size_t *GlobalWorkSizePtr,
const size_t *LocalWorkSizePtr, uint32_t NumKernelAlternatives,
ur_kernel_handle_t *KernelAlternatives, CUgraphNode SignalNode,
std::vector<CUgraphNode> WaitNodes);
const std::vector<CUgraphNode> &WaitNodes);

CommandType getCommandType() const noexcept override {
return CommandType::Kernel;
Expand Down Expand Up @@ -161,7 +161,7 @@ struct kernel_command_handle : ur_exp_command_buffer_command_handle_t_ {
struct usm_memcpy_command_handle : ur_exp_command_buffer_command_handle_t_ {
usm_memcpy_command_handle(ur_exp_command_buffer_handle_t CommandBuffer,
CUgraphNode Node, CUgraphNode SignalNode,
std::vector<CUgraphNode> WaitNodes)
const std::vector<CUgraphNode> &WaitNodes)
: ur_exp_command_buffer_command_handle_t_(CommandBuffer, Node, SignalNode,
WaitNodes) {}
CommandType getCommandType() const noexcept override {
Expand All @@ -172,7 +172,7 @@ struct usm_memcpy_command_handle : ur_exp_command_buffer_command_handle_t_ {
struct usm_fill_command_handle : ur_exp_command_buffer_command_handle_t_ {
usm_fill_command_handle(ur_exp_command_buffer_handle_t CommandBuffer,
CUgraphNode Node, CUgraphNode SignalNode,
std::vector<CUgraphNode> WaitNodes)
const std::vector<CUgraphNode> &WaitNodes)
: ur_exp_command_buffer_command_handle_t_(CommandBuffer, Node, SignalNode,
WaitNodes) {}
CommandType getCommandType() const noexcept override {
Expand All @@ -183,7 +183,7 @@ struct usm_fill_command_handle : ur_exp_command_buffer_command_handle_t_ {
struct buffer_copy_command_handle : ur_exp_command_buffer_command_handle_t_ {
buffer_copy_command_handle(ur_exp_command_buffer_handle_t CommandBuffer,
CUgraphNode Node, CUgraphNode SignalNode,
std::vector<CUgraphNode> WaitNodes)
const std::vector<CUgraphNode> &WaitNodes)
: ur_exp_command_buffer_command_handle_t_(CommandBuffer, Node, SignalNode,
WaitNodes) {}
CommandType getCommandType() const noexcept override {
Expand All @@ -195,7 +195,7 @@ struct buffer_copy_rect_command_handle
: ur_exp_command_buffer_command_handle_t_ {
buffer_copy_rect_command_handle(ur_exp_command_buffer_handle_t CommandBuffer,
CUgraphNode Node, CUgraphNode SignalNode,
std::vector<CUgraphNode> WaitNodes)
const std::vector<CUgraphNode> &WaitNodes)
: ur_exp_command_buffer_command_handle_t_(CommandBuffer, Node, SignalNode,
WaitNodes) {}
CommandType getCommandType() const noexcept override {
Expand All @@ -206,7 +206,7 @@ struct buffer_copy_rect_command_handle
struct buffer_read_command_handle : ur_exp_command_buffer_command_handle_t_ {
buffer_read_command_handle(ur_exp_command_buffer_handle_t CommandBuffer,
CUgraphNode Node, CUgraphNode SignalNode,
std::vector<CUgraphNode> WaitNodes)
const std::vector<CUgraphNode> &WaitNodes)
: ur_exp_command_buffer_command_handle_t_(CommandBuffer, Node, SignalNode,
WaitNodes) {}
CommandType getCommandType() const noexcept override {
Expand All @@ -218,7 +218,7 @@ struct buffer_read_rect_command_handle
: ur_exp_command_buffer_command_handle_t_ {
buffer_read_rect_command_handle(ur_exp_command_buffer_handle_t CommandBuffer,
CUgraphNode Node, CUgraphNode SignalNode,
std::vector<CUgraphNode> WaitNodes)
const std::vector<CUgraphNode> &WaitNodes)
: ur_exp_command_buffer_command_handle_t_(CommandBuffer, Node, SignalNode,
WaitNodes) {}
CommandType getCommandType() const noexcept override {
Expand All @@ -229,7 +229,7 @@ struct buffer_read_rect_command_handle
struct buffer_write_command_handle : ur_exp_command_buffer_command_handle_t_ {
buffer_write_command_handle(ur_exp_command_buffer_handle_t CommandBuffer,
CUgraphNode Node, CUgraphNode SignalNode,
std::vector<CUgraphNode> WaitNodes)
const std::vector<CUgraphNode> &WaitNodes)
: ur_exp_command_buffer_command_handle_t_(CommandBuffer, Node, SignalNode,
WaitNodes) {}
CommandType getCommandType() const noexcept override {
Expand All @@ -241,7 +241,7 @@ struct buffer_write_rect_command_handle
: ur_exp_command_buffer_command_handle_t_ {
buffer_write_rect_command_handle(ur_exp_command_buffer_handle_t CommandBuffer,
CUgraphNode Node, CUgraphNode SignalNode,
std::vector<CUgraphNode> WaitNodes)
const std::vector<CUgraphNode> &WaitNodes)
: ur_exp_command_buffer_command_handle_t_(CommandBuffer, Node, SignalNode,
WaitNodes) {}
CommandType getCommandType() const noexcept override {
Expand All @@ -252,7 +252,7 @@ struct buffer_write_rect_command_handle
struct buffer_fill_command_handle : ur_exp_command_buffer_command_handle_t_ {
buffer_fill_command_handle(ur_exp_command_buffer_handle_t CommandBuffer,
CUgraphNode Node, CUgraphNode SignalNode,
std::vector<CUgraphNode> WaitNodes)
const std::vector<CUgraphNode> &WaitNodes)
: ur_exp_command_buffer_command_handle_t_(CommandBuffer, Node, SignalNode,
WaitNodes) {}
CommandType getCommandType() const noexcept override {
Expand All @@ -263,7 +263,7 @@ struct buffer_fill_command_handle : ur_exp_command_buffer_command_handle_t_ {
struct usm_prefetch_command_handle : ur_exp_command_buffer_command_handle_t_ {
usm_prefetch_command_handle(ur_exp_command_buffer_handle_t CommandBuffer,
CUgraphNode Node, CUgraphNode SignalNode,
std::vector<CUgraphNode> WaitNodes)
const std::vector<CUgraphNode> &WaitNodes)
: ur_exp_command_buffer_command_handle_t_(CommandBuffer, Node, SignalNode,
WaitNodes) {}
CommandType getCommandType() const noexcept override {
Expand All @@ -274,7 +274,7 @@ struct usm_prefetch_command_handle : ur_exp_command_buffer_command_handle_t_ {
struct usm_advise_command_handle : ur_exp_command_buffer_command_handle_t_ {
usm_advise_command_handle(ur_exp_command_buffer_handle_t CommandBuffer,
CUgraphNode Node, CUgraphNode SignalNode,
std::vector<CUgraphNode> WaitNodes)
const std::vector<CUgraphNode> &WaitNodes)
: ur_exp_command_buffer_command_handle_t_(CommandBuffer, Node, SignalNode,
WaitNodes) {}
CommandType getCommandType() const noexcept override {
Expand Down
Loading