From 9fc8ad069fbf7ba46df27dce277ccb1f5fc2e73c Mon Sep 17 00:00:00 2001 From: Alexander Batashev Date: Tue, 28 Jul 2020 16:30:50 +0300 Subject: [PATCH 1/2] [SYCL] Fix warnings from static analysis tool Signed-off-by: Alexander Batashev --- sycl/plugins/level_zero/pi_level0.cpp | 8 ++++++++ sycl/source/detail/program_impl.cpp | 2 +- sycl/source/detail/scheduler/graph_builder.cpp | 2 ++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/sycl/plugins/level_zero/pi_level0.cpp b/sycl/plugins/level_zero/pi_level0.cpp index 0fdf4e272e1d2..47042442f1c45 100644 --- a/sycl/plugins/level_zero/pi_level0.cpp +++ b/sycl/plugins/level_zero/pi_level0.cpp @@ -2258,6 +2258,8 @@ piEnqueueKernelLaunch(pi_queue Queue, pi_kernel Kernel, pi_uint32 WorkDim, ze_event_handle_t *ZeEventWaitList = _pi_event::createZeEventList(NumEventsInWaitList, EventWaitList); + if (!ZeEventWaitList) + return PI_OUT_OF_HOST_MEMORY; // Add the command to the command list ZE_CALL(zeCommandListAppendLaunchKernel( @@ -2708,6 +2710,8 @@ enqueueMemCopyHelper(pi_command_type CommandType, pi_queue Queue, void *Dst, ze_event_handle_t *ZeEventWaitList = _pi_event::createZeEventList(NumEventsInWaitList, EventWaitList); + if (!ZeEventWaitList) + return PI_OUT_OF_HOST_MEMORY; ZE_CALL(zeCommandListAppendWaitOnEvents(ZeCommandList, NumEventsInWaitList, ZeEventWaitList)); @@ -2766,6 +2770,8 @@ static pi_result enqueueMemCopyRectHelper( ze_event_handle_t *ZeEventWaitList = _pi_event::createZeEventList(NumEventsInWaitList, EventWaitList); + if (!ZeEventWaitList) + return PI_OUT_OF_HOST_MEMORY; ZE_CALL(zeCommandListAppendWaitOnEvents(ZeCommandList, NumEventsInWaitList, ZeEventWaitList)); @@ -2926,6 +2932,8 @@ enqueueMemFillHelper(pi_command_type CommandType, pi_queue Queue, void *Ptr, ze_event_handle_t *ZeEventWaitList = _pi_event::createZeEventList(NumEventsInWaitList, EventWaitList); + if (!ZeEventWaitList) + return PI_OUT_OF_HOST_MEMORY; ZE_CALL(zeCommandListAppendWaitOnEvents(ZeCommandList, NumEventsInWaitList, ZeEventWaitList)); diff --git a/sycl/source/detail/program_impl.cpp b/sycl/source/detail/program_impl.cpp index 88f092bf2d117..89ddc4f6cfb1b 100644 --- a/sycl/source/detail/program_impl.cpp +++ b/sycl/source/detail/program_impl.cpp @@ -399,7 +399,7 @@ bool program_impl::has_cl_kernel(const string_class &KernelName) const { } RT::PiKernel program_impl::get_pi_kernel(const string_class &KernelName) const { - RT::PiKernel Kernel; + RT::PiKernel Kernel = nullptr; if (is_cacheable()) { std::tie(Kernel, std::ignore) = diff --git a/sycl/source/detail/scheduler/graph_builder.cpp b/sycl/source/detail/scheduler/graph_builder.cpp index 46bfdb212f6d4..b23c41f1dda97 100644 --- a/sycl/source/detail/scheduler/graph_builder.cpp +++ b/sycl/source/detail/scheduler/graph_builder.cpp @@ -93,6 +93,8 @@ Scheduler::GraphBuilder::GraphBuilder() { } static bool markNodeAsVisited(Command *Cmd, std::vector &Visited) { + if (!Cmd) + return false; if (Cmd->MMarks.MVisited) return false; Cmd->MMarks.MVisited = true; From a6cdc0e77848bcc0ec7cf792563400d8510c53d0 Mon Sep 17 00:00:00 2001 From: Alexander Batashev Date: Tue, 28 Jul 2020 17:18:08 +0300 Subject: [PATCH 2/2] Replace check with assert Signed-off-by: Alexander Batashev --- sycl/source/detail/scheduler/graph_builder.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/sycl/source/detail/scheduler/graph_builder.cpp b/sycl/source/detail/scheduler/graph_builder.cpp index b23c41f1dda97..1532ab3da8666 100644 --- a/sycl/source/detail/scheduler/graph_builder.cpp +++ b/sycl/source/detail/scheduler/graph_builder.cpp @@ -93,8 +93,7 @@ Scheduler::GraphBuilder::GraphBuilder() { } static bool markNodeAsVisited(Command *Cmd, std::vector &Visited) { - if (!Cmd) - return false; + assert(Cmd && "Cmd can't be nullptr"); if (Cmd->MMarks.MVisited) return false; Cmd->MMarks.MVisited = true;