Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
109 commits
Select commit Hold shift + click to select a range
52c714a
scope profiler squashed
moksiuc Oct 31, 2025
0cbe479
Type fix
moksiuc Nov 13, 2025
7c98f84
Merge branch 'refs/heads/main' into moksiuci_6674_scope_profiler
moksiuc Nov 17, 2025
8438227
Fixes
moksiuc Nov 17, 2025
fd2a6e1
Code review fixes
moksiuc Nov 18, 2025
88082d5
Fix clang build on PT level
moksiuc Nov 18, 2025
04f305c
Fix clang build on PT level 2nd approach
moksiuc Nov 18, 2025
dbc709f
lintrunner
moksiuc Nov 19, 2025
ad4b1dd
Improve json for presentation in perfetto
moksiuc Nov 20, 2025
e050a30
Merge branch 'refs/heads/main' into moksiuci_6674_scope_profiler
moksiuc Nov 21, 2025
37eafea
Fix gtest after json update
moksiuc Nov 21, 2025
a266b04
Put correct oneapi version in error msg
moksiuc Nov 21, 2025
4a70122
Fix correct PTI and OneApi version
moksiuc Nov 24, 2025
535b19e
lint
sraikund16 Dec 15, 2025
b639a8c
Merge branch 'refs/heads/main' into moksiuci_6674_scope_profiler
moksiuc Dec 17, 2025
e85fd26
Fix merge error
moksiuc Dec 17, 2025
115ae6c
Merge branch 'refs/heads/main' into moksiuci_6674_scope_profiler
moksiuc Dec 18, 2025
02b8684
Move device gathering to enableScopeProfiler
moksiuc Dec 18, 2025
371c860
lint
sraikund16 Dec 16, 2025
9e3f9fd
Merge branch 'refs/heads/main' into moksiuci_6674_scope_profiler
moksiuc Dec 19, 2025
0d46ae9
Resolve exception from desctuctor
moksiuc Dec 19, 2025
906085b
Merge branch 'refs/heads/main' into moksiuci_6674_scope_profiler
moksiuc Dec 22, 2025
898ce26
Fix Win build: error C2039: 'back_inserter': is not a member of 'std'
moksiuc Dec 22, 2025
a014058
Update min PTI version error msg
moksiuc Dec 23, 2025
3fe5339
Remove unnecesary includes
moksiuc Dec 23, 2025
75cd8f4
Merge branch 'refs/heads/main' into moksiuci_6674_scope_profiler
moksiuc Jan 15, 2026
b2c9521
Avoid adding getMetadata method to the interface
moksiuc Jan 15, 2026
d5c79dd
Merge branch 'refs/heads/main' into moksiuci_6674_scope_profiler
moksiuc Jan 20, 2026
0ebfe7b
Split classes to avoid excessive #ifdef macro usage
moksiuc Jan 16, 2026
aeec1ca
Merge branch 'refs/heads/main' into moksiuci_6674_scope_profiler
moksiuc Feb 2, 2026
2bfb1c0
resolve merge commit issues
moksiuc Feb 2, 2026
703ce04
Merge branch 'refs/heads/main' into moksiuci_6674_scope_profiler
moksiuc Feb 3, 2026
830cc33
Fix win build
moksiuc Feb 3, 2026
1b1a031
Fix win build
moksiuc Feb 3, 2026
d04260a
Revert conflicting files
moksiuc Feb 13, 2026
156a7a7
Merge branch 'refs/heads/main' into moksiuci_6674_scope_profiler
moksiuc Feb 13, 2026
6be856a
Rename files 0->V2, V1->0
moksiuc Feb 13, 2026
d519f89
Rename 0->V2, V1->0 inside files
moksiuc Feb 13, 2026
05330ab
Merge branch 'refs/heads/main' into moksiuci_6674_scope_profiler
moksiuc Feb 27, 2026
613de06
Merge branch 'refs/heads/main' into moksiuci_6674_scope_profiler
moksiuc Mar 3, 2026
332c15a
Resolve merge conflict
moksiuc Mar 3, 2026
35aeeb0
Merge branch 'refs/heads/main' into moksiuci_6674_scope_profiler
moksiuc Mar 6, 2026
2748bcc
Apply review comments
moksiuc Mar 6, 2026
52bb30a
unformat
moksiuc Mar 6, 2026
749ede2
Revert "unformat"
moksiuc Mar 9, 2026
8af4584
Apply review comments - SELECT_VERSION macro
moksiuc Mar 9, 2026
7b7bea9
unformat
moksiuc Mar 6, 2026
acda410
Revert "unformat"
moksiuc Mar 10, 2026
48a1ea9
Merge branch 'refs/heads/main' into moksiuci_6674_scope_profiler
moksiuc Mar 10, 2026
fa11b87
No ApiT type alias
moksiuc Mar 10, 2026
71d22cd
unformat
moksiuc Mar 10, 2026
d7b330f
unfix compilation errors
moksiuc Mar 10, 2026
493b565
Revert "unfix compilation errors"
moksiuc Mar 11, 2026
a139c29
Revert "unformat"
moksiuc Mar 11, 2026
910eb4c
Merge branch 'refs/heads/main' into moksiuci_6674_scope_profiler
moksiuc Mar 11, 2026
2bfab82
Apply review comments
moksiuc Mar 11, 2026
e2b0bf7
Reapply "unformat"
moksiuc Mar 11, 2026
86d3759
Reapply "unfix compilation errors"
moksiuc Mar 11, 2026
446f253
Revert "unfix compilation errors"
moksiuc Mar 13, 2026
da9b441
Revert "unformat"
moksiuc Mar 13, 2026
4c850e7
Merge branch 'refs/heads/main' into moksiuci_6674_scope_profiler
moksiuc Mar 13, 2026
827141d
Clean up Api singleton usage
moksiuc Mar 13, 2026
f420f82
Reapply "unformat"
moksiuc Mar 13, 2026
fcd3223
Reapply "unfix compilation errors"
moksiuc Mar 13, 2026
3ae459c
Revert "unfix compilation errors"
moksiuc Mar 16, 2026
6e0717a
Revert "unformat"
moksiuc Mar 16, 2026
c271025
Merge branch 'refs/heads/main' into moksiuci_6674_scope_profiler
moksiuc Mar 16, 2026
ee0a469
Separate Api and ApiV2 classes and their singletons
moksiuc Mar 16, 2026
1f195d4
Reapply "unformat"
moksiuc Mar 16, 2026
c2f9aed
Reapply "unfix compilation errors"
moksiuc Mar 16, 2026
4483c75
Revert "Reapply "unfix compilation errors""
moksiuc Mar 18, 2026
dc6c1f0
Revert "Reapply "unformat""
moksiuc Mar 18, 2026
9923983
Merge branch 'refs/heads/main' into moksiuci_6674_scope_profiler
moksiuc Mar 18, 2026
b76c500
Rename XpuptiActivityApiV2 to XpuptiScopeProfilerApi
moksiuc Mar 18, 2026
d38f49f
Reapply "unformat"
moksiuc Mar 18, 2026
481ea86
Reapply "unfix compilation errors"
moksiuc Mar 18, 2026
1e02e75
Revert "unfix compilation errors"
moksiuc Mar 18, 2026
267b4c0
Revert "unformat"
moksiuc Mar 18, 2026
fc4417b
Merge branch 'refs/heads/main' into moksiuci_6674_scope_profiler
moksiuc Mar 18, 2026
eb6495a
Fix merge conflict
moksiuc Mar 18, 2026
75cdaa0
Reapply "unformat"
moksiuc Mar 18, 2026
d2d99de
Reapply "unfix compilation errors"
moksiuc Mar 18, 2026
2b8f065
Revert "unfix compilation errors"
moksiuc Mar 19, 2026
f87ef7a
Revert "unformat"
moksiuc Mar 19, 2026
99494fe
Merge branch 'refs/heads/main' into moksiuci_6674_scope_profiler
moksiuc Mar 19, 2026
6ce6652
Reapply "unformat"
moksiuc Mar 19, 2026
f55b81c
Revert "unformat"
moksiuc Mar 20, 2026
6c996e6
Merge branch 'refs/heads/main' into moksiuci_6674_scope_profiler
moksiuc Mar 20, 2026
96dc87e
Make ApiV2 a member of SessionV2 instead singleton
moksiuc Mar 20, 2026
4943d72
Reapply "unformat"
moksiuc Mar 20, 2026
2a594f0
Revert "unformat"
moksiuc Mar 24, 2026
7291dd7
Merge branch 'refs/heads/main' into moksiuci_6674_scope_profiler
moksiuc Mar 24, 2026
379d077
format
moksiuc Mar 24, 2026
2fe719a
Reapply "unformat"
moksiuc Mar 24, 2026
60751c0
Revert "unformat"
moksiuc Mar 27, 2026
82f2c9d
Merge branch 'refs/heads/main' into moksiuci_6674_scope_profiler
moksiuc Mar 27, 2026
d4bdc85
address review comments
moksiuc Mar 27, 2026
bda80d4
Reapply "unformat"
moksiuc Mar 27, 2026
8d9b899
Revert "unformat"
moksiuc Mar 30, 2026
400805c
Merge branch 'refs/heads/main' into moksiuci_6674_scope_profiler
moksiuc Mar 30, 2026
a312ef6
Rename V2 -> Scope according to review comments
moksiuc Mar 30, 2026
d0a82c1
Reapply "unformat"
moksiuc Mar 30, 2026
5230042
Revert "Reapply "unformat""
moksiuc Apr 9, 2026
dfbd801
Merge branch 'refs/heads/main' into moksiuci_6674_scope_profiler
moksiuc Apr 9, 2026
ef7102f
Align to new kineto code in output_json.cpp
moksiuc Apr 9, 2026
f329732
Reapply "unformat"
moksiuc Apr 9, 2026
3b2cb5a
Revert "unformat"
moksiuc Apr 16, 2026
c27b580
Merge branch 'refs/heads/main' into moksiuci_6674_scope_profiler
moksiuc Apr 16, 2026
840675e
Reapply "unformat"
moksiuc Apr 16, 2026
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
5 changes: 4 additions & 1 deletion libkineto/include/ActivityType.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ enum class ActivityType {
PRIVATEUSE1_RUNTIME = 24, // host side privateUse1 runtime events
PRIVATEUSE1_DRIVER = 25, // host side privateUse1 driver events

ENUM_COUNT = 26, // This is to add buffer and not used for any profiling logic. Add
XPU_SCOPE_PROFILER = 26, // XPUPTI Profiler scope for performance metrics

ENUM_COUNT = 27, // This is to add buffer and not used for any profiling logic. Add
// your new type before it.
OPTIONAL_ACTIVITY_TYPE_START = GLOW_RUNTIME,
};
Expand Down Expand Up @@ -94,6 +96,7 @@ inline constexpr std::array<_ActivityTypeName, activityTypeCount + 1> _activityT
{"collective_comm", ActivityType::COLLECTIVE_COMM},
{"privateuse1_runtime", ActivityType::PRIVATEUSE1_RUNTIME},
{"privateuse1_driver", ActivityType::PRIVATEUSE1_DRIVER},
{"xpu_scope_profiler", ActivityType::XPU_SCOPE_PROFILER},
{"ENUM_COUNT", ActivityType::ENUM_COUNT},
}};

Expand Down
3 changes: 3 additions & 0 deletions libkineto/libkineto_defs.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,10 @@ def get_libkineto_xpupti_srcs(with_api = True):
"src/plugin/xpupti/XpuptiActivityProfiler.cpp",
"src/plugin/xpupti/XpuptiActivityProfilerSession.cpp",
"src/plugin/xpupti/XpuptiProfilerMacros.cpp",
"src/plugin/xpupti/XpuptiScopeProfilerApi.cpp",
"src/plugin/xpupti/XpuptiScopeProfilerConfig.cpp",
"src/plugin/xpupti/XpuptiScopeProfilerHandlers.cpp",
"src/plugin/xpupti/XpuptiScopeProfilerSession.cpp",
] + (get_libkineto_cpu_only_srcs(with_api))

def get_libkineto_aiupti_srcs(with_api = True):
Expand Down
10 changes: 7 additions & 3 deletions libkineto/src/output_json.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -760,9 +760,13 @@ void ChromeTraceLogger::handleActivity(const libkineto::ITraceActivity& op) {
return;
}

if (op.type() == ActivityType::MTIA_COUNTERS) {
handleCounterEvent(op);
return;
switch (op.type()) {
case ActivityType::MTIA_COUNTERS:
case ActivityType::XPU_SCOPE_PROFILER:
handleCounterEvent(op);
return;
default:
break;
}

int64_t ts = op.timestamp();
Expand Down
11 changes: 11 additions & 0 deletions libkineto/src/plugin/xpupti/XpuptiActivityApi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,17 @@ void XpuptiActivityApi::enableXpuptiActivities(
XPUPTI_CALL(ptiViewEnable(PTI_VIEW_DRIVER_API));
break;

case ActivityType::XPU_SCOPE_PROFILER:
#if PTI_VERSION_AT_LEAST(0, 15)
Comment thread
moksiuc marked this conversation as resolved.
// This case is handled in constructor of
// XpuptiScopeProfilerSession
#else
throw std::runtime_error(
Comment thread
moksiuc marked this conversation as resolved.
"Intel® PTI version required to use scope profiler is at least 0.15 "
"(available with Intel® oneAPI in version at least 2025.3.1).");
#endif
break;

case ActivityType::OVERHEAD:
XPUPTI_CALL(ptiViewEnable(PTI_VIEW_COLLECTION_OVERHEAD));
break;
Expand Down
8 changes: 8 additions & 0 deletions libkineto/src/plugin/xpupti/XpuptiActivityHandlers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,14 @@ void XpuptiActivityProfilerSession::handleRuntimeKernelMemcpyMemsetActivities(
trace_activity->resource = activity->_sycl_queue_id;
trace_activity->flow.start = 0;

if constexpr (handleKernelActivities) {
kernelActivities_[activity->_kernel_id].emplace(
trace_activity->startTime,
trace_activity->endTime,
trace_activity->device,
trace_activity->resource);
}

addResouceInfo(trace_activity->device, trace_activity->resource);
}

Expand Down
9 changes: 7 additions & 2 deletions libkineto/src/plugin/xpupti/XpuptiActivityProfiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
*/

#include "XpuptiActivityProfiler.h"
#include "XpuptiActivityApi.h"
#include "XpuptiActivityProfilerSession.h"
#include "XpuptiScopeProfilerApi.h"
#include "XpuptiScopeProfilerSession.h"

#include <fmt/ranges.h>
#include <sycl/sycl.hpp>
Expand Down Expand Up @@ -66,8 +66,13 @@ std::unique_ptr<libkineto::IActivityProfilerSession> XPUActivityProfiler::
configure(
const std::set<ActivityType>& activity_types,
const libkineto::Config& config) {
#if PTI_VERSION_AT_LEAST(0, 15)
return std::make_unique<XpuptiScopeProfilerSession>(
XpuptiActivityApi::singleton(), name(), config, activity_types);
#else
return std::make_unique<XpuptiActivityProfilerSession>(
XpuptiActivityApi::singleton(), name(), config, activity_types);
#endif
}

std::unique_ptr<libkineto::IActivityProfilerSession> XPUActivityProfiler::
Expand Down
23 changes: 22 additions & 1 deletion libkineto/src/plugin/xpupti/XpuptiActivityProfilerSession.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ class XpuptiActivityProfilerSession : public libkineto::IActivityProfilerSession

void addResouceInfo(int32_t device_id, int32_t sycl_queue_id);

private:
protected:
static uint32_t iterationCount_;
static std::vector<DeviceUUIDsT> deviceUUIDs_;
static std::unordered_set<std::string_view> correlateRuntimeOps_;
Expand All @@ -117,6 +117,27 @@ class XpuptiActivityProfilerSession : public libkineto::IActivityProfilerSession
std::unique_ptr<const libkineto::Config> config_{nullptr};
const std::set<ActivityType>& activity_types_;
std::string name_;

struct KernelActivity {
void emplace(
int64_t startTime,
int64_t endTime,
int32_t device,
int32_t resource) {
startTime_ = startTime;
endTime_ = endTime;
device_ = device;
resource_ = resource;
}

int64_t startTime_{0};
int64_t endTime_{0};
int32_t device_{0};
int32_t resource_{0};
};

std::unordered_map<uint64_t, KernelActivity> kernelActivities_;
uint64_t lastKernelActivityEndTime_{0};
};

} // namespace KINETO_NAMESPACE
178 changes: 178 additions & 0 deletions libkineto/src/plugin/xpupti/XpuptiScopeProfilerApi.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,178 @@
/*
* 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 "XpuptiScopeProfilerApi.h"

#if PTI_VERSION_AT_LEAST(0, 15)

#include "XpuptiScopeProfilerConfig.h"

#include <algorithm>
#include <iterator>
#include <stdexcept>

#endif

namespace KINETO_NAMESPACE {

#if PTI_VERSION_AT_LEAST(0, 15)

XpuptiScopeProfilerApi::safe_pti_scope_collection_handle_t::
safe_pti_scope_collection_handle_t(std::exception_ptr& exceptFromDestructor)
: exceptFromDestructor_(exceptFromDestructor) {
XPUPTI_CALL(ptiMetricsScopeEnable(&handle_));
}

XpuptiScopeProfilerApi::safe_pti_scope_collection_handle_t::
~safe_pti_scope_collection_handle_t() noexcept {
try {
XPUPTI_CALL(ptiMetricsScopeDisable(handle_));
} catch (...) {
exceptFromDestructor_ = std::current_exception();
}
}

void XpuptiScopeProfilerApi::enableScopeProfiler(const Config& cfg) {
uint32_t deviceCount = 0;
XPUPTI_CALL(ptiMetricsGetDevices(nullptr, &deviceCount));

if (deviceCount == 0) {
throw std::runtime_error("No XPU devices available");
}

auto devices = std::make_unique<pti_device_properties_t[]>(deviceCount);
XPUPTI_CALL(ptiMetricsGetDevices(devices.get(), &deviceCount));

auto devicesHandles = std::make_unique<pti_device_handle_t[]>(deviceCount);
for (uint32_t i = 0; i < deviceCount; ++i) {
devicesHandles[i] = devices[i]._handle;
}

const auto& spcfg = XpuptiScopeProfilerConfig::get(cfg);
const auto& activitiesXpuptiMetrics = spcfg.activitiesXpuptiMetrics();

std::vector<const char*> metricNames;
metricNames.reserve(activitiesXpuptiMetrics.size());
std::transform(
activitiesXpuptiMetrics.begin(),
activitiesXpuptiMetrics.end(),
std::back_inserter(metricNames),
[](const std::string& s) { return s.c_str(); });

pti_metrics_scope_mode_t collectionMode = spcfg.xpuptiProfilerPerKernel()
? PTI_METRICS_SCOPE_AUTO_KERNEL
: PTI_METRICS_SCOPE_USER;

if (collectionMode == PTI_METRICS_SCOPE_USER) {
throw std::runtime_error(
"XPUPTI_PROFILER_ENABLE_PER_KERNEL has to be set to 1. Other variants are currently not supported.");
}

scopeHandleOpt_.emplace(exceptFromScopeHandleDestructor_);
XPUPTI_CALL(ptiMetricsScopeConfigure(
*scopeHandleOpt_,
collectionMode,
devicesHandles.get(),
((void)deviceCount, 1), // Only 1 device is currently supported
metricNames.data(),
metricNames.size()));

uint64_t expectedKernels = spcfg.xpuptiProfilerMaxScopes();
size_t estimatedCollectionBufferSize = 0;
XPUPTI_CALL(ptiMetricsScopeQueryCollectionBufferSize(
*scopeHandleOpt_, expectedKernels, &estimatedCollectionBufferSize));

XPUPTI_CALL(ptiMetricsScopeSetCollectionBufferSize(
*scopeHandleOpt_, estimatedCollectionBufferSize));
}

void XpuptiScopeProfilerApi::disableScopeProfiler() {
scopeHandleOpt_.reset();
if (exceptFromScopeHandleDestructor_) {
std::rethrow_exception(exceptFromScopeHandleDestructor_);
}
}

void XpuptiScopeProfilerApi::startScopeActivity() {
if (scopeHandleOpt_) {
XPUPTI_CALL(ptiMetricsScopeStartCollection(*scopeHandleOpt_));
}
}

void XpuptiScopeProfilerApi::stopScopeActivity() {
if (scopeHandleOpt_) {
XPUPTI_CALL(ptiMetricsScopeStopCollection(*scopeHandleOpt_));
}
}

static size_t IntDivRoundUp(size_t a, size_t b) {
return (a + b - 1) / b;
}

void XpuptiScopeProfilerApi::processScopeTrace(
std::function<void(
const pti_metrics_scope_record_t*,
const pti_metrics_scope_record_metadata_t& metadata)> handler) {
if (scopeHandleOpt_) {
pti_metrics_scope_record_metadata_t metadata;
metadata._struct_size = sizeof(pti_metrics_scope_record_metadata_t);

XPUPTI_CALL(ptiMetricsScopeGetMetricsMetadata(*scopeHandleOpt_, &metadata));

uint64_t collectionBuffersCount = 0;
XPUPTI_CALL(ptiMetricsScopeGetCollectionBuffersCount(
*scopeHandleOpt_, &collectionBuffersCount));

for (uint64_t bufferId = 0; bufferId < collectionBuffersCount; ++bufferId) {
void* collectionBuffer = nullptr;
size_t actualCollectionBufferSize = 0;
XPUPTI_CALL(ptiMetricsScopeGetCollectionBuffer(
*scopeHandleOpt_,
bufferId,
&collectionBuffer,
&actualCollectionBufferSize));

pti_metrics_scope_collection_buffer_properties_t metricsBufferProps;
metricsBufferProps._struct_size =
sizeof(pti_metrics_scope_collection_buffer_properties_t);
XPUPTI_CALL(ptiMetricsScopeGetCollectionBufferProperties(
*scopeHandleOpt_, collectionBuffer, &metricsBufferProps));

size_t requiredMetricsBufferSize = 0;
size_t recordsCount = 0;
XPUPTI_CALL(ptiMetricsScopeQueryMetricsBufferSize(
*scopeHandleOpt_,
collectionBuffer,
&requiredMetricsBufferSize,
&recordsCount));

if (recordsCount > 0) {
auto metricsBuffer =
std::make_unique<pti_metrics_scope_record_t[]>(IntDivRoundUp(
requiredMetricsBufferSize, sizeof(pti_metrics_scope_record_t)));

size_t actualRecordsCount = 0;
XPUPTI_CALL(ptiMetricsScopeCalculateMetrics(
*scopeHandleOpt_,
collectionBuffer,
metricsBuffer.get(),
requiredMetricsBufferSize,
&actualRecordsCount));

for (size_t recordId = 0; recordId < actualRecordsCount; ++recordId) {
auto record = metricsBuffer.get() + recordId;
handler(record, metadata);
}
}
}
}
}

#endif

} // namespace KINETO_NAMESPACE
61 changes: 61 additions & 0 deletions libkineto/src/plugin/xpupti/XpuptiScopeProfilerApi.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/*
* 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 "XpuptiActivityApi.h"

#if PTI_VERSION_AT_LEAST(0, 15)

#include <pti/pti_metrics_scope.h>

#include <optional>

namespace KINETO_NAMESPACE {

class Config;

class XpuptiScopeProfilerApi {
public:
XpuptiScopeProfilerApi() = default;
XpuptiScopeProfilerApi(const XpuptiScopeProfilerApi&) = delete;
XpuptiScopeProfilerApi& operator=(const XpuptiScopeProfilerApi&) = delete;

~XpuptiScopeProfilerApi() = default;

void enableScopeProfiler(const Config&);
void disableScopeProfiler();
void startScopeActivity();
void stopScopeActivity();

void processScopeTrace(
std::function<void(
const pti_metrics_scope_record_t*,
const pti_metrics_scope_record_metadata_t& metadata)> handler);

private:
struct safe_pti_scope_collection_handle_t {
safe_pti_scope_collection_handle_t(
std::exception_ptr& exceptFromDestructor);
~safe_pti_scope_collection_handle_t() noexcept;

operator pti_scope_collection_handle_t() {
return handle_;
}

pti_scope_collection_handle_t handle_{};
std::exception_ptr& exceptFromDestructor_;
};

std::optional<safe_pti_scope_collection_handle_t> scopeHandleOpt_;
std::exception_ptr exceptFromScopeHandleDestructor_;
};

} // namespace KINETO_NAMESPACE

#endif
Loading
Loading