From 172b9f96e657dda0bf3a61cb574fbbf7c28e536d Mon Sep 17 00:00:00 2001 From: Ben Sander Date: Tue, 31 Oct 2017 22:26:26 +0000 Subject: [PATCH] Add HIP_DB=warn + message if sync on dangerous event. --- hipamd/src/hip_event.cpp | 8 ++++++++ hipamd/src/hip_hcc_internal.h | 4 +++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/hipamd/src/hip_event.cpp b/hipamd/src/hip_event.cpp index d1ee37a45e..93ef63f2e3 100644 --- a/hipamd/src/hip_event.cpp +++ b/hipamd/src/hip_event.cpp @@ -191,6 +191,10 @@ hipError_t hipEventSynchronize(hipEvent_t event) { HIP_INIT_SPECIAL_API(TRACE_SYNC, event); + if (!(event->_flags & hipEventReleaseToSystem)) { + tprintf(DB_WARN, "hipEventSynchronize on event without system-scope fence ; consider creating with hipEventReleaseToSystem\n"); + } + if (event) { if (event->_state == hipEventStatusUnitialized) { return ihipLogStatus(hipErrorInvalidResourceHandle); @@ -268,6 +272,10 @@ hipError_t hipEventQuery(hipEvent_t event) { HIP_INIT_SPECIAL_API(TRACE_QUERY, event); + if (!(event->_flags & hipEventReleaseToSystem)) { + tprintf(DB_WARN, "hipEventQuery on event without system-scope fence ; consider creating with hipEventReleaseToSystem\n"); + } + if ((event->_state == hipEventStatusRecording) && !event->locked_isReady()) { return ihipLogStatus(hipErrorNotReady); } else { diff --git a/hipamd/src/hip_hcc_internal.h b/hipamd/src/hip_hcc_internal.h index 197cd35bfa..27c323887c 100644 --- a/hipamd/src/hip_hcc_internal.h +++ b/hipamd/src/hip_hcc_internal.h @@ -209,7 +209,8 @@ extern const char *API_COLOR_END; #define DB_SYNC 1 /* 0x02 - trace synchronization pieces */ #define DB_MEM 2 /* 0x04 - trace memory allocation / deallocation */ #define DB_COPY 3 /* 0x08 - trace memory copy and peer commands. . */ -#define DB_MAX_FLAG 4 +#define DB_WARN 4 /* 0x10 - warn about sub-optimal or shady behavior */ +#define DB_MAX_FLAG 5 // When adding a new debug flag, also add to the char name table below. // // @@ -226,6 +227,7 @@ static const DbName dbName [] = {KYEL, "sync"}, {KCYN, "mem"}, {KMAG, "copy"}, + {KRED, "warn"}, };