From 7d5bc56ab79aa9fc178f201e4648543e8b10c0b5 Mon Sep 17 00:00:00 2001 From: Sarbojit2019 <52527887+SarbojitAMD@users.noreply.github.com> Date: Mon, 18 Nov 2019 12:18:55 +0530 Subject: [PATCH] Added null check in hipEventSynchronize (#1627) * Added missing null check in hipEventSynchronize * Minor correction in the Event API description [ROCm/clr commit: 7985ad218fe947efeae49a7e5a04ea3d1d5e3f30] --- .../hipamd/include/hip/hcc_detail/hip_runtime_api.h | 4 ++-- projects/clr/hipamd/src/hip_event.cpp | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/projects/clr/hipamd/include/hip/hcc_detail/hip_runtime_api.h b/projects/clr/hipamd/include/hip/hcc_detail/hip_runtime_api.h index 4ae92f1c03..afb99da6a3 100644 --- a/projects/clr/hipamd/include/hip/hcc_detail/hip_runtime_api.h +++ b/projects/clr/hipamd/include/hip/hcc_detail/hip_runtime_api.h @@ -883,7 +883,7 @@ hipError_t hipStreamAddCallback(hipStream_t stream, hipStreamCallback_t callback * #hipEventDefault : Default flag. The event will use active synchronization and will support timing. Blocking synchronization provides lowest possible latency at the expense of dedicating a - CPU to poll on the eevent. + CPU to poll on the event. * #hipEventBlockingSync : The event will use blocking synchronization : if hipEventSynchronize is called on this event, the thread will block until the event completes. This can increase latency for the synchroniation but can result in lower power and more resources for other CPU threads. @@ -935,7 +935,7 @@ hipError_t hipEventCreate(hipEvent_t* event); * If hipEventRecord() has been previously called on this event, then this call will overwrite any * existing state in event. * - * If this function is called on a an event that is currently being recorded, results are undefined + * If this function is called on an event that is currently being recorded, results are undefined * - either outstanding recording may save state into the event, and the order is not guaranteed. * * @see hipEventCreate, hipEventCreateWithFlags, hipEventQuery, hipEventSynchronize, diff --git a/projects/clr/hipamd/src/hip_event.cpp b/projects/clr/hipamd/src/hip_event.cpp index dcab059774..3d1a366463 100644 --- a/projects/clr/hipamd/src/hip_event.cpp +++ b/projects/clr/hipamd/src/hip_event.cpp @@ -143,14 +143,14 @@ hipError_t hipEventDestroy(hipEvent_t event) { hipError_t hipEventSynchronize(hipEvent_t event) { HIP_INIT_SPECIAL_API(hipEventSynchronize, TRACE_SYNC, event); - if (!(event->_flags & hipEventReleaseToSystem)) { - tprintf(DB_WARN, + if (event){ + if (!(event->_flags & hipEventReleaseToSystem)) { + tprintf(DB_WARN, "hipEventSynchronize on event without system-scope fence ; consider creating with " "hipEventReleaseToSystem\n"); - } - auto ecd = event->locked_copyCrit(); + } + auto ecd = event->locked_copyCrit(); - if (event) { if (ecd._state == hipEventStatusUnitialized) { return ihipLogStatus(hipErrorInvalidResourceHandle); } else if (ecd._state == hipEventStatusCreated) {