Skip to content

Commit 5efbf1d

Browse files
refactor: add driver experimental entry points for tracer apis
Related-To: NEO-13770 Signed-off-by: Joshua Santosh Ranjan <[email protected]>
1 parent 1e5e7fa commit 5efbf1d

File tree

3 files changed

+249
-0
lines changed

3 files changed

+249
-0
lines changed

level_zero/api/driver_experimental/public/zex_metric.cpp

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,58 @@ ze_result_t ZE_APICALL zetIntelCommandListAppendMarkerExp(zet_command_list_handl
1818
return metricGroupImp->getMetricSource().appendMarker(hCommandList, hMetricGroup, value);
1919
}
2020

21+
ze_result_t ZE_APICALL zetIntelMetricTracerCreateExp(zet_context_handle_t hContext,
22+
zet_device_handle_t hDevice,
23+
uint32_t metricGroupCount,
24+
zet_metric_group_handle_t *phMetricGroups,
25+
zet_intel_metric_tracer_exp_desc_t *desc,
26+
ze_event_handle_t hNotificationEvent,
27+
zet_intel_metric_tracer_exp_handle_t *phMetricTracer) {
28+
return L0::metricTracerCreate(hContext, hDevice, metricGroupCount, phMetricGroups, desc, hNotificationEvent, phMetricTracer);
29+
}
30+
31+
ze_result_t ZE_APICALL zetIntelMetricTracerDestroyExp(zet_intel_metric_tracer_exp_handle_t hMetricTracer) {
32+
return L0::metricTracerDestroy(hMetricTracer);
33+
}
34+
35+
ze_result_t ZE_APICALL zetIntelMetricTracerEnableExp(zet_intel_metric_tracer_exp_handle_t hMetricTracer,
36+
ze_bool_t synchronous) {
37+
return L0::metricTracerEnable(hMetricTracer, synchronous);
38+
}
39+
40+
ze_result_t ZE_APICALL zetIntelMetricTracerDisableExp(zet_intel_metric_tracer_exp_handle_t hMetricTracer,
41+
ze_bool_t synchronous) {
42+
return L0::metricTracerDisable(hMetricTracer, synchronous);
43+
}
44+
45+
ze_result_t ZE_APICALL zetIntelMetricTracerReadDataExp(zet_intel_metric_tracer_exp_handle_t hMetricTracer,
46+
size_t *pRawDataSize, uint8_t *pRawData) {
47+
return L0::metricTracerReadData(hMetricTracer, pRawDataSize, pRawData);
48+
}
49+
50+
ze_result_t ZE_APICALL zetIntelMetricDecoderCreateExp(zet_intel_metric_tracer_exp_handle_t hMetricTracer,
51+
zet_intel_metric_decoder_exp_handle_t *phMetricDecoder) {
52+
return L0::metricDecoderCreate(hMetricTracer, phMetricDecoder);
53+
}
54+
55+
ze_result_t ZE_APICALL zetIntelMetricDecoderDestroyExp(zet_intel_metric_decoder_exp_handle_t phMetricDecoder) {
56+
return L0::metricDecoderDestroy(phMetricDecoder);
57+
}
58+
59+
ze_result_t ZE_APICALL zetIntelMetricDecoderGetDecodableMetricsExp(zet_intel_metric_decoder_exp_handle_t hMetricDecoder,
60+
uint32_t *pCount,
61+
zet_metric_handle_t *phMetrics) {
62+
return L0::metricDecoderGetDecodableMetrics(hMetricDecoder, pCount, phMetrics);
63+
}
64+
65+
ze_result_t ZE_APICALL zetIntelMetricTracerDecodeExp(zet_intel_metric_decoder_exp_handle_t phMetricDecoder,
66+
size_t *pRawDataSize, uint8_t *pRawData, uint32_t metricsCount,
67+
zet_metric_handle_t *phMetrics, uint32_t *pSetCount, uint32_t *pMetricEntriesCountPerSet,
68+
uint32_t *pMetricEntriesCount, zet_intel_metric_entry_exp_t *pMetricEntries) {
69+
return L0::metricTracerDecode(phMetricDecoder, pRawDataSize, pRawData, metricsCount, phMetrics,
70+
pSetCount, pMetricEntriesCountPerSet, pMetricEntriesCount, pMetricEntries);
71+
}
72+
2173
} // namespace L0
2274

2375
extern "C" {
@@ -29,4 +81,71 @@ zetIntelCommandListAppendMarkerExp(
2981
uint32_t value) {
3082
return L0::zetIntelCommandListAppendMarkerExp(hCommandList, hMetricGroup, value);
3183
}
84+
85+
ze_result_t ZE_APICALL zetIntelMetricTracerCreateExp(
86+
zet_context_handle_t hContext,
87+
zet_device_handle_t hDevice,
88+
uint32_t metricGroupCount,
89+
zet_metric_group_handle_t *phMetricGroups,
90+
zet_intel_metric_tracer_exp_desc_t *desc,
91+
ze_event_handle_t hNotificationEvent,
92+
zet_intel_metric_tracer_exp_handle_t *phMetricTracer) {
93+
return L0::zetIntelMetricTracerCreateExp(hContext, hDevice, metricGroupCount, phMetricGroups, desc, hNotificationEvent, phMetricTracer);
94+
}
95+
96+
ze_result_t ZE_APICALL zetIntelMetricTracerDestroyExp(
97+
zet_intel_metric_tracer_exp_handle_t hMetricTracer) {
98+
return L0::zetIntelMetricTracerDestroyExp(hMetricTracer);
99+
}
100+
101+
ze_result_t ZE_APICALL zetIntelMetricTracerEnableExp(
102+
zet_intel_metric_tracer_exp_handle_t hMetricTracer,
103+
ze_bool_t synchronous) {
104+
return L0::zetIntelMetricTracerEnableExp(hMetricTracer, synchronous);
105+
}
106+
107+
ze_result_t ZE_APICALL zetIntelMetricTracerDisableExp(
108+
zet_intel_metric_tracer_exp_handle_t hMetricTracer,
109+
ze_bool_t synchronous) {
110+
return L0::zetIntelMetricTracerDisableExp(hMetricTracer, synchronous);
111+
}
112+
113+
ze_result_t ZE_APICALL zetIntelMetricTracerReadDataExp(
114+
zet_intel_metric_tracer_exp_handle_t hMetricTracer,
115+
size_t *pRawDataSize,
116+
uint8_t *pRawData) {
117+
return L0::zetIntelMetricTracerReadDataExp(hMetricTracer, pRawDataSize, pRawData);
118+
}
119+
120+
ze_result_t ZE_APICALL zetIntelMetricDecoderCreateExp(
121+
zet_intel_metric_tracer_exp_handle_t hMetricTracer,
122+
zet_intel_metric_decoder_exp_handle_t *phMetricDecoder) {
123+
return L0::zetIntelMetricDecoderCreateExp(hMetricTracer, phMetricDecoder);
124+
}
125+
126+
ze_result_t ZE_APICALL zetIntelMetricDecoderDestroyExp(
127+
zet_intel_metric_decoder_exp_handle_t phMetricDecoder) {
128+
return L0::zetIntelMetricDecoderDestroyExp(phMetricDecoder);
129+
}
130+
131+
ze_result_t ZE_APICALL zetIntelMetricDecoderGetDecodableMetricsExp(
132+
zet_intel_metric_decoder_exp_handle_t hMetricDecoder,
133+
uint32_t *pCount,
134+
zet_metric_handle_t *phMetrics) {
135+
return L0::zetIntelMetricDecoderGetDecodableMetricsExp(hMetricDecoder, pCount, phMetrics);
136+
}
137+
138+
ze_result_t ZE_APICALL zetIntelMetricTracerDecodeExp(
139+
zet_intel_metric_decoder_exp_handle_t phMetricDecoder,
140+
size_t *pRawDataSize,
141+
uint8_t *pRawData,
142+
uint32_t metricsCount,
143+
zet_metric_handle_t *phMetrics,
144+
uint32_t *pSetCount,
145+
uint32_t *pMetricEntriesCountPerSet,
146+
uint32_t *pMetricEntriesCount,
147+
zet_intel_metric_entry_exp_t *pMetricEntries) {
148+
return L0::zetIntelMetricTracerDecodeExp(phMetricDecoder, pRawDataSize, pRawData, metricsCount, phMetrics, pSetCount,
149+
pMetricEntriesCountPerSet, pMetricEntriesCount, pMetricEntries);
150+
}
32151
}

level_zero/core/source/driver/extension_function_address.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,15 @@ void *ExtensionFunctionAddressHelper::getExtensionFunctionAddress(const std::str
6363
RETURN_FUNC_PTR_IF_EXIST(zeIntelCommandListAppendSignalExternalSemaphoresExp);
6464
RETURN_FUNC_PTR_IF_EXIST(zeIntelDeviceReleaseExternalSemaphoreExp);
6565
RETURN_FUNC_PTR_IF_EXIST(zetIntelCommandListAppendMarkerExp);
66+
RETURN_FUNC_PTR_IF_EXIST(zetIntelMetricTracerCreateExp);
67+
RETURN_FUNC_PTR_IF_EXIST(zetIntelMetricTracerDestroyExp);
68+
RETURN_FUNC_PTR_IF_EXIST(zetIntelMetricTracerEnableExp);
69+
RETURN_FUNC_PTR_IF_EXIST(zetIntelMetricTracerDisableExp);
70+
RETURN_FUNC_PTR_IF_EXIST(zetIntelMetricTracerReadDataExp);
71+
RETURN_FUNC_PTR_IF_EXIST(zetIntelMetricDecoderCreateExp);
72+
RETURN_FUNC_PTR_IF_EXIST(zetIntelMetricDecoderDestroyExp);
73+
RETURN_FUNC_PTR_IF_EXIST(zetIntelMetricDecoderGetDecodableMetricsExp);
74+
RETURN_FUNC_PTR_IF_EXIST(zetIntelMetricTracerDecodeExp);
6675

6776
#undef RETURN_FUNC_PTR_IF_EXIST
6877

level_zero/include/level_zero/zet_intel_gpu_metric.h

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,127 @@ ze_result_t ZE_APICALL zetIntelCommandListAppendMarkerExp(zet_command_list_handl
4545
zet_metric_group_handle_t hMetricGroup,
4646
uint32_t value);
4747

48+
typedef zet_metric_tracer_exp_desc_t zet_intel_metric_tracer_exp_desc_t;
49+
typedef zet_metric_tracer_exp_handle_t zet_intel_metric_tracer_exp_handle_t;
50+
typedef zet_metric_decoder_exp_handle_t zet_intel_metric_decoder_exp_handle_t;
51+
typedef zet_metric_entry_exp_t zet_intel_metric_entry_exp_t;
52+
53+
ze_result_t ZE_APICALL zetIntelMetricTracerCreateExp(
54+
zet_context_handle_t hContext, ///< [in] handle of the context object
55+
zet_device_handle_t hDevice, ///< [in] handle of the device
56+
uint32_t metricGroupCount, ///< [in] metric group count
57+
zet_metric_group_handle_t *phMetricGroups, ///< [in][range(0, metricGroupCount )] handles of the metric groups to
58+
///< trace
59+
zet_intel_metric_tracer_exp_desc_t *desc, ///< [in,out] metric tracer descriptor
60+
ze_event_handle_t hNotificationEvent, ///< [in][optional] event used for report availability notification. Note:
61+
///< If buffer is not drained when the event it flagged, there is a risk of
62+
///< HW event buffer being overrun
63+
zet_intel_metric_tracer_exp_handle_t *phMetricTracer ///< [out] handle of the metric tracer
64+
);
65+
66+
ze_result_t ZE_APICALL zetIntelMetricTracerDestroyExp(
67+
zet_intel_metric_tracer_exp_handle_t hMetricTracer ///< [in] handle of the metric tracer
68+
);
69+
70+
ze_result_t ZE_APICALL zetIntelMetricTracerEnableExp(
71+
zet_intel_metric_tracer_exp_handle_t hMetricTracer, ///< [in] handle of the metric tracer
72+
ze_bool_t synchronous ///< [in] request synchronous behavior. Confirmation of successful
73+
///< asynchronous operation is done by calling ::zetMetricTracerReadDataExp()
74+
///< and checking the return status: ::ZE_RESULT_NOT_READY will be returned
75+
///< when the tracer is inactive. ::ZE_RESULT_SUCCESS will be returned
76+
///< when the tracer is active.
77+
);
78+
79+
ze_result_t ZE_APICALL zetIntelMetricTracerDisableExp(
80+
zet_intel_metric_tracer_exp_handle_t hMetricTracer, ///< [in] handle of the metric tracer
81+
ze_bool_t synchronous ///< [in] request synchronous behavior. Confirmation of successful
82+
///< asynchronous operation is done by calling ::zetMetricTracerReadDataExp()
83+
///< and checking the return status: ::ZE_RESULT_SUCCESS will be returned
84+
///< when the tracer is active or when it is inactive but still has data.
85+
///< ::ZE_RESULT_NOT_READY will be returned when the tracer is inactive and
86+
///< has no more data to be retrieved.
87+
);
88+
89+
ze_result_t ZE_APICALL zetIntelMetricTracerReadDataExp(
90+
zet_intel_metric_tracer_exp_handle_t hMetricTracer, ///< [in] handle of the metric tracer
91+
size_t *pRawDataSize, ///< [in,out] pointer to size in bytes of raw data requested to read.
92+
///< if size is zero, then the driver will update the value with the total
93+
///< size in bytes needed for all data available.
94+
///< if size is non-zero, then driver will only retrieve that amount of
95+
///< data.
96+
///< if size is larger than size needed for all data, then driver will
97+
///< update the value with the actual size needed.
98+
uint8_t *pRawData ///< [in,out][optional][range(0, *pRawDataSize)] buffer containing tracer
99+
///< data in raw format
100+
);
101+
102+
ze_result_t ZE_APICALL zetIntelMetricDecoderCreateExp(
103+
zet_intel_metric_tracer_exp_handle_t hMetricTracer, ///< [in] handle of the metric tracer
104+
zet_intel_metric_decoder_exp_handle_t *phMetricDecoder ///< [out] handle of the metric decoder object
105+
);
106+
107+
ze_result_t ZE_APICALL zetIntelMetricDecoderDestroyExp(
108+
zet_intel_metric_decoder_exp_handle_t phMetricDecoder ///< [in] handle of the metric decoder object
109+
);
110+
111+
ze_result_t ZE_APICALL zetIntelMetricDecoderGetDecodableMetricsExp(
112+
zet_intel_metric_decoder_exp_handle_t hMetricDecoder, ///< [in] handle of the metric decoder object
113+
uint32_t *pCount, ///< [in,out] pointer to number of decodable metric in the hMetricDecoder
114+
///< handle. If count is zero, then the driver shall
115+
///< update the value with the total number of decodable metrics available
116+
///< in the decoder. if count is greater than zero
117+
///< but less than the total number of decodable metrics available in the
118+
///< decoder, then only that number will be returned.
119+
///< if count is greater than the number of decodable metrics available in
120+
///< the decoder, then the driver shall update the
121+
///< value with the actual number of decodable metrics available.
122+
zet_metric_handle_t *phMetrics ///< [in,out] [range(0, *pCount)] array of handles of decodable metrics in
123+
///< the hMetricDecoder handle provided.
124+
);
125+
126+
ze_result_t ZE_APICALL zetIntelMetricTracerDecodeExp(
127+
zet_intel_metric_decoder_exp_handle_t phMetricDecoder, ///< [in] handle of the metric decoder object
128+
size_t *pRawDataSize, ///< [in,out] size in bytes of raw data buffer. If pMetricEntriesCount is
129+
///< greater than zero but less than total number of
130+
///< decodable metrics available in the raw data buffer, then driver shall
131+
///< update this value with actual number of raw
132+
///< data bytes processed.
133+
uint8_t *pRawData, ///< [in,out][optional][range(0, *pRawDataSize)] buffer containing tracer
134+
///< data in raw format
135+
uint32_t metricsCount, ///< [in] number of decodable metrics in the tracer for which the
136+
///< hMetricDecoder handle was provided. See
137+
///< ::zetMetricDecoderGetDecodableMetricsExp(). If metricCount is greater
138+
///< than zero but less than the number decodable
139+
///< metrics available in the raw data buffer, then driver shall only
140+
///< decode those.
141+
zet_metric_handle_t *phMetrics, ///< [in] [range(0, metricsCount)] array of handles of decodable metrics in
142+
///< the decoder for which the hMetricDecoder handle was
143+
///< provided. Metrics handles are expected to be for decodable metrics,
144+
///< see ::zetMetricDecoderGetDecodableMetricsExp()
145+
uint32_t *pSetCount, ///< [in,out] pointer to number of metric sets. If count is zero, then the
146+
///< driver shall update the value with the total
147+
///< number of metric sets to be decoded. If count is greater than the
148+
///< number available in the raw data buffer, then the
149+
///< driver shall update the value with the actual number of metric sets to
150+
///< be decoded. There is a 1:1 relation between
151+
///< the number of sets and sub-devices returned in the decoded entries.
152+
uint32_t *pMetricEntriesCountPerSet, ///< [in,out][optional][range(0, *pSetCount)] buffer of metric entries
153+
///< counts per metric set, one value per set.
154+
uint32_t *pMetricEntriesCount, ///< [in,out] pointer to the total number of metric entries decoded, for
155+
///< all metric sets. If count is zero, then the
156+
///< driver shall update the value with the total number of metric entries
157+
///< to be decoded. If count is greater than zero
158+
///< but less than the total number of metric entries available in the raw
159+
///< data, then user provided number will be decoded.
160+
///< If count is greater than the number available in the raw data buffer,
161+
///< then the driver shall update the value with
162+
///< the actual number of decodable metric entries decoded. If set to null,
163+
///< then driver will only update the value of
164+
///< pSetCount.
165+
zet_intel_metric_entry_exp_t *pMetricEntries ///< [in,out][optional][range(0, *pMetricEntriesCount)] buffer containing
166+
///< decoded metric entries
167+
);
168+
48169
#if defined(__cplusplus)
49170
} // extern "C"
50171
#endif

0 commit comments

Comments
 (0)