Skip to content

Add toggleCollectionDynamic for XPUPTI #1088

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions libkineto/src/CuptiActivityProfiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@
#include "RoctracerActivityApi.h"
#include "RoctracerLogger.h"
#endif
#ifdef HAS_XPUPTI
#include "plugin/xpupti/XpuptiActivityProfiler.h"
#endif
#include "ActivityBuffers.h"
#include "output_base.h"

Expand Down Expand Up @@ -1209,6 +1212,13 @@ void CuptiActivityProfiler::toggleCollectionDynamic(const bool enable) {
cupti_.disableActivities(derivedConfig_->profileActivityTypes());
}
#endif
#ifdef HAS_XPUPTI
for (auto& session : sessions_) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you leave a comment here explaining that you are making the assumption that all sessions will be XPUPTI since there are no downstream profilers for it? I think a TODO to determine session type is a good idea

auto xpu_session =
dynamic_cast<XpuptiActivityProfilerSession*>(session.get());
xpu_session->toggleCollectionDynamic(enable);
}
#endif
}

void CuptiActivityProfiler::startTraceInternal(
Expand Down
16 changes: 16 additions & 0 deletions libkineto/src/plugin/xpupti/XpuptiActivityProfiler.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree.
*/

#include "XpuptiActivityProfiler.h"
#include "XpuptiActivityApi.h"

Expand Down Expand Up @@ -53,6 +61,14 @@ void XpuptiActivityProfilerSession::stop() {
libkineto::timeSinceEpoch(std::chrono::high_resolution_clock::now());
}

void XpuptiActivityProfilerSession::toggleCollectionDynamic(const bool enable) {
if (enable) {
xpti_.enableXpuptiActivities(activity_types_);
} else {
xpti_.disablePtiActivities(activity_types_);
}
}

void XpuptiActivityProfilerSession::processTrace(ActivityLogger& logger) {
traceBuffer_.span = libkineto::TraceSpan(
profilerStartTs_, profilerEndTs_, "__xpu_profiler__");
Expand Down
9 changes: 9 additions & 0 deletions libkineto/src/plugin/xpupti/XpuptiActivityProfiler.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree.
*/

#pragma once

#include <mutex>
Expand All @@ -23,6 +31,7 @@ class XpuptiActivityProfilerSession

void start() override;
void stop() override;
void toggleCollectionDynamic(const bool);
std::vector<std::string> errors() override {
return errors_;
};
Expand Down
Loading