Skip to content

Commit 8f70ba9

Browse files
Disable Metrics Library after Metric Tracer usage.
Metric Tracer can use Metrics Library to generate gpu commands for Metric Tracer marker. Closing Metrics Library will force it to reintialize, so Metric Query can use Linux time based sampling stream exclusively (needed to activate metric set or to obtain context switch/triggered reports). Change-Id: I3105febfbbd78b537ef0688d1b9c08ab54f9a875
1 parent e61136d commit 8f70ba9

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

level_zero/tools/source/metrics/metric_query_imp.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ struct MetricsLibrary {
4545
bool isInitialized();
4646
static const char *getFilename();
4747

48+
// Deinitialization.
49+
void release();
50+
4851
// Metric query.
4952
bool createMetricQuery(const uint32_t slotsCount, QueryHandle_1_0 &query,
5053
NEO::GraphicsAllocation *&pAllocation);
@@ -66,7 +69,6 @@ struct MetricsLibrary {
6669

6770
protected:
6871
void initialize();
69-
void release();
7072

7173
bool createContext();
7274
virtual bool getContextData(Device &device, ContextCreateData_1_0 &contextData);

level_zero/tools/source/metrics/metric_tracer_imp.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,18 @@ ze_result_t MetricTracerImp::close() {
4747
const auto result = stopMeasurements();
4848
if (result == ZE_RESULT_SUCCESS) {
4949

50-
// Clear metric tracer reference in context.
5150
auto device = Device::fromHandle(hDevice);
52-
device->getMetricContext().setMetricTracer(nullptr);
51+
auto &metricContext = device->getMetricContext();
52+
auto &metricsLibrary = metricContext.getMetricsLibrary();
53+
54+
// Clear metric tracer reference in context.
55+
// Another metric tracer instance or query can be used.
56+
metricContext.setMetricTracer(nullptr);
57+
58+
// Close metrics library (if was used to generate tracer's marker gpu commands).
59+
// It will allow metric query to use Linux Tbs stream exclusively
60+
// (to activate metric sets and to read context switch reports).
61+
metricsLibrary.release();
5362

5463
// Release notification event.
5564
if (pNotificationEvent != nullptr) {

0 commit comments

Comments
 (0)