Skip to content

Commit afcee70

Browse files
committed
Use nullptr default initialization
Don't need extra flag for IsInitialized if checking if cudaGraphExec is no longer its initial value of nullptr.
1 parent 7de661f commit afcee70

File tree

4 files changed

+6
-10
lines changed

4 files changed

+6
-10
lines changed

source/adapters/cuda/command_buffer.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,8 @@ urCommandBufferReleaseExp(ur_exp_command_buffer_handle_t hCommandBuffer) {
401401

402402
UR_APIEXPORT ur_result_t UR_APICALL
403403
urCommandBufferFinalizeExp(ur_exp_command_buffer_handle_t hCommandBuffer) {
404-
UR_ASSERT(!hCommandBuffer->IsFinalized, UR_RESULT_ERROR_INVALID_OPERATION);
404+
UR_ASSERT(hCommandBuffer->CudaGraphExec == nullptr,
405+
UR_RESULT_ERROR_INVALID_OPERATION);
405406
try {
406407
const unsigned long long flags = 0;
407408
#if CUDA_VERSION >= 12000
@@ -419,7 +420,6 @@ urCommandBufferFinalizeExp(ur_exp_command_buffer_handle_t hCommandBuffer) {
419420
} catch (...) {
420421
return UR_RESULT_ERROR_UNKNOWN;
421422
}
422-
hCommandBuffer->IsFinalized = true;
423423
return UR_RESULT_SUCCESS;
424424
}
425425

source/adapters/cuda/command_buffer.hpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -352,12 +352,10 @@ struct ur_exp_command_buffer_handle_t_ {
352352
ur_device_handle_t Device;
353353
// Whether commands in the command-buffer can be updated
354354
bool IsUpdatable;
355-
// Keep track of whether command buffer is finalized
356-
bool IsFinalized = false;
357355
// Cuda Graph handle
358356
CUgraph CudaGraph;
359357
// Cuda Graph Exec handle
360-
CUgraphExec CudaGraphExec;
358+
CUgraphExec CudaGraphExec = nullptr;
361359
// Atomic variable counting the number of reference to this command_buffer
362360
// using std::atomic prevents data race when incrementing/decrementing.
363361
std::atomic_uint32_t RefCountInternal;

source/adapters/hip/command_buffer.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -306,15 +306,15 @@ urCommandBufferReleaseExp(ur_exp_command_buffer_handle_t hCommandBuffer) {
306306

307307
UR_APIEXPORT ur_result_t UR_APICALL
308308
urCommandBufferFinalizeExp(ur_exp_command_buffer_handle_t hCommandBuffer) {
309-
UR_ASSERT(!hCommandBuffer->IsFinalized, UR_RESULT_ERROR_INVALID_OPERATION);
309+
UR_ASSERT(hCommandBuffer->HIPGraphExec == nullptr,
310+
UR_RESULT_ERROR_INVALID_OPERATION);
310311
try {
311312
const unsigned long long flags = 0;
312313
UR_CHECK_ERROR(hipGraphInstantiateWithFlags(
313314
&hCommandBuffer->HIPGraphExec, hCommandBuffer->HIPGraph, flags));
314315
} catch (...) {
315316
return UR_RESULT_ERROR_UNKNOWN;
316317
}
317-
hCommandBuffer->IsFinalized = true;
318318
return UR_RESULT_SUCCESS;
319319
}
320320

source/adapters/hip/command_buffer.hpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -172,12 +172,10 @@ struct ur_exp_command_buffer_handle_t_ {
172172
ur_device_handle_t Device;
173173
// Whether commands in the command-buffer can be updated
174174
bool IsUpdatable;
175-
// Keep track of whether command buffer is finalized
176-
bool IsFinalized = false;
177175
// HIP Graph handle
178176
hipGraph_t HIPGraph;
179177
// HIP Graph Exec handle
180-
hipGraphExec_t HIPGraphExec;
178+
hipGraphExec_t HIPGraphExec = nullptr;
181179
// Atomic variable counting the number of reference to this command_buffer
182180
// using std::atomic prevents data race when incrementing/decrementing.
183181
std::atomic_uint32_t RefCountInternal;

0 commit comments

Comments
 (0)