1 /*
2 *
3 * Copyright (C) 2019-2021 Intel Corporation
4 *
5 * SPDX-License-Identifier: MIT
6 *
7 * @file zet_valddi.cpp
8 *
9 */
10 #include "ze_validation_layer.h"
11
12 namespace validation_layer
13 {
14 ///////////////////////////////////////////////////////////////////////////////
15 /// @brief Intercept function for zetModuleGetDebugInfo
16 __zedlllocal ze_result_t ZE_APICALL
zetModuleGetDebugInfo(zet_module_handle_t hModule,zet_module_debug_info_format_t format,size_t * pSize,uint8_t * pDebugInfo)17 zetModuleGetDebugInfo(
18 zet_module_handle_t hModule, ///< [in] handle of the module
19 zet_module_debug_info_format_t format, ///< [in] debug info format requested
20 size_t* pSize, ///< [in,out] size of debug info in bytes
21 uint8_t* pDebugInfo ///< [in,out][optional] byte pointer to debug info
22 )
23 {
24 auto pfnGetDebugInfo = context.zetDdiTable.Module.pfnGetDebugInfo;
25
26 if( nullptr == pfnGetDebugInfo )
27 return ZE_RESULT_ERROR_UNINITIALIZED;
28
29 if( context.enableParameterValidation )
30 {
31 if( nullptr == hModule )
32 return ZE_RESULT_ERROR_INVALID_NULL_HANDLE;
33
34 if( ZET_MODULE_DEBUG_INFO_FORMAT_ELF_DWARF < format )
35 return ZE_RESULT_ERROR_INVALID_ENUMERATION;
36
37 if( nullptr == pSize )
38 return ZE_RESULT_ERROR_INVALID_NULL_POINTER;
39
40 }
41
42 return pfnGetDebugInfo( hModule, format, pSize, pDebugInfo );
43 }
44
45 ///////////////////////////////////////////////////////////////////////////////
46 /// @brief Intercept function for zetDeviceGetDebugProperties
47 __zedlllocal ze_result_t ZE_APICALL
zetDeviceGetDebugProperties(zet_device_handle_t hDevice,zet_device_debug_properties_t * pDebugProperties)48 zetDeviceGetDebugProperties(
49 zet_device_handle_t hDevice, ///< [in] device handle
50 zet_device_debug_properties_t* pDebugProperties ///< [in,out] query result for debug properties
51 )
52 {
53 auto pfnGetDebugProperties = context.zetDdiTable.Device.pfnGetDebugProperties;
54
55 if( nullptr == pfnGetDebugProperties )
56 return ZE_RESULT_ERROR_UNINITIALIZED;
57
58 if( context.enableParameterValidation )
59 {
60 if( nullptr == hDevice )
61 return ZE_RESULT_ERROR_INVALID_NULL_HANDLE;
62
63 if( nullptr == pDebugProperties )
64 return ZE_RESULT_ERROR_INVALID_NULL_POINTER;
65
66 }
67
68 return pfnGetDebugProperties( hDevice, pDebugProperties );
69 }
70
71 ///////////////////////////////////////////////////////////////////////////////
72 /// @brief Intercept function for zetDebugAttach
73 __zedlllocal ze_result_t ZE_APICALL
zetDebugAttach(zet_device_handle_t hDevice,const zet_debug_config_t * config,zet_debug_session_handle_t * phDebug)74 zetDebugAttach(
75 zet_device_handle_t hDevice, ///< [in] device handle
76 const zet_debug_config_t* config, ///< [in] the debug configuration
77 zet_debug_session_handle_t* phDebug ///< [out] debug session handle
78 )
79 {
80 auto pfnAttach = context.zetDdiTable.Debug.pfnAttach;
81
82 if( nullptr == pfnAttach )
83 return ZE_RESULT_ERROR_UNINITIALIZED;
84
85 if( context.enableParameterValidation )
86 {
87 if( nullptr == hDevice )
88 return ZE_RESULT_ERROR_INVALID_NULL_HANDLE;
89
90 if( nullptr == config )
91 return ZE_RESULT_ERROR_INVALID_NULL_POINTER;
92
93 if( nullptr == phDebug )
94 return ZE_RESULT_ERROR_INVALID_NULL_POINTER;
95
96 }
97
98 return pfnAttach( hDevice, config, phDebug );
99 }
100
101 ///////////////////////////////////////////////////////////////////////////////
102 /// @brief Intercept function for zetDebugDetach
103 __zedlllocal ze_result_t ZE_APICALL
zetDebugDetach(zet_debug_session_handle_t hDebug)104 zetDebugDetach(
105 zet_debug_session_handle_t hDebug ///< [in][release] debug session handle
106 )
107 {
108 auto pfnDetach = context.zetDdiTable.Debug.pfnDetach;
109
110 if( nullptr == pfnDetach )
111 return ZE_RESULT_ERROR_UNINITIALIZED;
112
113 if( context.enableParameterValidation )
114 {
115 if( nullptr == hDebug )
116 return ZE_RESULT_ERROR_INVALID_NULL_HANDLE;
117
118 }
119
120 return pfnDetach( hDebug );
121 }
122
123 ///////////////////////////////////////////////////////////////////////////////
124 /// @brief Intercept function for zetDebugReadEvent
125 __zedlllocal ze_result_t ZE_APICALL
zetDebugReadEvent(zet_debug_session_handle_t hDebug,uint64_t timeout,zet_debug_event_t * event)126 zetDebugReadEvent(
127 zet_debug_session_handle_t hDebug, ///< [in] debug session handle
128 uint64_t timeout, ///< [in] if non-zero, then indicates the maximum time (in milliseconds) to
129 ///< yield before returning ::ZE_RESULT_SUCCESS or ::ZE_RESULT_NOT_READY;
130 ///< if zero, then immediately returns the status of the event;
131 ///< if UINT64_MAX, then function will not return until complete or device
132 ///< is lost.
133 ///< Due to external dependencies, timeout may be rounded to the closest
134 ///< value allowed by the accuracy of those dependencies.
135 zet_debug_event_t* event ///< [in,out] a pointer to a ::zet_debug_event_t.
136 )
137 {
138 auto pfnReadEvent = context.zetDdiTable.Debug.pfnReadEvent;
139
140 if( nullptr == pfnReadEvent )
141 return ZE_RESULT_ERROR_UNINITIALIZED;
142
143 if( context.enableParameterValidation )
144 {
145 if( nullptr == hDebug )
146 return ZE_RESULT_ERROR_INVALID_NULL_HANDLE;
147
148 if( nullptr == event )
149 return ZE_RESULT_ERROR_INVALID_NULL_POINTER;
150
151 }
152
153 return pfnReadEvent( hDebug, timeout, event );
154 }
155
156 ///////////////////////////////////////////////////////////////////////////////
157 /// @brief Intercept function for zetDebugAcknowledgeEvent
158 __zedlllocal ze_result_t ZE_APICALL
zetDebugAcknowledgeEvent(zet_debug_session_handle_t hDebug,const zet_debug_event_t * event)159 zetDebugAcknowledgeEvent(
160 zet_debug_session_handle_t hDebug, ///< [in] debug session handle
161 const zet_debug_event_t* event ///< [in] a pointer to a ::zet_debug_event_t.
162 )
163 {
164 auto pfnAcknowledgeEvent = context.zetDdiTable.Debug.pfnAcknowledgeEvent;
165
166 if( nullptr == pfnAcknowledgeEvent )
167 return ZE_RESULT_ERROR_UNINITIALIZED;
168
169 if( context.enableParameterValidation )
170 {
171 if( nullptr == hDebug )
172 return ZE_RESULT_ERROR_INVALID_NULL_HANDLE;
173
174 if( nullptr == event )
175 return ZE_RESULT_ERROR_INVALID_NULL_POINTER;
176
177 }
178
179 return pfnAcknowledgeEvent( hDebug, event );
180 }
181
182 ///////////////////////////////////////////////////////////////////////////////
183 /// @brief Intercept function for zetDebugInterrupt
184 __zedlllocal ze_result_t ZE_APICALL
zetDebugInterrupt(zet_debug_session_handle_t hDebug,ze_device_thread_t thread)185 zetDebugInterrupt(
186 zet_debug_session_handle_t hDebug, ///< [in] debug session handle
187 ze_device_thread_t thread ///< [in] the thread to interrupt
188 )
189 {
190 auto pfnInterrupt = context.zetDdiTable.Debug.pfnInterrupt;
191
192 if( nullptr == pfnInterrupt )
193 return ZE_RESULT_ERROR_UNINITIALIZED;
194
195 if( context.enableParameterValidation )
196 {
197 if( nullptr == hDebug )
198 return ZE_RESULT_ERROR_INVALID_NULL_HANDLE;
199
200 }
201
202 return pfnInterrupt( hDebug, thread );
203 }
204
205 ///////////////////////////////////////////////////////////////////////////////
206 /// @brief Intercept function for zetDebugResume
207 __zedlllocal ze_result_t ZE_APICALL
zetDebugResume(zet_debug_session_handle_t hDebug,ze_device_thread_t thread)208 zetDebugResume(
209 zet_debug_session_handle_t hDebug, ///< [in] debug session handle
210 ze_device_thread_t thread ///< [in] the thread to resume
211 )
212 {
213 auto pfnResume = context.zetDdiTable.Debug.pfnResume;
214
215 if( nullptr == pfnResume )
216 return ZE_RESULT_ERROR_UNINITIALIZED;
217
218 if( context.enableParameterValidation )
219 {
220 if( nullptr == hDebug )
221 return ZE_RESULT_ERROR_INVALID_NULL_HANDLE;
222
223 }
224
225 return pfnResume( hDebug, thread );
226 }
227
228 ///////////////////////////////////////////////////////////////////////////////
229 /// @brief Intercept function for zetDebugReadMemory
230 __zedlllocal ze_result_t ZE_APICALL
zetDebugReadMemory(zet_debug_session_handle_t hDebug,ze_device_thread_t thread,const zet_debug_memory_space_desc_t * desc,size_t size,void * buffer)231 zetDebugReadMemory(
232 zet_debug_session_handle_t hDebug, ///< [in] debug session handle
233 ze_device_thread_t thread, ///< [in] the thread identifier.
234 const zet_debug_memory_space_desc_t* desc, ///< [in] memory space descriptor
235 size_t size, ///< [in] the number of bytes to read
236 void* buffer ///< [in,out] a buffer to hold a copy of the memory
237 )
238 {
239 auto pfnReadMemory = context.zetDdiTable.Debug.pfnReadMemory;
240
241 if( nullptr == pfnReadMemory )
242 return ZE_RESULT_ERROR_UNINITIALIZED;
243
244 if( context.enableParameterValidation )
245 {
246 if( nullptr == hDebug )
247 return ZE_RESULT_ERROR_INVALID_NULL_HANDLE;
248
249 if( nullptr == desc )
250 return ZE_RESULT_ERROR_INVALID_NULL_POINTER;
251
252 if( nullptr == buffer )
253 return ZE_RESULT_ERROR_INVALID_NULL_POINTER;
254
255 if( ZET_DEBUG_MEMORY_SPACE_TYPE_SLM < desc->type )
256 return ZE_RESULT_ERROR_INVALID_ENUMERATION;
257
258 }
259
260 return pfnReadMemory( hDebug, thread, desc, size, buffer );
261 }
262
263 ///////////////////////////////////////////////////////////////////////////////
264 /// @brief Intercept function for zetDebugWriteMemory
265 __zedlllocal ze_result_t ZE_APICALL
zetDebugWriteMemory(zet_debug_session_handle_t hDebug,ze_device_thread_t thread,const zet_debug_memory_space_desc_t * desc,size_t size,const void * buffer)266 zetDebugWriteMemory(
267 zet_debug_session_handle_t hDebug, ///< [in] debug session handle
268 ze_device_thread_t thread, ///< [in] the thread identifier.
269 const zet_debug_memory_space_desc_t* desc, ///< [in] memory space descriptor
270 size_t size, ///< [in] the number of bytes to write
271 const void* buffer ///< [in] a buffer holding the pattern to write
272 )
273 {
274 auto pfnWriteMemory = context.zetDdiTable.Debug.pfnWriteMemory;
275
276 if( nullptr == pfnWriteMemory )
277 return ZE_RESULT_ERROR_UNINITIALIZED;
278
279 if( context.enableParameterValidation )
280 {
281 if( nullptr == hDebug )
282 return ZE_RESULT_ERROR_INVALID_NULL_HANDLE;
283
284 if( nullptr == desc )
285 return ZE_RESULT_ERROR_INVALID_NULL_POINTER;
286
287 if( nullptr == buffer )
288 return ZE_RESULT_ERROR_INVALID_NULL_POINTER;
289
290 if( ZET_DEBUG_MEMORY_SPACE_TYPE_SLM < desc->type )
291 return ZE_RESULT_ERROR_INVALID_ENUMERATION;
292
293 }
294
295 return pfnWriteMemory( hDebug, thread, desc, size, buffer );
296 }
297
298 ///////////////////////////////////////////////////////////////////////////////
299 /// @brief Intercept function for zetDebugGetRegisterSetProperties
300 __zedlllocal ze_result_t ZE_APICALL
zetDebugGetRegisterSetProperties(zet_device_handle_t hDevice,uint32_t * pCount,zet_debug_regset_properties_t * pRegisterSetProperties)301 zetDebugGetRegisterSetProperties(
302 zet_device_handle_t hDevice, ///< [in] device handle
303 uint32_t* pCount, ///< [in,out] pointer to the number of register set properties.
304 ///< if count is zero, then the driver shall update the value with the
305 ///< total number of register set properties available.
306 ///< if count is greater than the number of register set properties
307 ///< available, then the driver shall update the value with the correct
308 ///< number of registry set properties available.
309 zet_debug_regset_properties_t* pRegisterSetProperties ///< [in,out][optional][range(0, *pCount)] array of query results for
310 ///< register set properties.
311 ///< if count is less than the number of register set properties available,
312 ///< then driver shall only retrieve that number of register set properties.
313 )
314 {
315 auto pfnGetRegisterSetProperties = context.zetDdiTable.Debug.pfnGetRegisterSetProperties;
316
317 if( nullptr == pfnGetRegisterSetProperties )
318 return ZE_RESULT_ERROR_UNINITIALIZED;
319
320 if( context.enableParameterValidation )
321 {
322 if( nullptr == hDevice )
323 return ZE_RESULT_ERROR_INVALID_NULL_HANDLE;
324
325 if( nullptr == pCount )
326 return ZE_RESULT_ERROR_INVALID_NULL_POINTER;
327
328 }
329
330 return pfnGetRegisterSetProperties( hDevice, pCount, pRegisterSetProperties );
331 }
332
333 ///////////////////////////////////////////////////////////////////////////////
334 /// @brief Intercept function for zetDebugReadRegisters
335 __zedlllocal ze_result_t ZE_APICALL
zetDebugReadRegisters(zet_debug_session_handle_t hDebug,ze_device_thread_t thread,uint32_t type,uint32_t start,uint32_t count,void * pRegisterValues)336 zetDebugReadRegisters(
337 zet_debug_session_handle_t hDebug, ///< [in] debug session handle
338 ze_device_thread_t thread, ///< [in] the thread identifier
339 uint32_t type, ///< [in] register set type
340 uint32_t start, ///< [in] the starting offset into the register state area; must be less
341 ///< than ::zet_debug_regset_properties_t.count for the type
342 uint32_t count, ///< [in] the number of registers to read; start+count must be <=
343 ///< zet_debug_register_group_properties_t.count for the type
344 void* pRegisterValues ///< [in,out][optional][range(0, count)] buffer of register values
345 )
346 {
347 auto pfnReadRegisters = context.zetDdiTable.Debug.pfnReadRegisters;
348
349 if( nullptr == pfnReadRegisters )
350 return ZE_RESULT_ERROR_UNINITIALIZED;
351
352 if( context.enableParameterValidation )
353 {
354 if( nullptr == hDebug )
355 return ZE_RESULT_ERROR_INVALID_NULL_HANDLE;
356
357 }
358
359 return pfnReadRegisters( hDebug, thread, type, start, count, pRegisterValues );
360 }
361
362 ///////////////////////////////////////////////////////////////////////////////
363 /// @brief Intercept function for zetDebugWriteRegisters
364 __zedlllocal ze_result_t ZE_APICALL
zetDebugWriteRegisters(zet_debug_session_handle_t hDebug,ze_device_thread_t thread,uint32_t type,uint32_t start,uint32_t count,void * pRegisterValues)365 zetDebugWriteRegisters(
366 zet_debug_session_handle_t hDebug, ///< [in] debug session handle
367 ze_device_thread_t thread, ///< [in] the thread identifier
368 uint32_t type, ///< [in] register set type
369 uint32_t start, ///< [in] the starting offset into the register state area; must be less
370 ///< than ::zet_debug_regset_properties_t.count for the type
371 uint32_t count, ///< [in] the number of registers to write; start+count must be <=
372 ///< zet_debug_register_group_properties_t.count for the type
373 void* pRegisterValues ///< [in,out][optional][range(0, count)] buffer of register values
374 )
375 {
376 auto pfnWriteRegisters = context.zetDdiTable.Debug.pfnWriteRegisters;
377
378 if( nullptr == pfnWriteRegisters )
379 return ZE_RESULT_ERROR_UNINITIALIZED;
380
381 if( context.enableParameterValidation )
382 {
383 if( nullptr == hDebug )
384 return ZE_RESULT_ERROR_INVALID_NULL_HANDLE;
385
386 }
387
388 return pfnWriteRegisters( hDebug, thread, type, start, count, pRegisterValues );
389 }
390
391 ///////////////////////////////////////////////////////////////////////////////
392 /// @brief Intercept function for zetMetricGroupGet
393 __zedlllocal ze_result_t ZE_APICALL
zetMetricGroupGet(zet_device_handle_t hDevice,uint32_t * pCount,zet_metric_group_handle_t * phMetricGroups)394 zetMetricGroupGet(
395 zet_device_handle_t hDevice, ///< [in] handle of the device
396 uint32_t* pCount, ///< [in,out] pointer to the number of metric groups.
397 ///< if count is zero, then the driver shall update the value with the
398 ///< total number of metric groups available.
399 ///< if count is greater than the number of metric groups available, then
400 ///< the driver shall update the value with the correct number of metric
401 ///< groups available.
402 zet_metric_group_handle_t* phMetricGroups ///< [in,out][optional][range(0, *pCount)] array of handle of metric groups.
403 ///< if count is less than the number of metric groups available, then
404 ///< driver shall only retrieve that number of metric groups.
405 )
406 {
407 auto pfnGet = context.zetDdiTable.MetricGroup.pfnGet;
408
409 if( nullptr == pfnGet )
410 return ZE_RESULT_ERROR_UNINITIALIZED;
411
412 if( context.enableParameterValidation )
413 {
414 if( nullptr == hDevice )
415 return ZE_RESULT_ERROR_INVALID_NULL_HANDLE;
416
417 if( nullptr == pCount )
418 return ZE_RESULT_ERROR_INVALID_NULL_POINTER;
419
420 }
421
422 return pfnGet( hDevice, pCount, phMetricGroups );
423 }
424
425 ///////////////////////////////////////////////////////////////////////////////
426 /// @brief Intercept function for zetMetricGroupGetProperties
427 __zedlllocal ze_result_t ZE_APICALL
zetMetricGroupGetProperties(zet_metric_group_handle_t hMetricGroup,zet_metric_group_properties_t * pProperties)428 zetMetricGroupGetProperties(
429 zet_metric_group_handle_t hMetricGroup, ///< [in] handle of the metric group
430 zet_metric_group_properties_t* pProperties ///< [in,out] metric group properties
431 )
432 {
433 auto pfnGetProperties = context.zetDdiTable.MetricGroup.pfnGetProperties;
434
435 if( nullptr == pfnGetProperties )
436 return ZE_RESULT_ERROR_UNINITIALIZED;
437
438 if( context.enableParameterValidation )
439 {
440 if( nullptr == hMetricGroup )
441 return ZE_RESULT_ERROR_INVALID_NULL_HANDLE;
442
443 if( nullptr == pProperties )
444 return ZE_RESULT_ERROR_INVALID_NULL_POINTER;
445
446 }
447
448 return pfnGetProperties( hMetricGroup, pProperties );
449 }
450
451 ///////////////////////////////////////////////////////////////////////////////
452 /// @brief Intercept function for zetMetricGroupCalculateMetricValues
453 __zedlllocal ze_result_t ZE_APICALL
zetMetricGroupCalculateMetricValues(zet_metric_group_handle_t hMetricGroup,zet_metric_group_calculation_type_t type,size_t rawDataSize,const uint8_t * pRawData,uint32_t * pMetricValueCount,zet_typed_value_t * pMetricValues)454 zetMetricGroupCalculateMetricValues(
455 zet_metric_group_handle_t hMetricGroup, ///< [in] handle of the metric group
456 zet_metric_group_calculation_type_t type, ///< [in] calculation type to be applied on raw data
457 size_t rawDataSize, ///< [in] size in bytes of raw data buffer
458 const uint8_t* pRawData, ///< [in][range(0, rawDataSize)] buffer of raw data to calculate
459 uint32_t* pMetricValueCount, ///< [in,out] pointer to number of metric values calculated.
460 ///< if count is zero, then the driver shall update the value with the
461 ///< total number of metric values to be calculated.
462 ///< if count is greater than the number available in the raw data buffer,
463 ///< then the driver shall update the value with the actual number of
464 ///< metric values to be calculated.
465 zet_typed_value_t* pMetricValues ///< [in,out][optional][range(0, *pMetricValueCount)] buffer of calculated metrics.
466 ///< if count is less than the number available in the raw data buffer,
467 ///< then driver shall only calculate that number of metric values.
468 )
469 {
470 auto pfnCalculateMetricValues = context.zetDdiTable.MetricGroup.pfnCalculateMetricValues;
471
472 if( nullptr == pfnCalculateMetricValues )
473 return ZE_RESULT_ERROR_UNINITIALIZED;
474
475 if( context.enableParameterValidation )
476 {
477 if( nullptr == hMetricGroup )
478 return ZE_RESULT_ERROR_INVALID_NULL_HANDLE;
479
480 if( ZET_METRIC_GROUP_CALCULATION_TYPE_MAX_METRIC_VALUES < type )
481 return ZE_RESULT_ERROR_INVALID_ENUMERATION;
482
483 if( nullptr == pRawData )
484 return ZE_RESULT_ERROR_INVALID_NULL_POINTER;
485
486 if( nullptr == pMetricValueCount )
487 return ZE_RESULT_ERROR_INVALID_NULL_POINTER;
488
489 }
490
491 return pfnCalculateMetricValues( hMetricGroup, type, rawDataSize, pRawData, pMetricValueCount, pMetricValues );
492 }
493
494 ///////////////////////////////////////////////////////////////////////////////
495 /// @brief Intercept function for zetMetricGet
496 __zedlllocal ze_result_t ZE_APICALL
zetMetricGet(zet_metric_group_handle_t hMetricGroup,uint32_t * pCount,zet_metric_handle_t * phMetrics)497 zetMetricGet(
498 zet_metric_group_handle_t hMetricGroup, ///< [in] handle of the metric group
499 uint32_t* pCount, ///< [in,out] pointer to the number of metrics.
500 ///< if count is zero, then the driver shall update the value with the
501 ///< total number of metrics available.
502 ///< if count is greater than the number of metrics available, then the
503 ///< driver shall update the value with the correct number of metrics available.
504 zet_metric_handle_t* phMetrics ///< [in,out][optional][range(0, *pCount)] array of handle of metrics.
505 ///< if count is less than the number of metrics available, then driver
506 ///< shall only retrieve that number of metrics.
507 )
508 {
509 auto pfnGet = context.zetDdiTable.Metric.pfnGet;
510
511 if( nullptr == pfnGet )
512 return ZE_RESULT_ERROR_UNINITIALIZED;
513
514 if( context.enableParameterValidation )
515 {
516 if( nullptr == hMetricGroup )
517 return ZE_RESULT_ERROR_INVALID_NULL_HANDLE;
518
519 if( nullptr == pCount )
520 return ZE_RESULT_ERROR_INVALID_NULL_POINTER;
521
522 }
523
524 return pfnGet( hMetricGroup, pCount, phMetrics );
525 }
526
527 ///////////////////////////////////////////////////////////////////////////////
528 /// @brief Intercept function for zetMetricGetProperties
529 __zedlllocal ze_result_t ZE_APICALL
zetMetricGetProperties(zet_metric_handle_t hMetric,zet_metric_properties_t * pProperties)530 zetMetricGetProperties(
531 zet_metric_handle_t hMetric, ///< [in] handle of the metric
532 zet_metric_properties_t* pProperties ///< [in,out] metric properties
533 )
534 {
535 auto pfnGetProperties = context.zetDdiTable.Metric.pfnGetProperties;
536
537 if( nullptr == pfnGetProperties )
538 return ZE_RESULT_ERROR_UNINITIALIZED;
539
540 if( context.enableParameterValidation )
541 {
542 if( nullptr == hMetric )
543 return ZE_RESULT_ERROR_INVALID_NULL_HANDLE;
544
545 if( nullptr == pProperties )
546 return ZE_RESULT_ERROR_INVALID_NULL_POINTER;
547
548 }
549
550 return pfnGetProperties( hMetric, pProperties );
551 }
552
553 ///////////////////////////////////////////////////////////////////////////////
554 /// @brief Intercept function for zetContextActivateMetricGroups
555 __zedlllocal ze_result_t ZE_APICALL
zetContextActivateMetricGroups(zet_context_handle_t hContext,zet_device_handle_t hDevice,uint32_t count,zet_metric_group_handle_t * phMetricGroups)556 zetContextActivateMetricGroups(
557 zet_context_handle_t hContext, ///< [in] handle of the context object
558 zet_device_handle_t hDevice, ///< [in] handle of the device
559 uint32_t count, ///< [in] metric group count to activate; must be 0 if `nullptr ==
560 ///< phMetricGroups`
561 zet_metric_group_handle_t* phMetricGroups ///< [in][optional][range(0, count)] handles of the metric groups to activate.
562 ///< nullptr deactivates all previously used metric groups.
563 ///< all metrics groups must come from a different domains.
564 ///< metric query and metric stream must use activated metric groups.
565 )
566 {
567 auto pfnActivateMetricGroups = context.zetDdiTable.Context.pfnActivateMetricGroups;
568
569 if( nullptr == pfnActivateMetricGroups )
570 return ZE_RESULT_ERROR_UNINITIALIZED;
571
572 if( context.enableParameterValidation )
573 {
574 if( nullptr == hContext )
575 return ZE_RESULT_ERROR_INVALID_NULL_HANDLE;
576
577 if( nullptr == hDevice )
578 return ZE_RESULT_ERROR_INVALID_NULL_HANDLE;
579
580 if( (nullptr == phMetricGroups) && (0 < count) )
581 return ZE_RESULT_ERROR_INVALID_SIZE;
582
583 }
584
585 return pfnActivateMetricGroups( hContext, hDevice, count, phMetricGroups );
586 }
587
588 ///////////////////////////////////////////////////////////////////////////////
589 /// @brief Intercept function for zetMetricStreamerOpen
590 __zedlllocal ze_result_t ZE_APICALL
zetMetricStreamerOpen(zet_context_handle_t hContext,zet_device_handle_t hDevice,zet_metric_group_handle_t hMetricGroup,zet_metric_streamer_desc_t * desc,ze_event_handle_t hNotificationEvent,zet_metric_streamer_handle_t * phMetricStreamer)591 zetMetricStreamerOpen(
592 zet_context_handle_t hContext, ///< [in] handle of the context object
593 zet_device_handle_t hDevice, ///< [in] handle of the device
594 zet_metric_group_handle_t hMetricGroup, ///< [in] handle of the metric group
595 zet_metric_streamer_desc_t* desc, ///< [in,out] metric streamer descriptor
596 ze_event_handle_t hNotificationEvent, ///< [in][optional] event used for report availability notification
597 zet_metric_streamer_handle_t* phMetricStreamer ///< [out] handle of metric streamer
598 )
599 {
600 auto pfnOpen = context.zetDdiTable.MetricStreamer.pfnOpen;
601
602 if( nullptr == pfnOpen )
603 return ZE_RESULT_ERROR_UNINITIALIZED;
604
605 if( context.enableParameterValidation )
606 {
607 if( nullptr == hContext )
608 return ZE_RESULT_ERROR_INVALID_NULL_HANDLE;
609
610 if( nullptr == hDevice )
611 return ZE_RESULT_ERROR_INVALID_NULL_HANDLE;
612
613 if( nullptr == hMetricGroup )
614 return ZE_RESULT_ERROR_INVALID_NULL_HANDLE;
615
616 if( nullptr == desc )
617 return ZE_RESULT_ERROR_INVALID_NULL_POINTER;
618
619 if( nullptr == phMetricStreamer )
620 return ZE_RESULT_ERROR_INVALID_NULL_POINTER;
621
622 }
623
624 return pfnOpen( hContext, hDevice, hMetricGroup, desc, hNotificationEvent, phMetricStreamer );
625 }
626
627 ///////////////////////////////////////////////////////////////////////////////
628 /// @brief Intercept function for zetCommandListAppendMetricStreamerMarker
629 __zedlllocal ze_result_t ZE_APICALL
zetCommandListAppendMetricStreamerMarker(zet_command_list_handle_t hCommandList,zet_metric_streamer_handle_t hMetricStreamer,uint32_t value)630 zetCommandListAppendMetricStreamerMarker(
631 zet_command_list_handle_t hCommandList, ///< [in] handle of the command list
632 zet_metric_streamer_handle_t hMetricStreamer, ///< [in] handle of the metric streamer
633 uint32_t value ///< [in] streamer marker value
634 )
635 {
636 auto pfnAppendMetricStreamerMarker = context.zetDdiTable.CommandList.pfnAppendMetricStreamerMarker;
637
638 if( nullptr == pfnAppendMetricStreamerMarker )
639 return ZE_RESULT_ERROR_UNINITIALIZED;
640
641 if( context.enableParameterValidation )
642 {
643 if( nullptr == hCommandList )
644 return ZE_RESULT_ERROR_INVALID_NULL_HANDLE;
645
646 if( nullptr == hMetricStreamer )
647 return ZE_RESULT_ERROR_INVALID_NULL_HANDLE;
648
649 }
650
651 return pfnAppendMetricStreamerMarker( hCommandList, hMetricStreamer, value );
652 }
653
654 ///////////////////////////////////////////////////////////////////////////////
655 /// @brief Intercept function for zetMetricStreamerClose
656 __zedlllocal ze_result_t ZE_APICALL
zetMetricStreamerClose(zet_metric_streamer_handle_t hMetricStreamer)657 zetMetricStreamerClose(
658 zet_metric_streamer_handle_t hMetricStreamer ///< [in][release] handle of the metric streamer
659 )
660 {
661 auto pfnClose = context.zetDdiTable.MetricStreamer.pfnClose;
662
663 if( nullptr == pfnClose )
664 return ZE_RESULT_ERROR_UNINITIALIZED;
665
666 if( context.enableParameterValidation )
667 {
668 if( nullptr == hMetricStreamer )
669 return ZE_RESULT_ERROR_INVALID_NULL_HANDLE;
670
671 }
672
673 return pfnClose( hMetricStreamer );
674 }
675
676 ///////////////////////////////////////////////////////////////////////////////
677 /// @brief Intercept function for zetMetricStreamerReadData
678 __zedlllocal ze_result_t ZE_APICALL
zetMetricStreamerReadData(zet_metric_streamer_handle_t hMetricStreamer,uint32_t maxReportCount,size_t * pRawDataSize,uint8_t * pRawData)679 zetMetricStreamerReadData(
680 zet_metric_streamer_handle_t hMetricStreamer, ///< [in] handle of the metric streamer
681 uint32_t maxReportCount, ///< [in] the maximum number of reports the application wants to receive.
682 ///< if UINT32_MAX, then function will retrieve all reports available
683 size_t* pRawDataSize, ///< [in,out] pointer to size in bytes of raw data requested to read.
684 ///< if size is zero, then the driver will update the value with the total
685 ///< size in bytes needed for all reports available.
686 ///< if size is non-zero, then driver will only retrieve the number of
687 ///< reports that fit into the buffer.
688 ///< if size is larger than size needed for all reports, then driver will
689 ///< update the value with the actual size needed.
690 uint8_t* pRawData ///< [in,out][optional][range(0, *pRawDataSize)] buffer containing streamer
691 ///< reports in raw format
692 )
693 {
694 auto pfnReadData = context.zetDdiTable.MetricStreamer.pfnReadData;
695
696 if( nullptr == pfnReadData )
697 return ZE_RESULT_ERROR_UNINITIALIZED;
698
699 if( context.enableParameterValidation )
700 {
701 if( nullptr == hMetricStreamer )
702 return ZE_RESULT_ERROR_INVALID_NULL_HANDLE;
703
704 if( nullptr == pRawDataSize )
705 return ZE_RESULT_ERROR_INVALID_NULL_POINTER;
706
707 }
708
709 return pfnReadData( hMetricStreamer, maxReportCount, pRawDataSize, pRawData );
710 }
711
712 ///////////////////////////////////////////////////////////////////////////////
713 /// @brief Intercept function for zetMetricQueryPoolCreate
714 __zedlllocal ze_result_t ZE_APICALL
zetMetricQueryPoolCreate(zet_context_handle_t hContext,zet_device_handle_t hDevice,zet_metric_group_handle_t hMetricGroup,const zet_metric_query_pool_desc_t * desc,zet_metric_query_pool_handle_t * phMetricQueryPool)715 zetMetricQueryPoolCreate(
716 zet_context_handle_t hContext, ///< [in] handle of the context object
717 zet_device_handle_t hDevice, ///< [in] handle of the device
718 zet_metric_group_handle_t hMetricGroup, ///< [in] metric group associated with the query object.
719 const zet_metric_query_pool_desc_t* desc, ///< [in] metric query pool descriptor
720 zet_metric_query_pool_handle_t* phMetricQueryPool ///< [out] handle of metric query pool
721 )
722 {
723 auto pfnCreate = context.zetDdiTable.MetricQueryPool.pfnCreate;
724
725 if( nullptr == pfnCreate )
726 return ZE_RESULT_ERROR_UNINITIALIZED;
727
728 if( context.enableParameterValidation )
729 {
730 if( nullptr == hContext )
731 return ZE_RESULT_ERROR_INVALID_NULL_HANDLE;
732
733 if( nullptr == hDevice )
734 return ZE_RESULT_ERROR_INVALID_NULL_HANDLE;
735
736 if( nullptr == hMetricGroup )
737 return ZE_RESULT_ERROR_INVALID_NULL_HANDLE;
738
739 if( nullptr == desc )
740 return ZE_RESULT_ERROR_INVALID_NULL_POINTER;
741
742 if( nullptr == phMetricQueryPool )
743 return ZE_RESULT_ERROR_INVALID_NULL_POINTER;
744
745 if( ZET_METRIC_QUERY_POOL_TYPE_EXECUTION < desc->type )
746 return ZE_RESULT_ERROR_INVALID_ENUMERATION;
747
748 }
749
750 return pfnCreate( hContext, hDevice, hMetricGroup, desc, phMetricQueryPool );
751 }
752
753 ///////////////////////////////////////////////////////////////////////////////
754 /// @brief Intercept function for zetMetricQueryPoolDestroy
755 __zedlllocal ze_result_t ZE_APICALL
zetMetricQueryPoolDestroy(zet_metric_query_pool_handle_t hMetricQueryPool)756 zetMetricQueryPoolDestroy(
757 zet_metric_query_pool_handle_t hMetricQueryPool ///< [in][release] handle of the metric query pool
758 )
759 {
760 auto pfnDestroy = context.zetDdiTable.MetricQueryPool.pfnDestroy;
761
762 if( nullptr == pfnDestroy )
763 return ZE_RESULT_ERROR_UNINITIALIZED;
764
765 if( context.enableParameterValidation )
766 {
767 if( nullptr == hMetricQueryPool )
768 return ZE_RESULT_ERROR_INVALID_NULL_HANDLE;
769
770 }
771
772 return pfnDestroy( hMetricQueryPool );
773 }
774
775 ///////////////////////////////////////////////////////////////////////////////
776 /// @brief Intercept function for zetMetricQueryCreate
777 __zedlllocal ze_result_t ZE_APICALL
zetMetricQueryCreate(zet_metric_query_pool_handle_t hMetricQueryPool,uint32_t index,zet_metric_query_handle_t * phMetricQuery)778 zetMetricQueryCreate(
779 zet_metric_query_pool_handle_t hMetricQueryPool,///< [in] handle of the metric query pool
780 uint32_t index, ///< [in] index of the query within the pool
781 zet_metric_query_handle_t* phMetricQuery ///< [out] handle of metric query
782 )
783 {
784 auto pfnCreate = context.zetDdiTable.MetricQuery.pfnCreate;
785
786 if( nullptr == pfnCreate )
787 return ZE_RESULT_ERROR_UNINITIALIZED;
788
789 if( context.enableParameterValidation )
790 {
791 if( nullptr == hMetricQueryPool )
792 return ZE_RESULT_ERROR_INVALID_NULL_HANDLE;
793
794 if( nullptr == phMetricQuery )
795 return ZE_RESULT_ERROR_INVALID_NULL_POINTER;
796
797 }
798
799 return pfnCreate( hMetricQueryPool, index, phMetricQuery );
800 }
801
802 ///////////////////////////////////////////////////////////////////////////////
803 /// @brief Intercept function for zetMetricQueryDestroy
804 __zedlllocal ze_result_t ZE_APICALL
zetMetricQueryDestroy(zet_metric_query_handle_t hMetricQuery)805 zetMetricQueryDestroy(
806 zet_metric_query_handle_t hMetricQuery ///< [in][release] handle of metric query
807 )
808 {
809 auto pfnDestroy = context.zetDdiTable.MetricQuery.pfnDestroy;
810
811 if( nullptr == pfnDestroy )
812 return ZE_RESULT_ERROR_UNINITIALIZED;
813
814 if( context.enableParameterValidation )
815 {
816 if( nullptr == hMetricQuery )
817 return ZE_RESULT_ERROR_INVALID_NULL_HANDLE;
818
819 }
820
821 return pfnDestroy( hMetricQuery );
822 }
823
824 ///////////////////////////////////////////////////////////////////////////////
825 /// @brief Intercept function for zetMetricQueryReset
826 __zedlllocal ze_result_t ZE_APICALL
zetMetricQueryReset(zet_metric_query_handle_t hMetricQuery)827 zetMetricQueryReset(
828 zet_metric_query_handle_t hMetricQuery ///< [in] handle of metric query
829 )
830 {
831 auto pfnReset = context.zetDdiTable.MetricQuery.pfnReset;
832
833 if( nullptr == pfnReset )
834 return ZE_RESULT_ERROR_UNINITIALIZED;
835
836 if( context.enableParameterValidation )
837 {
838 if( nullptr == hMetricQuery )
839 return ZE_RESULT_ERROR_INVALID_NULL_HANDLE;
840
841 }
842
843 return pfnReset( hMetricQuery );
844 }
845
846 ///////////////////////////////////////////////////////////////////////////////
847 /// @brief Intercept function for zetCommandListAppendMetricQueryBegin
848 __zedlllocal ze_result_t ZE_APICALL
zetCommandListAppendMetricQueryBegin(zet_command_list_handle_t hCommandList,zet_metric_query_handle_t hMetricQuery)849 zetCommandListAppendMetricQueryBegin(
850 zet_command_list_handle_t hCommandList, ///< [in] handle of the command list
851 zet_metric_query_handle_t hMetricQuery ///< [in] handle of the metric query
852 )
853 {
854 auto pfnAppendMetricQueryBegin = context.zetDdiTable.CommandList.pfnAppendMetricQueryBegin;
855
856 if( nullptr == pfnAppendMetricQueryBegin )
857 return ZE_RESULT_ERROR_UNINITIALIZED;
858
859 if( context.enableParameterValidation )
860 {
861 if( nullptr == hCommandList )
862 return ZE_RESULT_ERROR_INVALID_NULL_HANDLE;
863
864 if( nullptr == hMetricQuery )
865 return ZE_RESULT_ERROR_INVALID_NULL_HANDLE;
866
867 }
868
869 return pfnAppendMetricQueryBegin( hCommandList, hMetricQuery );
870 }
871
872 ///////////////////////////////////////////////////////////////////////////////
873 /// @brief Intercept function for zetCommandListAppendMetricQueryEnd
874 __zedlllocal ze_result_t ZE_APICALL
zetCommandListAppendMetricQueryEnd(zet_command_list_handle_t hCommandList,zet_metric_query_handle_t hMetricQuery,ze_event_handle_t hSignalEvent,uint32_t numWaitEvents,ze_event_handle_t * phWaitEvents)875 zetCommandListAppendMetricQueryEnd(
876 zet_command_list_handle_t hCommandList, ///< [in] handle of the command list
877 zet_metric_query_handle_t hMetricQuery, ///< [in] handle of the metric query
878 ze_event_handle_t hSignalEvent, ///< [in][optional] handle of the event to signal on completion
879 uint32_t numWaitEvents, ///< [in] must be zero
880 ze_event_handle_t* phWaitEvents ///< [in][mbz] must be nullptr
881 )
882 {
883 auto pfnAppendMetricQueryEnd = context.zetDdiTable.CommandList.pfnAppendMetricQueryEnd;
884
885 if( nullptr == pfnAppendMetricQueryEnd )
886 return ZE_RESULT_ERROR_UNINITIALIZED;
887
888 if( context.enableParameterValidation )
889 {
890 if( nullptr == hCommandList )
891 return ZE_RESULT_ERROR_INVALID_NULL_HANDLE;
892
893 if( nullptr == hMetricQuery )
894 return ZE_RESULT_ERROR_INVALID_NULL_HANDLE;
895
896 if( nullptr == phWaitEvents )
897 return ZE_RESULT_ERROR_INVALID_NULL_POINTER;
898
899 if( (nullptr == phWaitEvents) && (0 < numWaitEvents) )
900 return ZE_RESULT_ERROR_INVALID_SIZE;
901
902 }
903
904 return pfnAppendMetricQueryEnd( hCommandList, hMetricQuery, hSignalEvent, numWaitEvents, phWaitEvents );
905 }
906
907 ///////////////////////////////////////////////////////////////////////////////
908 /// @brief Intercept function for zetCommandListAppendMetricMemoryBarrier
909 __zedlllocal ze_result_t ZE_APICALL
zetCommandListAppendMetricMemoryBarrier(zet_command_list_handle_t hCommandList)910 zetCommandListAppendMetricMemoryBarrier(
911 zet_command_list_handle_t hCommandList ///< [in] handle of the command list
912 )
913 {
914 auto pfnAppendMetricMemoryBarrier = context.zetDdiTable.CommandList.pfnAppendMetricMemoryBarrier;
915
916 if( nullptr == pfnAppendMetricMemoryBarrier )
917 return ZE_RESULT_ERROR_UNINITIALIZED;
918
919 if( context.enableParameterValidation )
920 {
921 if( nullptr == hCommandList )
922 return ZE_RESULT_ERROR_INVALID_NULL_HANDLE;
923
924 }
925
926 return pfnAppendMetricMemoryBarrier( hCommandList );
927 }
928
929 ///////////////////////////////////////////////////////////////////////////////
930 /// @brief Intercept function for zetMetricQueryGetData
931 __zedlllocal ze_result_t ZE_APICALL
zetMetricQueryGetData(zet_metric_query_handle_t hMetricQuery,size_t * pRawDataSize,uint8_t * pRawData)932 zetMetricQueryGetData(
933 zet_metric_query_handle_t hMetricQuery, ///< [in] handle of the metric query
934 size_t* pRawDataSize, ///< [in,out] pointer to size in bytes of raw data requested to read.
935 ///< if size is zero, then the driver will update the value with the total
936 ///< size in bytes needed for all reports available.
937 ///< if size is non-zero, then driver will only retrieve the number of
938 ///< reports that fit into the buffer.
939 ///< if size is larger than size needed for all reports, then driver will
940 ///< update the value with the actual size needed.
941 uint8_t* pRawData ///< [in,out][optional][range(0, *pRawDataSize)] buffer containing query
942 ///< reports in raw format
943 )
944 {
945 auto pfnGetData = context.zetDdiTable.MetricQuery.pfnGetData;
946
947 if( nullptr == pfnGetData )
948 return ZE_RESULT_ERROR_UNINITIALIZED;
949
950 if( context.enableParameterValidation )
951 {
952 if( nullptr == hMetricQuery )
953 return ZE_RESULT_ERROR_INVALID_NULL_HANDLE;
954
955 if( nullptr == pRawDataSize )
956 return ZE_RESULT_ERROR_INVALID_NULL_POINTER;
957
958 }
959
960 return pfnGetData( hMetricQuery, pRawDataSize, pRawData );
961 }
962
963 ///////////////////////////////////////////////////////////////////////////////
964 /// @brief Intercept function for zetKernelGetProfileInfo
965 __zedlllocal ze_result_t ZE_APICALL
zetKernelGetProfileInfo(zet_kernel_handle_t hKernel,zet_profile_properties_t * pProfileProperties)966 zetKernelGetProfileInfo(
967 zet_kernel_handle_t hKernel, ///< [in] handle to kernel
968 zet_profile_properties_t* pProfileProperties ///< [out] pointer to profile properties
969 )
970 {
971 auto pfnGetProfileInfo = context.zetDdiTable.Kernel.pfnGetProfileInfo;
972
973 if( nullptr == pfnGetProfileInfo )
974 return ZE_RESULT_ERROR_UNINITIALIZED;
975
976 if( context.enableParameterValidation )
977 {
978 if( nullptr == hKernel )
979 return ZE_RESULT_ERROR_INVALID_NULL_HANDLE;
980
981 if( nullptr == pProfileProperties )
982 return ZE_RESULT_ERROR_INVALID_NULL_POINTER;
983
984 }
985
986 return pfnGetProfileInfo( hKernel, pProfileProperties );
987 }
988
989 ///////////////////////////////////////////////////////////////////////////////
990 /// @brief Intercept function for zetTracerExpCreate
991 __zedlllocal ze_result_t ZE_APICALL
zetTracerExpCreate(zet_context_handle_t hContext,const zet_tracer_exp_desc_t * desc,zet_tracer_exp_handle_t * phTracer)992 zetTracerExpCreate(
993 zet_context_handle_t hContext, ///< [in] handle of the context object
994 const zet_tracer_exp_desc_t* desc, ///< [in] pointer to tracer descriptor
995 zet_tracer_exp_handle_t* phTracer ///< [out] pointer to handle of tracer object created
996 )
997 {
998 auto pfnCreate = context.zetDdiTable.TracerExp.pfnCreate;
999
1000 if( nullptr == pfnCreate )
1001 return ZE_RESULT_ERROR_UNINITIALIZED;
1002
1003 if( context.enableParameterValidation )
1004 {
1005 if( nullptr == hContext )
1006 return ZE_RESULT_ERROR_INVALID_NULL_HANDLE;
1007
1008 if( nullptr == desc )
1009 return ZE_RESULT_ERROR_INVALID_NULL_POINTER;
1010
1011 if( nullptr == desc->pUserData )
1012 return ZE_RESULT_ERROR_INVALID_NULL_POINTER;
1013
1014 if( nullptr == phTracer )
1015 return ZE_RESULT_ERROR_INVALID_NULL_POINTER;
1016
1017 }
1018
1019 return pfnCreate( hContext, desc, phTracer );
1020 }
1021
1022 ///////////////////////////////////////////////////////////////////////////////
1023 /// @brief Intercept function for zetTracerExpDestroy
1024 __zedlllocal ze_result_t ZE_APICALL
zetTracerExpDestroy(zet_tracer_exp_handle_t hTracer)1025 zetTracerExpDestroy(
1026 zet_tracer_exp_handle_t hTracer ///< [in][release] handle of tracer object to destroy
1027 )
1028 {
1029 auto pfnDestroy = context.zetDdiTable.TracerExp.pfnDestroy;
1030
1031 if( nullptr == pfnDestroy )
1032 return ZE_RESULT_ERROR_UNINITIALIZED;
1033
1034 if( context.enableParameterValidation )
1035 {
1036 if( nullptr == hTracer )
1037 return ZE_RESULT_ERROR_INVALID_NULL_HANDLE;
1038
1039 }
1040
1041 return pfnDestroy( hTracer );
1042 }
1043
1044 ///////////////////////////////////////////////////////////////////////////////
1045 /// @brief Intercept function for zetTracerExpSetPrologues
1046 __zedlllocal ze_result_t ZE_APICALL
zetTracerExpSetPrologues(zet_tracer_exp_handle_t hTracer,zet_core_callbacks_t * pCoreCbs)1047 zetTracerExpSetPrologues(
1048 zet_tracer_exp_handle_t hTracer, ///< [in] handle of the tracer
1049 zet_core_callbacks_t* pCoreCbs ///< [in] pointer to table of 'core' callback function pointers
1050 )
1051 {
1052 auto pfnSetPrologues = context.zetDdiTable.TracerExp.pfnSetPrologues;
1053
1054 if( nullptr == pfnSetPrologues )
1055 return ZE_RESULT_ERROR_UNINITIALIZED;
1056
1057 if( context.enableParameterValidation )
1058 {
1059 if( nullptr == hTracer )
1060 return ZE_RESULT_ERROR_INVALID_NULL_HANDLE;
1061
1062 if( nullptr == pCoreCbs )
1063 return ZE_RESULT_ERROR_INVALID_NULL_POINTER;
1064
1065 }
1066
1067 return pfnSetPrologues( hTracer, pCoreCbs );
1068 }
1069
1070 ///////////////////////////////////////////////////////////////////////////////
1071 /// @brief Intercept function for zetTracerExpSetEpilogues
1072 __zedlllocal ze_result_t ZE_APICALL
zetTracerExpSetEpilogues(zet_tracer_exp_handle_t hTracer,zet_core_callbacks_t * pCoreCbs)1073 zetTracerExpSetEpilogues(
1074 zet_tracer_exp_handle_t hTracer, ///< [in] handle of the tracer
1075 zet_core_callbacks_t* pCoreCbs ///< [in] pointer to table of 'core' callback function pointers
1076 )
1077 {
1078 auto pfnSetEpilogues = context.zetDdiTable.TracerExp.pfnSetEpilogues;
1079
1080 if( nullptr == pfnSetEpilogues )
1081 return ZE_RESULT_ERROR_UNINITIALIZED;
1082
1083 if( context.enableParameterValidation )
1084 {
1085 if( nullptr == hTracer )
1086 return ZE_RESULT_ERROR_INVALID_NULL_HANDLE;
1087
1088 if( nullptr == pCoreCbs )
1089 return ZE_RESULT_ERROR_INVALID_NULL_POINTER;
1090
1091 }
1092
1093 return pfnSetEpilogues( hTracer, pCoreCbs );
1094 }
1095
1096 ///////////////////////////////////////////////////////////////////////////////
1097 /// @brief Intercept function for zetTracerExpSetEnabled
1098 __zedlllocal ze_result_t ZE_APICALL
zetTracerExpSetEnabled(zet_tracer_exp_handle_t hTracer,ze_bool_t enable)1099 zetTracerExpSetEnabled(
1100 zet_tracer_exp_handle_t hTracer, ///< [in] handle of the tracer
1101 ze_bool_t enable ///< [in] enable the tracer if true; disable if false
1102 )
1103 {
1104 auto pfnSetEnabled = context.zetDdiTable.TracerExp.pfnSetEnabled;
1105
1106 if( nullptr == pfnSetEnabled )
1107 return ZE_RESULT_ERROR_UNINITIALIZED;
1108
1109 if( context.enableParameterValidation )
1110 {
1111 if( nullptr == hTracer )
1112 return ZE_RESULT_ERROR_INVALID_NULL_HANDLE;
1113
1114 }
1115
1116 return pfnSetEnabled( hTracer, enable );
1117 }
1118
1119 ///////////////////////////////////////////////////////////////////////////////
1120 /// @brief Intercept function for zetMetricGroupCalculateMultipleMetricValuesExp
1121 __zedlllocal ze_result_t ZE_APICALL
zetMetricGroupCalculateMultipleMetricValuesExp(zet_metric_group_handle_t hMetricGroup,zet_metric_group_calculation_type_t type,size_t rawDataSize,const uint8_t * pRawData,uint32_t * pSetCount,uint32_t * pTotalMetricValueCount,uint32_t * pMetricCounts,zet_typed_value_t * pMetricValues)1122 zetMetricGroupCalculateMultipleMetricValuesExp(
1123 zet_metric_group_handle_t hMetricGroup, ///< [in] handle of the metric group
1124 zet_metric_group_calculation_type_t type, ///< [in] calculation type to be applied on raw data
1125 size_t rawDataSize, ///< [in] size in bytes of raw data buffer
1126 const uint8_t* pRawData, ///< [in][range(0, rawDataSize)] buffer of raw data to calculate
1127 uint32_t* pSetCount, ///< [in,out] pointer to number of metric sets.
1128 ///< if count is zero, then the driver shall update the value with the
1129 ///< total number of metric sets to be calculated.
1130 ///< if count is greater than the number available in the raw data buffer,
1131 ///< then the driver shall update the value with the actual number of
1132 ///< metric sets to be calculated.
1133 uint32_t* pTotalMetricValueCount, ///< [in,out] pointer to number of the total number of metric values
1134 ///< calculated, for all metric sets.
1135 ///< if count is zero, then the driver shall update the value with the
1136 ///< total number of metric values to be calculated.
1137 ///< if count is greater than the number available in the raw data buffer,
1138 ///< then the driver shall update the value with the actual number of
1139 ///< metric values to be calculated.
1140 uint32_t* pMetricCounts, ///< [in,out][optional][range(0, *pSetCount)] buffer of metric counts per
1141 ///< metric set.
1142 zet_typed_value_t* pMetricValues ///< [in,out][optional][range(0, *pTotalMetricValueCount)] buffer of
1143 ///< calculated metrics.
1144 ///< if count is less than the number available in the raw data buffer,
1145 ///< then driver shall only calculate that number of metric values.
1146 )
1147 {
1148 auto pfnCalculateMultipleMetricValuesExp = context.zetDdiTable.MetricGroupExp.pfnCalculateMultipleMetricValuesExp;
1149
1150 if( nullptr == pfnCalculateMultipleMetricValuesExp )
1151 return ZE_RESULT_ERROR_UNINITIALIZED;
1152
1153 if( context.enableParameterValidation )
1154 {
1155 if( nullptr == hMetricGroup )
1156 return ZE_RESULT_ERROR_INVALID_NULL_HANDLE;
1157
1158 if( ZET_METRIC_GROUP_CALCULATION_TYPE_MAX_METRIC_VALUES < type )
1159 return ZE_RESULT_ERROR_INVALID_ENUMERATION;
1160
1161 if( nullptr == pRawData )
1162 return ZE_RESULT_ERROR_INVALID_NULL_POINTER;
1163
1164 if( nullptr == pSetCount )
1165 return ZE_RESULT_ERROR_INVALID_NULL_POINTER;
1166
1167 if( nullptr == pTotalMetricValueCount )
1168 return ZE_RESULT_ERROR_INVALID_NULL_POINTER;
1169
1170 }
1171
1172 return pfnCalculateMultipleMetricValuesExp( hMetricGroup, type, rawDataSize, pRawData, pSetCount, pTotalMetricValueCount, pMetricCounts, pMetricValues );
1173 }
1174
1175 } // namespace validation_layer
1176
1177 #if defined(__cplusplus)
1178 extern "C" {
1179 #endif
1180
1181 ///////////////////////////////////////////////////////////////////////////////
1182 /// @brief Exported function for filling application's Device table
1183 /// with current process' addresses
1184 ///
1185 /// @returns
1186 /// - ::ZE_RESULT_SUCCESS
1187 /// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER
1188 /// - ::ZE_RESULT_ERROR_UNSUPPORTED_VERSION
1189 ZE_DLLEXPORT ze_result_t ZE_APICALL
zetGetDeviceProcAddrTable(ze_api_version_t version,zet_device_dditable_t * pDdiTable)1190 zetGetDeviceProcAddrTable(
1191 ze_api_version_t version, ///< [in] API version requested
1192 zet_device_dditable_t* pDdiTable ///< [in,out] pointer to table of DDI function pointers
1193 )
1194 {
1195 auto& dditable = validation_layer::context.zetDdiTable.Device;
1196
1197 if( nullptr == pDdiTable )
1198 return ZE_RESULT_ERROR_INVALID_NULL_POINTER;
1199
1200 if (ZE_MAJOR_VERSION(validation_layer::context.version) != ZE_MAJOR_VERSION(version) ||
1201 ZE_MINOR_VERSION(validation_layer::context.version) > ZE_MINOR_VERSION(version))
1202 return ZE_RESULT_ERROR_UNSUPPORTED_VERSION;
1203
1204 ze_result_t result = ZE_RESULT_SUCCESS;
1205
1206 dditable.pfnGetDebugProperties = pDdiTable->pfnGetDebugProperties;
1207 pDdiTable->pfnGetDebugProperties = validation_layer::zetDeviceGetDebugProperties;
1208
1209 return result;
1210 }
1211
1212 ///////////////////////////////////////////////////////////////////////////////
1213 /// @brief Exported function for filling application's Context table
1214 /// with current process' addresses
1215 ///
1216 /// @returns
1217 /// - ::ZE_RESULT_SUCCESS
1218 /// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER
1219 /// - ::ZE_RESULT_ERROR_UNSUPPORTED_VERSION
1220 ZE_DLLEXPORT ze_result_t ZE_APICALL
zetGetContextProcAddrTable(ze_api_version_t version,zet_context_dditable_t * pDdiTable)1221 zetGetContextProcAddrTable(
1222 ze_api_version_t version, ///< [in] API version requested
1223 zet_context_dditable_t* pDdiTable ///< [in,out] pointer to table of DDI function pointers
1224 )
1225 {
1226 auto& dditable = validation_layer::context.zetDdiTable.Context;
1227
1228 if( nullptr == pDdiTable )
1229 return ZE_RESULT_ERROR_INVALID_NULL_POINTER;
1230
1231 if (ZE_MAJOR_VERSION(validation_layer::context.version) != ZE_MAJOR_VERSION(version) ||
1232 ZE_MINOR_VERSION(validation_layer::context.version) > ZE_MINOR_VERSION(version))
1233 return ZE_RESULT_ERROR_UNSUPPORTED_VERSION;
1234
1235 ze_result_t result = ZE_RESULT_SUCCESS;
1236
1237 dditable.pfnActivateMetricGroups = pDdiTable->pfnActivateMetricGroups;
1238 pDdiTable->pfnActivateMetricGroups = validation_layer::zetContextActivateMetricGroups;
1239
1240 return result;
1241 }
1242
1243 ///////////////////////////////////////////////////////////////////////////////
1244 /// @brief Exported function for filling application's CommandList table
1245 /// with current process' addresses
1246 ///
1247 /// @returns
1248 /// - ::ZE_RESULT_SUCCESS
1249 /// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER
1250 /// - ::ZE_RESULT_ERROR_UNSUPPORTED_VERSION
1251 ZE_DLLEXPORT ze_result_t ZE_APICALL
zetGetCommandListProcAddrTable(ze_api_version_t version,zet_command_list_dditable_t * pDdiTable)1252 zetGetCommandListProcAddrTable(
1253 ze_api_version_t version, ///< [in] API version requested
1254 zet_command_list_dditable_t* pDdiTable ///< [in,out] pointer to table of DDI function pointers
1255 )
1256 {
1257 auto& dditable = validation_layer::context.zetDdiTable.CommandList;
1258
1259 if( nullptr == pDdiTable )
1260 return ZE_RESULT_ERROR_INVALID_NULL_POINTER;
1261
1262 if (ZE_MAJOR_VERSION(validation_layer::context.version) != ZE_MAJOR_VERSION(version) ||
1263 ZE_MINOR_VERSION(validation_layer::context.version) > ZE_MINOR_VERSION(version))
1264 return ZE_RESULT_ERROR_UNSUPPORTED_VERSION;
1265
1266 ze_result_t result = ZE_RESULT_SUCCESS;
1267
1268 dditable.pfnAppendMetricStreamerMarker = pDdiTable->pfnAppendMetricStreamerMarker;
1269 pDdiTable->pfnAppendMetricStreamerMarker = validation_layer::zetCommandListAppendMetricStreamerMarker;
1270
1271 dditable.pfnAppendMetricQueryBegin = pDdiTable->pfnAppendMetricQueryBegin;
1272 pDdiTable->pfnAppendMetricQueryBegin = validation_layer::zetCommandListAppendMetricQueryBegin;
1273
1274 dditable.pfnAppendMetricQueryEnd = pDdiTable->pfnAppendMetricQueryEnd;
1275 pDdiTable->pfnAppendMetricQueryEnd = validation_layer::zetCommandListAppendMetricQueryEnd;
1276
1277 dditable.pfnAppendMetricMemoryBarrier = pDdiTable->pfnAppendMetricMemoryBarrier;
1278 pDdiTable->pfnAppendMetricMemoryBarrier = validation_layer::zetCommandListAppendMetricMemoryBarrier;
1279
1280 return result;
1281 }
1282
1283 ///////////////////////////////////////////////////////////////////////////////
1284 /// @brief Exported function for filling application's Kernel table
1285 /// with current process' addresses
1286 ///
1287 /// @returns
1288 /// - ::ZE_RESULT_SUCCESS
1289 /// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER
1290 /// - ::ZE_RESULT_ERROR_UNSUPPORTED_VERSION
1291 ZE_DLLEXPORT ze_result_t ZE_APICALL
zetGetKernelProcAddrTable(ze_api_version_t version,zet_kernel_dditable_t * pDdiTable)1292 zetGetKernelProcAddrTable(
1293 ze_api_version_t version, ///< [in] API version requested
1294 zet_kernel_dditable_t* pDdiTable ///< [in,out] pointer to table of DDI function pointers
1295 )
1296 {
1297 auto& dditable = validation_layer::context.zetDdiTable.Kernel;
1298
1299 if( nullptr == pDdiTable )
1300 return ZE_RESULT_ERROR_INVALID_NULL_POINTER;
1301
1302 if (ZE_MAJOR_VERSION(validation_layer::context.version) != ZE_MAJOR_VERSION(version) ||
1303 ZE_MINOR_VERSION(validation_layer::context.version) > ZE_MINOR_VERSION(version))
1304 return ZE_RESULT_ERROR_UNSUPPORTED_VERSION;
1305
1306 ze_result_t result = ZE_RESULT_SUCCESS;
1307
1308 dditable.pfnGetProfileInfo = pDdiTable->pfnGetProfileInfo;
1309 pDdiTable->pfnGetProfileInfo = validation_layer::zetKernelGetProfileInfo;
1310
1311 return result;
1312 }
1313
1314 ///////////////////////////////////////////////////////////////////////////////
1315 /// @brief Exported function for filling application's Module table
1316 /// with current process' addresses
1317 ///
1318 /// @returns
1319 /// - ::ZE_RESULT_SUCCESS
1320 /// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER
1321 /// - ::ZE_RESULT_ERROR_UNSUPPORTED_VERSION
1322 ZE_DLLEXPORT ze_result_t ZE_APICALL
zetGetModuleProcAddrTable(ze_api_version_t version,zet_module_dditable_t * pDdiTable)1323 zetGetModuleProcAddrTable(
1324 ze_api_version_t version, ///< [in] API version requested
1325 zet_module_dditable_t* pDdiTable ///< [in,out] pointer to table of DDI function pointers
1326 )
1327 {
1328 auto& dditable = validation_layer::context.zetDdiTable.Module;
1329
1330 if( nullptr == pDdiTable )
1331 return ZE_RESULT_ERROR_INVALID_NULL_POINTER;
1332
1333 if (ZE_MAJOR_VERSION(validation_layer::context.version) != ZE_MAJOR_VERSION(version) ||
1334 ZE_MINOR_VERSION(validation_layer::context.version) > ZE_MINOR_VERSION(version))
1335 return ZE_RESULT_ERROR_UNSUPPORTED_VERSION;
1336
1337 ze_result_t result = ZE_RESULT_SUCCESS;
1338
1339 dditable.pfnGetDebugInfo = pDdiTable->pfnGetDebugInfo;
1340 pDdiTable->pfnGetDebugInfo = validation_layer::zetModuleGetDebugInfo;
1341
1342 return result;
1343 }
1344
1345 ///////////////////////////////////////////////////////////////////////////////
1346 /// @brief Exported function for filling application's Debug table
1347 /// with current process' addresses
1348 ///
1349 /// @returns
1350 /// - ::ZE_RESULT_SUCCESS
1351 /// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER
1352 /// - ::ZE_RESULT_ERROR_UNSUPPORTED_VERSION
1353 ZE_DLLEXPORT ze_result_t ZE_APICALL
zetGetDebugProcAddrTable(ze_api_version_t version,zet_debug_dditable_t * pDdiTable)1354 zetGetDebugProcAddrTable(
1355 ze_api_version_t version, ///< [in] API version requested
1356 zet_debug_dditable_t* pDdiTable ///< [in,out] pointer to table of DDI function pointers
1357 )
1358 {
1359 auto& dditable = validation_layer::context.zetDdiTable.Debug;
1360
1361 if( nullptr == pDdiTable )
1362 return ZE_RESULT_ERROR_INVALID_NULL_POINTER;
1363
1364 if (ZE_MAJOR_VERSION(validation_layer::context.version) != ZE_MAJOR_VERSION(version) ||
1365 ZE_MINOR_VERSION(validation_layer::context.version) > ZE_MINOR_VERSION(version))
1366 return ZE_RESULT_ERROR_UNSUPPORTED_VERSION;
1367
1368 ze_result_t result = ZE_RESULT_SUCCESS;
1369
1370 dditable.pfnAttach = pDdiTable->pfnAttach;
1371 pDdiTable->pfnAttach = validation_layer::zetDebugAttach;
1372
1373 dditable.pfnDetach = pDdiTable->pfnDetach;
1374 pDdiTable->pfnDetach = validation_layer::zetDebugDetach;
1375
1376 dditable.pfnReadEvent = pDdiTable->pfnReadEvent;
1377 pDdiTable->pfnReadEvent = validation_layer::zetDebugReadEvent;
1378
1379 dditable.pfnAcknowledgeEvent = pDdiTable->pfnAcknowledgeEvent;
1380 pDdiTable->pfnAcknowledgeEvent = validation_layer::zetDebugAcknowledgeEvent;
1381
1382 dditable.pfnInterrupt = pDdiTable->pfnInterrupt;
1383 pDdiTable->pfnInterrupt = validation_layer::zetDebugInterrupt;
1384
1385 dditable.pfnResume = pDdiTable->pfnResume;
1386 pDdiTable->pfnResume = validation_layer::zetDebugResume;
1387
1388 dditable.pfnReadMemory = pDdiTable->pfnReadMemory;
1389 pDdiTable->pfnReadMemory = validation_layer::zetDebugReadMemory;
1390
1391 dditable.pfnWriteMemory = pDdiTable->pfnWriteMemory;
1392 pDdiTable->pfnWriteMemory = validation_layer::zetDebugWriteMemory;
1393
1394 dditable.pfnGetRegisterSetProperties = pDdiTable->pfnGetRegisterSetProperties;
1395 pDdiTable->pfnGetRegisterSetProperties = validation_layer::zetDebugGetRegisterSetProperties;
1396
1397 dditable.pfnReadRegisters = pDdiTable->pfnReadRegisters;
1398 pDdiTable->pfnReadRegisters = validation_layer::zetDebugReadRegisters;
1399
1400 dditable.pfnWriteRegisters = pDdiTable->pfnWriteRegisters;
1401 pDdiTable->pfnWriteRegisters = validation_layer::zetDebugWriteRegisters;
1402
1403 return result;
1404 }
1405
1406 ///////////////////////////////////////////////////////////////////////////////
1407 /// @brief Exported function for filling application's Metric table
1408 /// with current process' addresses
1409 ///
1410 /// @returns
1411 /// - ::ZE_RESULT_SUCCESS
1412 /// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER
1413 /// - ::ZE_RESULT_ERROR_UNSUPPORTED_VERSION
1414 ZE_DLLEXPORT ze_result_t ZE_APICALL
zetGetMetricProcAddrTable(ze_api_version_t version,zet_metric_dditable_t * pDdiTable)1415 zetGetMetricProcAddrTable(
1416 ze_api_version_t version, ///< [in] API version requested
1417 zet_metric_dditable_t* pDdiTable ///< [in,out] pointer to table of DDI function pointers
1418 )
1419 {
1420 auto& dditable = validation_layer::context.zetDdiTable.Metric;
1421
1422 if( nullptr == pDdiTable )
1423 return ZE_RESULT_ERROR_INVALID_NULL_POINTER;
1424
1425 if (ZE_MAJOR_VERSION(validation_layer::context.version) != ZE_MAJOR_VERSION(version) ||
1426 ZE_MINOR_VERSION(validation_layer::context.version) > ZE_MINOR_VERSION(version))
1427 return ZE_RESULT_ERROR_UNSUPPORTED_VERSION;
1428
1429 ze_result_t result = ZE_RESULT_SUCCESS;
1430
1431 dditable.pfnGet = pDdiTable->pfnGet;
1432 pDdiTable->pfnGet = validation_layer::zetMetricGet;
1433
1434 dditable.pfnGetProperties = pDdiTable->pfnGetProperties;
1435 pDdiTable->pfnGetProperties = validation_layer::zetMetricGetProperties;
1436
1437 return result;
1438 }
1439
1440 ///////////////////////////////////////////////////////////////////////////////
1441 /// @brief Exported function for filling application's MetricGroup table
1442 /// with current process' addresses
1443 ///
1444 /// @returns
1445 /// - ::ZE_RESULT_SUCCESS
1446 /// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER
1447 /// - ::ZE_RESULT_ERROR_UNSUPPORTED_VERSION
1448 ZE_DLLEXPORT ze_result_t ZE_APICALL
zetGetMetricGroupProcAddrTable(ze_api_version_t version,zet_metric_group_dditable_t * pDdiTable)1449 zetGetMetricGroupProcAddrTable(
1450 ze_api_version_t version, ///< [in] API version requested
1451 zet_metric_group_dditable_t* pDdiTable ///< [in,out] pointer to table of DDI function pointers
1452 )
1453 {
1454 auto& dditable = validation_layer::context.zetDdiTable.MetricGroup;
1455
1456 if( nullptr == pDdiTable )
1457 return ZE_RESULT_ERROR_INVALID_NULL_POINTER;
1458
1459 if (ZE_MAJOR_VERSION(validation_layer::context.version) != ZE_MAJOR_VERSION(version) ||
1460 ZE_MINOR_VERSION(validation_layer::context.version) > ZE_MINOR_VERSION(version))
1461 return ZE_RESULT_ERROR_UNSUPPORTED_VERSION;
1462
1463 ze_result_t result = ZE_RESULT_SUCCESS;
1464
1465 dditable.pfnGet = pDdiTable->pfnGet;
1466 pDdiTable->pfnGet = validation_layer::zetMetricGroupGet;
1467
1468 dditable.pfnGetProperties = pDdiTable->pfnGetProperties;
1469 pDdiTable->pfnGetProperties = validation_layer::zetMetricGroupGetProperties;
1470
1471 dditable.pfnCalculateMetricValues = pDdiTable->pfnCalculateMetricValues;
1472 pDdiTable->pfnCalculateMetricValues = validation_layer::zetMetricGroupCalculateMetricValues;
1473
1474 return result;
1475 }
1476
1477 ///////////////////////////////////////////////////////////////////////////////
1478 /// @brief Exported function for filling application's MetricGroupExp table
1479 /// with current process' addresses
1480 ///
1481 /// @returns
1482 /// - ::ZE_RESULT_SUCCESS
1483 /// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER
1484 /// - ::ZE_RESULT_ERROR_UNSUPPORTED_VERSION
1485 ZE_DLLEXPORT ze_result_t ZE_APICALL
zetGetMetricGroupExpProcAddrTable(ze_api_version_t version,zet_metric_group_exp_dditable_t * pDdiTable)1486 zetGetMetricGroupExpProcAddrTable(
1487 ze_api_version_t version, ///< [in] API version requested
1488 zet_metric_group_exp_dditable_t* pDdiTable ///< [in,out] pointer to table of DDI function pointers
1489 )
1490 {
1491 auto& dditable = validation_layer::context.zetDdiTable.MetricGroupExp;
1492
1493 if( nullptr == pDdiTable )
1494 return ZE_RESULT_ERROR_INVALID_NULL_POINTER;
1495
1496 if (ZE_MAJOR_VERSION(validation_layer::context.version) != ZE_MAJOR_VERSION(version) ||
1497 ZE_MINOR_VERSION(validation_layer::context.version) > ZE_MINOR_VERSION(version))
1498 return ZE_RESULT_ERROR_UNSUPPORTED_VERSION;
1499
1500 ze_result_t result = ZE_RESULT_SUCCESS;
1501
1502 dditable.pfnCalculateMultipleMetricValuesExp = pDdiTable->pfnCalculateMultipleMetricValuesExp;
1503 pDdiTable->pfnCalculateMultipleMetricValuesExp = validation_layer::zetMetricGroupCalculateMultipleMetricValuesExp;
1504
1505 return result;
1506 }
1507
1508 ///////////////////////////////////////////////////////////////////////////////
1509 /// @brief Exported function for filling application's MetricQuery table
1510 /// with current process' addresses
1511 ///
1512 /// @returns
1513 /// - ::ZE_RESULT_SUCCESS
1514 /// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER
1515 /// - ::ZE_RESULT_ERROR_UNSUPPORTED_VERSION
1516 ZE_DLLEXPORT ze_result_t ZE_APICALL
zetGetMetricQueryProcAddrTable(ze_api_version_t version,zet_metric_query_dditable_t * pDdiTable)1517 zetGetMetricQueryProcAddrTable(
1518 ze_api_version_t version, ///< [in] API version requested
1519 zet_metric_query_dditable_t* pDdiTable ///< [in,out] pointer to table of DDI function pointers
1520 )
1521 {
1522 auto& dditable = validation_layer::context.zetDdiTable.MetricQuery;
1523
1524 if( nullptr == pDdiTable )
1525 return ZE_RESULT_ERROR_INVALID_NULL_POINTER;
1526
1527 if (ZE_MAJOR_VERSION(validation_layer::context.version) != ZE_MAJOR_VERSION(version) ||
1528 ZE_MINOR_VERSION(validation_layer::context.version) > ZE_MINOR_VERSION(version))
1529 return ZE_RESULT_ERROR_UNSUPPORTED_VERSION;
1530
1531 ze_result_t result = ZE_RESULT_SUCCESS;
1532
1533 dditable.pfnCreate = pDdiTable->pfnCreate;
1534 pDdiTable->pfnCreate = validation_layer::zetMetricQueryCreate;
1535
1536 dditable.pfnDestroy = pDdiTable->pfnDestroy;
1537 pDdiTable->pfnDestroy = validation_layer::zetMetricQueryDestroy;
1538
1539 dditable.pfnReset = pDdiTable->pfnReset;
1540 pDdiTable->pfnReset = validation_layer::zetMetricQueryReset;
1541
1542 dditable.pfnGetData = pDdiTable->pfnGetData;
1543 pDdiTable->pfnGetData = validation_layer::zetMetricQueryGetData;
1544
1545 return result;
1546 }
1547
1548 ///////////////////////////////////////////////////////////////////////////////
1549 /// @brief Exported function for filling application's MetricQueryPool table
1550 /// with current process' addresses
1551 ///
1552 /// @returns
1553 /// - ::ZE_RESULT_SUCCESS
1554 /// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER
1555 /// - ::ZE_RESULT_ERROR_UNSUPPORTED_VERSION
1556 ZE_DLLEXPORT ze_result_t ZE_APICALL
zetGetMetricQueryPoolProcAddrTable(ze_api_version_t version,zet_metric_query_pool_dditable_t * pDdiTable)1557 zetGetMetricQueryPoolProcAddrTable(
1558 ze_api_version_t version, ///< [in] API version requested
1559 zet_metric_query_pool_dditable_t* pDdiTable ///< [in,out] pointer to table of DDI function pointers
1560 )
1561 {
1562 auto& dditable = validation_layer::context.zetDdiTable.MetricQueryPool;
1563
1564 if( nullptr == pDdiTable )
1565 return ZE_RESULT_ERROR_INVALID_NULL_POINTER;
1566
1567 if (ZE_MAJOR_VERSION(validation_layer::context.version) != ZE_MAJOR_VERSION(version) ||
1568 ZE_MINOR_VERSION(validation_layer::context.version) > ZE_MINOR_VERSION(version))
1569 return ZE_RESULT_ERROR_UNSUPPORTED_VERSION;
1570
1571 ze_result_t result = ZE_RESULT_SUCCESS;
1572
1573 dditable.pfnCreate = pDdiTable->pfnCreate;
1574 pDdiTable->pfnCreate = validation_layer::zetMetricQueryPoolCreate;
1575
1576 dditable.pfnDestroy = pDdiTable->pfnDestroy;
1577 pDdiTable->pfnDestroy = validation_layer::zetMetricQueryPoolDestroy;
1578
1579 return result;
1580 }
1581
1582 ///////////////////////////////////////////////////////////////////////////////
1583 /// @brief Exported function for filling application's MetricStreamer table
1584 /// with current process' addresses
1585 ///
1586 /// @returns
1587 /// - ::ZE_RESULT_SUCCESS
1588 /// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER
1589 /// - ::ZE_RESULT_ERROR_UNSUPPORTED_VERSION
1590 ZE_DLLEXPORT ze_result_t ZE_APICALL
zetGetMetricStreamerProcAddrTable(ze_api_version_t version,zet_metric_streamer_dditable_t * pDdiTable)1591 zetGetMetricStreamerProcAddrTable(
1592 ze_api_version_t version, ///< [in] API version requested
1593 zet_metric_streamer_dditable_t* pDdiTable ///< [in,out] pointer to table of DDI function pointers
1594 )
1595 {
1596 auto& dditable = validation_layer::context.zetDdiTable.MetricStreamer;
1597
1598 if( nullptr == pDdiTable )
1599 return ZE_RESULT_ERROR_INVALID_NULL_POINTER;
1600
1601 if (ZE_MAJOR_VERSION(validation_layer::context.version) != ZE_MAJOR_VERSION(version) ||
1602 ZE_MINOR_VERSION(validation_layer::context.version) > ZE_MINOR_VERSION(version))
1603 return ZE_RESULT_ERROR_UNSUPPORTED_VERSION;
1604
1605 ze_result_t result = ZE_RESULT_SUCCESS;
1606
1607 dditable.pfnOpen = pDdiTable->pfnOpen;
1608 pDdiTable->pfnOpen = validation_layer::zetMetricStreamerOpen;
1609
1610 dditable.pfnClose = pDdiTable->pfnClose;
1611 pDdiTable->pfnClose = validation_layer::zetMetricStreamerClose;
1612
1613 dditable.pfnReadData = pDdiTable->pfnReadData;
1614 pDdiTable->pfnReadData = validation_layer::zetMetricStreamerReadData;
1615
1616 return result;
1617 }
1618
1619 ///////////////////////////////////////////////////////////////////////////////
1620 /// @brief Exported function for filling application's TracerExp table
1621 /// with current process' addresses
1622 ///
1623 /// @returns
1624 /// - ::ZE_RESULT_SUCCESS
1625 /// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER
1626 /// - ::ZE_RESULT_ERROR_UNSUPPORTED_VERSION
1627 ZE_DLLEXPORT ze_result_t ZE_APICALL
zetGetTracerExpProcAddrTable(ze_api_version_t version,zet_tracer_exp_dditable_t * pDdiTable)1628 zetGetTracerExpProcAddrTable(
1629 ze_api_version_t version, ///< [in] API version requested
1630 zet_tracer_exp_dditable_t* pDdiTable ///< [in,out] pointer to table of DDI function pointers
1631 )
1632 {
1633 auto& dditable = validation_layer::context.zetDdiTable.TracerExp;
1634
1635 if( nullptr == pDdiTable )
1636 return ZE_RESULT_ERROR_INVALID_NULL_POINTER;
1637
1638 if (ZE_MAJOR_VERSION(validation_layer::context.version) != ZE_MAJOR_VERSION(version) ||
1639 ZE_MINOR_VERSION(validation_layer::context.version) > ZE_MINOR_VERSION(version))
1640 return ZE_RESULT_ERROR_UNSUPPORTED_VERSION;
1641
1642 ze_result_t result = ZE_RESULT_SUCCESS;
1643
1644 dditable.pfnCreate = pDdiTable->pfnCreate;
1645 pDdiTable->pfnCreate = validation_layer::zetTracerExpCreate;
1646
1647 dditable.pfnDestroy = pDdiTable->pfnDestroy;
1648 pDdiTable->pfnDestroy = validation_layer::zetTracerExpDestroy;
1649
1650 dditable.pfnSetPrologues = pDdiTable->pfnSetPrologues;
1651 pDdiTable->pfnSetPrologues = validation_layer::zetTracerExpSetPrologues;
1652
1653 dditable.pfnSetEpilogues = pDdiTable->pfnSetEpilogues;
1654 pDdiTable->pfnSetEpilogues = validation_layer::zetTracerExpSetEpilogues;
1655
1656 dditable.pfnSetEnabled = pDdiTable->pfnSetEnabled;
1657 pDdiTable->pfnSetEnabled = validation_layer::zetTracerExpSetEnabled;
1658
1659 return result;
1660 }
1661
1662 #if defined(__cplusplus)
1663 };
1664 #endif
1665