From 25be4fb5327cfc16b56e2dacd2eedd4067ece9f1 Mon Sep 17 00:00:00 2001 From: Aditya Atluri Date: Thu, 25 Aug 2016 14:34:41 -0500 Subject: [PATCH] Changed how hipEvent_t is typedefed internall - Mapped hipEvent_t directly to ihipEvent_t* instead of a handle Change-Id: I5a8bcca0ef962932e0738c03eb1fc914d23022ae --- hipamd/include/hcc_detail/hip_runtime_api.h | 4 +--- hipamd/src/hip_event.cpp | 19 ++++++++++--------- hipamd/src/hip_hcc.cpp | 2 +- 3 files changed, 12 insertions(+), 13 deletions(-) diff --git a/hipamd/include/hcc_detail/hip_runtime_api.h b/hipamd/include/hcc_detail/hip_runtime_api.h index 34750fea57..0d08563fde 100644 --- a/hipamd/include/hcc_detail/hip_runtime_api.h +++ b/hipamd/include/hcc_detail/hip_runtime_api.h @@ -58,9 +58,7 @@ typedef struct ihipFunction_t *hipFunction; typedef void* hipDeviceptr; -typedef struct hipEvent_t { - struct ihipEvent_t *_handle; -} hipEvent_t; +typedef struct ihipEvent_t *hipEvent_t; /** diff --git a/hipamd/src/hip_event.cpp b/hipamd/src/hip_event.cpp index ca30c3c62b..4324583690 100644 --- a/hipamd/src/hip_event.cpp +++ b/hipamd/src/hip_event.cpp @@ -33,13 +33,14 @@ hipError_t ihipEventCreate(hipEvent_t* event, unsigned flags) // TODO - support hipEventDefault, hipEventBlockingSync, hipEventDisableTiming if (flags == 0) { - ihipEvent_t *eh = event->_handle = new ihipEvent_t(); + ihipEvent_t *eh = new ihipEvent_t(); eh->_state = hipEventStatusCreated; eh->_stream = NULL; eh->_flags = flags; eh->_timestamp = 0; eh->_copySeqId = 0; + *event = eh; } else { e = hipErrorInvalidValue; } @@ -71,7 +72,7 @@ hipError_t hipEventRecord(hipEvent_t event, hipStream_t stream) { HIP_INIT_API(event, stream); - ihipEvent_t *eh = event._handle; + ihipEvent_t *eh = event; if (eh && eh->_state != hipEventStatusUnitialized) { eh->_stream = stream; @@ -106,10 +107,10 @@ hipError_t hipEventDestroy(hipEvent_t event) { HIP_INIT_API(event); - event._handle->_state = hipEventStatusUnitialized; + event->_state = hipEventStatusUnitialized; - delete event._handle; - event._handle = NULL; + delete event; + event = NULL; // TODO - examine return additional error codes return ihipLogStatus(hipSuccess); @@ -121,7 +122,7 @@ hipError_t hipEventSynchronize(hipEvent_t event) { HIP_INIT_API(event); - ihipEvent_t *eh = event._handle; + ihipEvent_t *eh = event; if (eh) { if (eh->_state == hipEventStatusUnitialized) { @@ -150,8 +151,8 @@ hipError_t hipEventElapsedTime(float *ms, hipEvent_t start, hipEvent_t stop) { HIP_INIT_API(ms, start, stop); - ihipEvent_t *start_eh = start._handle; - ihipEvent_t *stop_eh = stop._handle; + ihipEvent_t *start_eh = start; + ihipEvent_t *stop_eh = stop; ihipSetTs(start); ihipSetTs(stop); @@ -195,7 +196,7 @@ hipError_t hipEventQuery(hipEvent_t event) { HIP_INIT_API(event); - ihipEvent_t *eh = event._handle; + ihipEvent_t *eh = event; // TODO-stream - need to read state of signal here: The event may have become ready after recording.. // TODO-HCC - use get_hsa_signal here. diff --git a/hipamd/src/hip_hcc.cpp b/hipamd/src/hip_hcc.cpp index 4508b6057a..589b9ef47e 100644 --- a/hipamd/src/hip_hcc.cpp +++ b/hipamd/src/hip_hcc.cpp @@ -1493,7 +1493,7 @@ const char *ihipErrorString(hipError_t hip_error) void ihipSetTs(hipEvent_t e) { - ihipEvent_t *eh = e._handle; + ihipEvent_t *eh = e; if (eh->_state == hipEventStatusRecorded) { // already recorded, done: return;