From 7c4a59352cd06c091b1240a89ef38d887c118afe Mon Sep 17 00:00:00 2001 From: Ewan Crawford Date: Wed, 28 Feb 2024 13:28:53 +0000 Subject: [PATCH] [HIP][CMD-BUF] HIP coverity fixes * Don't throw from constructor * Move rather than copy nodes during sync-point registration * Initalize `NextSyncPoint` --- source/adapters/hip/command_buffer.cpp | 6 +++--- source/adapters/hip/command_buffer.hpp | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/source/adapters/hip/command_buffer.cpp b/source/adapters/hip/command_buffer.cpp index 9fd3a06927..180c90d064 100644 --- a/source/adapters/hip/command_buffer.cpp +++ b/source/adapters/hip/command_buffer.cpp @@ -50,7 +50,7 @@ ur_exp_command_buffer_handle_t_::ur_exp_command_buffer_handle_t_( ur_context_handle_t hContext, ur_device_handle_t hDevice, bool IsUpdatable) : Context(hContext), Device(hDevice), IsUpdatable(IsUpdatable), HIPGraph{nullptr}, HIPGraphExec{nullptr}, - RefCountInternal{1}, RefCountExternal{1} { + RefCountInternal{1}, RefCountExternal{1}, NextSyncPoint{0} { urContextRetain(hContext); urDeviceRetain(hDevice); } @@ -65,11 +65,11 @@ ur_exp_command_buffer_handle_t_::~ur_exp_command_buffer_handle_t_() { UR_TRACE(urDeviceRelease(Device)); // Release the memory allocated to the HIPGraph - UR_CHECK_ERROR(hipGraphDestroy(HIPGraph)); + (void)hipGraphDestroy(HIPGraph); // Release the memory allocated to the HIPGraphExec if (HIPGraphExec) { - UR_CHECK_ERROR(hipGraphExecDestroy(HIPGraphExec)); + (void)hipGraphExecDestroy(HIPGraphExec); } } diff --git a/source/adapters/hip/command_buffer.hpp b/source/adapters/hip/command_buffer.hpp index f1b3e32bfb..53b648b5cd 100644 --- a/source/adapters/hip/command_buffer.hpp +++ b/source/adapters/hip/command_buffer.hpp @@ -254,8 +254,8 @@ struct ur_exp_command_buffer_handle_t_ { ~ur_exp_command_buffer_handle_t_(); void registerSyncPoint(ur_exp_command_buffer_sync_point_t SyncPoint, - std::shared_ptr HIPNode) { - SyncPoints[SyncPoint] = HIPNode; + std::shared_ptr &&HIPNode) { + SyncPoints[SyncPoint] = std::move(HIPNode); NextSyncPoint++; } @@ -269,7 +269,7 @@ struct ur_exp_command_buffer_handle_t_ { ur_exp_command_buffer_sync_point_t addSyncPoint(std::shared_ptr HIPNode) { ur_exp_command_buffer_sync_point_t SyncPoint = NextSyncPoint; - registerSyncPoint(SyncPoint, HIPNode); + registerSyncPoint(SyncPoint, std::move(HIPNode)); return SyncPoint; } uint32_t incrementInternalReferenceCount() noexcept {