Skip to content

Commit

Permalink
[HIP][CMD-BUF] HIP coverity fixes
Browse files Browse the repository at this point in the history
* Don't throw from constructor
* Move rather than copy nodes during sync-point registration
* Initalize `NextSyncPoint`
  • Loading branch information
EwanC committed Mar 4, 2024
1 parent 273ac6b commit be622e7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions source/adapters/hip/command_buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -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);
}
}

Expand Down
6 changes: 3 additions & 3 deletions source/adapters/hip/command_buffer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<hipGraphNode_t> HIPNode) {
SyncPoints[SyncPoint] = HIPNode;
std::shared_ptr<hipGraphNode_t> &&HIPNode) {
SyncPoints[SyncPoint] = std::move(HIPNode);
NextSyncPoint++;
}

Expand All @@ -269,7 +269,7 @@ struct ur_exp_command_buffer_handle_t_ {
ur_exp_command_buffer_sync_point_t
addSyncPoint(std::shared_ptr<hipGraphNode_t> HIPNode) {
ur_exp_command_buffer_sync_point_t SyncPoint = NextSyncPoint;
registerSyncPoint(SyncPoint, HIPNode);
registerSyncPoint(SyncPoint, std::move(HIPNode));
return SyncPoint;
}
uint32_t incrementInternalReferenceCount() noexcept {
Expand Down

0 comments on commit be622e7

Please sign in to comment.