From 2f7ce6f5475bba4e630e4d43504b8c2d5bd390da Mon Sep 17 00:00:00 2001 From: Shivam Raikundalia Date: Fri, 13 Sep 2024 12:17:33 -0700 Subject: [PATCH] Extend CPU User Annotations to End of Profile (#986) Summary: Pull Request resolved: https://github.com/pytorch/kineto/pull/986 If a CPU User Annotation doesn't end by the time the profile ends, the annotation is marked as a 0-length event. This can be annoying to look at because it seems like profiler just never got the annotation event when it did. Lets set the end time to the end of profiling. Reviewed By: aaronenyeshi Differential Revision: D62604717 fbshipit-source-id: 34cb06b87c3c369601e1e6df859f61377b8198f6 --- libkineto/src/CuptiActivityProfiler.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libkineto/src/CuptiActivityProfiler.cpp b/libkineto/src/CuptiActivityProfiler.cpp index 286d5b359..e02c325c1 100644 --- a/libkineto/src/CuptiActivityProfiler.cpp +++ b/libkineto/src/CuptiActivityProfiler.cpp @@ -397,6 +397,9 @@ void CuptiActivityProfiler::processCpuTrace( const std::unique_ptr>::value, "handleActivity is unsafe and relies on the caller to maintain not " "only lifetime but also address stability."); + if (act->type() == ActivityType::USER_ANNOTATION && act->duration()<=0){ + act->endTime = captureWindowEndTime_; + } logger.handleActivity(*act); } clientActivityTraceMap_[act->correlationId()] = &span_pair;