Skip to content

Commit

Permalink
Starting fix on range end events
Browse files Browse the repository at this point in the history
  • Loading branch information
khuck committed Apr 18, 2022
1 parent 4fdc34e commit ed5d5ce
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/apex/cupti_trace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ typedef nvtxDomainHandle_t (*nvtxDomainCreateA_p)(const char * name);
typedef nvtxRangeId_t (*nvtxRangeStartA_p)(const char * message);
typedef nvtxRangeId_t (*nvtxRangeStartW_p)(const wchar_t * message);
typedef nvtxRangeId_t (*nvtxRangeStartEx_p)(const nvtxEventAttributes_t *eventAttrib);
typedef void (*nvtxRangeEnd_p)(nvtxRangeId_t id);
typedef nvtxRangeId_t (*nvtxDomainRangeStartEx_p)(nvtxDomainHandle_t domain, const nvtxEventAttributes_t *eventAttrib);

/* Define the wrapper for nvtxDomainCreateA */
Expand Down Expand Up @@ -221,6 +222,25 @@ NVTX_DECLSPEC nvtxRangeId_t NVTX_API nvtxRangeStartEx (const nvtxEventAttributes
return apex_nvtxRangeStartEx_wrapper(_nvtxRangeStartEx, eventAttrib);
}

/* Define the wrapper for nvtxRangeEnd */
void apex_nvtxRangeEnd_wrapper (
nvtxRangeEnd_p nvtxRangeEnd_call,
const nvtxRangeId_t id) {
nvtxRangeEnd_call(id);
/* Range start/end is too risky for OTF2 */
if (apex::apex_options::use_otf2()) { return; }
apex::stop(get_range_map()[id]);
get_range_map().erase(id);
return;
}

/* Define the interceptor for nvtxRangeEnd */
NVTX_DECLSPEC void NVTX_API nvtxRangeEnd (nvtxRangeId_t id) {
static nvtxRangeEnd_p _nvtxRangeEnd =
(nvtxRangeEnd_p)(get_system_function_handle("nvtxRangeEnd", (void*)(nvtxRangeEnd)));
return apex_nvtxRangeEnd_wrapper(_nvtxRangeEnd, id);
}

/* Define the wrapper for nvtxDomainRangeStartEx */
nvtxRangeId_t apex_nvtxDomainRangeStartEx_wrapper (
nvtxDomainRangeStartEx_p nvtxDomainRangeStartEx_call,
Expand Down Expand Up @@ -1632,6 +1652,7 @@ void apex_cupti_callback_dispatch(void *ud, CUpti_CallbackDomain domain,
APEX_UNUSED(ud);
APEX_UNUSED(id);
APEX_UNUSED(domain);
printf("Callback: %d, %d\n", domain, id);
if (!apex::thread_instance::is_worker()) { return; }
if (params == NULL) { return; }

Expand Down

0 comments on commit ed5d5ce

Please sign in to comment.