forked from oneapi-src/level-zero
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathzes_ldrddi.cpp
More file actions
6502 lines (5485 loc) · 295 KB
/
zes_ldrddi.cpp
File metadata and controls
6502 lines (5485 loc) · 295 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
*
* Copyright (C) 2019-2024 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
* @file zes_ldrddi.cpp
*
*/
#include "ze_loader_internal.h"
namespace loader
{
///////////////////////////////////////////////////////////////////////////////
/// @brief Intercept function for zesInit
__zedlllocal ze_result_t ZE_APICALL
zesInit(
zes_init_flags_t flags ///< [in] initialization flags.
///< currently unused, must be 0 (default).
)
{
ze_result_t result = ZE_RESULT_SUCCESS;
bool atLeastOneDriverValid = false;
for( auto& drv : *loader::context->sysmanInstanceDrivers )
{
if(drv.initStatus != ZE_RESULT_SUCCESS || drv.initSysManStatus != ZE_RESULT_SUCCESS)
continue;
if (!drv.dditable.zes.Global.pfnInit) {
drv.initSysManStatus = ZE_RESULT_ERROR_UNINITIALIZED;
continue;
}
drv.initSysManStatus = drv.dditable.zes.Global.pfnInit( flags );
if(drv.initSysManStatus == ZE_RESULT_SUCCESS)
atLeastOneDriverValid = true;
}
if(!atLeastOneDriverValid)
result=ZE_RESULT_ERROR_UNINITIALIZED;
return result;
}
///////////////////////////////////////////////////////////////////////////////
/// @brief Intercept function for zesDriverGet
__zedlllocal ze_result_t ZE_APICALL
zesDriverGet(
uint32_t* pCount, ///< [in,out] pointer to the number of sysman driver instances.
///< if count is zero, then the loader shall update the value with the
///< total number of sysman drivers available.
///< if count is greater than the number of sysman drivers available, then
///< the loader shall update the value with the correct number of sysman
///< drivers available.
zes_driver_handle_t* phDrivers ///< [in,out][optional][range(0, *pCount)] array of sysman driver instance handles.
///< if count is less than the number of sysman drivers available, then the
///< loader shall only retrieve that number of sysman drivers.
)
{
ze_result_t result = ZE_RESULT_SUCCESS;
uint32_t total_driver_handle_count = 0;
{
std::lock_guard<std::mutex> lock(loader::context->sortMutex);
if (!loader::context->sortingInProgress.exchange(true) && !loader::context->instrumentationEnabled) {
std::call_once(loader::context->sysmanDriverSortOnce, []() {
loader::context->driverSorting(loader::context->sysmanInstanceDrivers, nullptr, true);
});
loader::context->sortingInProgress.store(false);
}
}
for( auto& drv : *loader::context->sysmanInstanceDrivers )
{
if(drv.initStatus != ZE_RESULT_SUCCESS || drv.initSysManStatus != ZE_RESULT_SUCCESS)
continue;
if( ( 0 < *pCount ) && ( *pCount == total_driver_handle_count))
break;
uint32_t library_driver_handle_count = 0;
result = drv.dditable.zes.Driver.pfnGet( &library_driver_handle_count, nullptr );
if( ZE_RESULT_SUCCESS != result ) {
// If Get Drivers fails with Uninitialized, then update the driver init status to prevent reporting this driver in the next get call.
if (ZE_RESULT_ERROR_UNINITIALIZED == result) {
drv.initStatus = result;
}
continue;
}
if( nullptr != phDrivers && *pCount !=0)
{
if( total_driver_handle_count + library_driver_handle_count > *pCount) {
library_driver_handle_count = *pCount - total_driver_handle_count;
}
result = drv.dditable.zes.Driver.pfnGet( &library_driver_handle_count, &phDrivers[ total_driver_handle_count ] );
if( ZE_RESULT_SUCCESS != result ) break;
drv.driverInuse = true;
try
{
for( uint32_t i = 0; i < library_driver_handle_count; ++i ) {
uint32_t driver_index = total_driver_handle_count + i;
phDrivers[ driver_index ] = reinterpret_cast<zes_driver_handle_t>(
context->zes_driver_factory.getInstance( phDrivers[ driver_index ], &drv.dditable ) );
}
}
catch( std::bad_alloc& )
{
result = ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY;
}
}
total_driver_handle_count += library_driver_handle_count;
}
// If the last driver get failed, but at least one driver succeeded, then return success with total count.
if( ZE_RESULT_SUCCESS == result || total_driver_handle_count > 0)
*pCount = total_driver_handle_count;
if (total_driver_handle_count > 0) {
result = ZE_RESULT_SUCCESS;
}
return result;
}
///////////////////////////////////////////////////////////////////////////////
/// @brief Intercept function for zesDriverGetExtensionProperties
__zedlllocal ze_result_t ZE_APICALL
zesDriverGetExtensionProperties(
zes_driver_handle_t hDriver, ///< [in] handle of the driver instance
uint32_t* pCount, ///< [in,out] pointer to the number of extension properties.
///< if count is zero, then the driver shall update the value with the
///< total number of extension properties available.
///< if count is greater than the number of extension properties available,
///< then the driver shall update the value with the correct number of
///< extension properties available.
zes_driver_extension_properties_t* pExtensionProperties ///< [in,out][optional][range(0, *pCount)] array of query results for
///< extension properties.
///< if count is less than the number of extension properties available,
///< then driver shall only retrieve that number of extension properties.
)
{
ze_result_t result = ZE_RESULT_SUCCESS;
// extract driver's function pointer table
auto dditable = reinterpret_cast<zes_driver_object_t*>( hDriver )->dditable;
auto pfnGetExtensionProperties = dditable->zes.Driver.pfnGetExtensionProperties;
if( nullptr == pfnGetExtensionProperties )
return ZE_RESULT_ERROR_UNINITIALIZED;
// convert loader handle to driver handle
hDriver = reinterpret_cast<zes_driver_object_t*>( hDriver )->handle;
// forward to device-driver
result = pfnGetExtensionProperties( hDriver, pCount, pExtensionProperties );
return result;
}
///////////////////////////////////////////////////////////////////////////////
/// @brief Intercept function for zesDriverGetExtensionFunctionAddress
__zedlllocal ze_result_t ZE_APICALL
zesDriverGetExtensionFunctionAddress(
zes_driver_handle_t hDriver, ///< [in] handle of the driver instance
const char* name, ///< [in] extension function name
void** ppFunctionAddress ///< [out] pointer to function pointer
)
{
ze_result_t result = ZE_RESULT_SUCCESS;
// extract driver's function pointer table
auto dditable = reinterpret_cast<zes_driver_object_t*>( hDriver )->dditable;
auto pfnGetExtensionFunctionAddress = dditable->zes.Driver.pfnGetExtensionFunctionAddress;
if( nullptr == pfnGetExtensionFunctionAddress )
return ZE_RESULT_ERROR_UNINITIALIZED;
// convert loader handle to driver handle
hDriver = reinterpret_cast<zes_driver_object_t*>( hDriver )->handle;
// forward to device-driver
result = pfnGetExtensionFunctionAddress( hDriver, name, ppFunctionAddress );
return result;
}
///////////////////////////////////////////////////////////////////////////////
/// @brief Intercept function for zesDeviceGet
__zedlllocal ze_result_t ZE_APICALL
zesDeviceGet(
zes_driver_handle_t hDriver, ///< [in] handle of the sysman driver instance
uint32_t* pCount, ///< [in,out] pointer to the number of sysman devices.
///< if count is zero, then the driver shall update the value with the
///< total number of sysman devices available.
///< if count is greater than the number of sysman devices available, then
///< the driver shall update the value with the correct number of sysman
///< devices available.
zes_device_handle_t* phDevices ///< [in,out][optional][range(0, *pCount)] array of handle of sysman devices.
///< if count is less than the number of sysman devices available, then
///< driver shall only retrieve that number of sysman devices.
)
{
ze_result_t result = ZE_RESULT_SUCCESS;
// extract driver's function pointer table
auto dditable = reinterpret_cast<zes_driver_object_t*>( hDriver )->dditable;
auto pfnGet = dditable->zes.Device.pfnGet;
if( nullptr == pfnGet )
return ZE_RESULT_ERROR_UNINITIALIZED;
// convert loader handle to driver handle
hDriver = reinterpret_cast<zes_driver_object_t*>( hDriver )->handle;
// forward to device-driver
result = pfnGet( hDriver, pCount, phDevices );
if( ZE_RESULT_SUCCESS != result )
return result;
try
{
// convert driver handles to loader handles
for( size_t i = 0; ( nullptr != phDevices ) && ( i < *pCount ); ++i )
phDevices[ i ] = reinterpret_cast<zes_device_handle_t>(
context->zes_device_factory.getInstance( phDevices[ i ], dditable ) );
}
catch( std::bad_alloc& )
{
result = ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY;
}
return result;
}
///////////////////////////////////////////////////////////////////////////////
/// @brief Intercept function for zesDeviceGetProperties
__zedlllocal ze_result_t ZE_APICALL
zesDeviceGetProperties(
zes_device_handle_t hDevice, ///< [in] Sysman handle of the device.
zes_device_properties_t* pProperties ///< [in,out] Structure that will contain information about the device.
)
{
ze_result_t result = ZE_RESULT_SUCCESS;
// extract driver's function pointer table
auto dditable = reinterpret_cast<zes_device_object_t*>( hDevice )->dditable;
auto pfnGetProperties = dditable->zes.Device.pfnGetProperties;
if( nullptr == pfnGetProperties )
return ZE_RESULT_ERROR_UNINITIALIZED;
// convert loader handle to driver handle
hDevice = reinterpret_cast<zes_device_object_t*>( hDevice )->handle;
// forward to device-driver
result = pfnGetProperties( hDevice, pProperties );
return result;
}
///////////////////////////////////////////////////////////////////////////////
/// @brief Intercept function for zesDeviceGetState
__zedlllocal ze_result_t ZE_APICALL
zesDeviceGetState(
zes_device_handle_t hDevice, ///< [in] Sysman handle of the device.
zes_device_state_t* pState ///< [in,out] Structure that will contain information about the device.
)
{
ze_result_t result = ZE_RESULT_SUCCESS;
// extract driver's function pointer table
auto dditable = reinterpret_cast<zes_device_object_t*>( hDevice )->dditable;
auto pfnGetState = dditable->zes.Device.pfnGetState;
if( nullptr == pfnGetState )
return ZE_RESULT_ERROR_UNINITIALIZED;
// convert loader handle to driver handle
hDevice = reinterpret_cast<zes_device_object_t*>( hDevice )->handle;
// forward to device-driver
result = pfnGetState( hDevice, pState );
return result;
}
///////////////////////////////////////////////////////////////////////////////
/// @brief Intercept function for zesDeviceReset
__zedlllocal ze_result_t ZE_APICALL
zesDeviceReset(
zes_device_handle_t hDevice, ///< [in] Sysman handle for the device
ze_bool_t force ///< [in] If set to true, all applications that are currently using the
///< device will be forcibly killed.
)
{
ze_result_t result = ZE_RESULT_SUCCESS;
// extract driver's function pointer table
auto dditable = reinterpret_cast<zes_device_object_t*>( hDevice )->dditable;
auto pfnReset = dditable->zes.Device.pfnReset;
if( nullptr == pfnReset )
return ZE_RESULT_ERROR_UNINITIALIZED;
// convert loader handle to driver handle
hDevice = reinterpret_cast<zes_device_object_t*>( hDevice )->handle;
// forward to device-driver
result = pfnReset( hDevice, force );
return result;
}
///////////////////////////////////////////////////////////////////////////////
/// @brief Intercept function for zesDeviceResetExt
__zedlllocal ze_result_t ZE_APICALL
zesDeviceResetExt(
zes_device_handle_t hDevice, ///< [in] Sysman handle for the device
zes_reset_properties_t* pProperties ///< [in] Device reset properties to apply
)
{
ze_result_t result = ZE_RESULT_SUCCESS;
// extract driver's function pointer table
auto dditable = reinterpret_cast<zes_device_object_t*>( hDevice )->dditable;
auto pfnResetExt = dditable->zes.Device.pfnResetExt;
if( nullptr == pfnResetExt )
return ZE_RESULT_ERROR_UNINITIALIZED;
// convert loader handle to driver handle
hDevice = reinterpret_cast<zes_device_object_t*>( hDevice )->handle;
// forward to device-driver
result = pfnResetExt( hDevice, pProperties );
return result;
}
///////////////////////////////////////////////////////////////////////////////
/// @brief Intercept function for zesDeviceProcessesGetState
__zedlllocal ze_result_t ZE_APICALL
zesDeviceProcessesGetState(
zes_device_handle_t hDevice, ///< [in] Sysman handle for the device
uint32_t* pCount, ///< [in,out] pointer to the number of processes.
///< if count is zero, then the driver shall update the value with the
///< total number of processes currently attached to the device.
///< if count is greater than the number of processes currently attached to
///< the device, then the driver shall update the value with the correct
///< number of processes.
zes_process_state_t* pProcesses ///< [in,out][optional][range(0, *pCount)] array of process information.
///< if count is less than the number of processes currently attached to
///< the device, then the driver shall only retrieve information about that
///< number of processes. In this case, the return code will ::ZE_RESULT_ERROR_INVALID_SIZE.
)
{
ze_result_t result = ZE_RESULT_SUCCESS;
// extract driver's function pointer table
auto dditable = reinterpret_cast<zes_device_object_t*>( hDevice )->dditable;
auto pfnProcessesGetState = dditable->zes.Device.pfnProcessesGetState;
if( nullptr == pfnProcessesGetState )
return ZE_RESULT_ERROR_UNINITIALIZED;
// convert loader handle to driver handle
hDevice = reinterpret_cast<zes_device_object_t*>( hDevice )->handle;
// forward to device-driver
result = pfnProcessesGetState( hDevice, pCount, pProcesses );
return result;
}
///////////////////////////////////////////////////////////////////////////////
/// @brief Intercept function for zesDevicePciGetProperties
__zedlllocal ze_result_t ZE_APICALL
zesDevicePciGetProperties(
zes_device_handle_t hDevice, ///< [in] Sysman handle of the device.
zes_pci_properties_t* pProperties ///< [in,out] Will contain the PCI properties.
)
{
ze_result_t result = ZE_RESULT_SUCCESS;
// extract driver's function pointer table
auto dditable = reinterpret_cast<zes_device_object_t*>( hDevice )->dditable;
auto pfnPciGetProperties = dditable->zes.Device.pfnPciGetProperties;
if( nullptr == pfnPciGetProperties )
return ZE_RESULT_ERROR_UNINITIALIZED;
// convert loader handle to driver handle
hDevice = reinterpret_cast<zes_device_object_t*>( hDevice )->handle;
// forward to device-driver
result = pfnPciGetProperties( hDevice, pProperties );
return result;
}
///////////////////////////////////////////////////////////////////////////////
/// @brief Intercept function for zesDevicePciGetState
__zedlllocal ze_result_t ZE_APICALL
zesDevicePciGetState(
zes_device_handle_t hDevice, ///< [in] Sysman handle of the device.
zes_pci_state_t* pState ///< [in,out] Will contain the PCI properties.
)
{
ze_result_t result = ZE_RESULT_SUCCESS;
// extract driver's function pointer table
auto dditable = reinterpret_cast<zes_device_object_t*>( hDevice )->dditable;
auto pfnPciGetState = dditable->zes.Device.pfnPciGetState;
if( nullptr == pfnPciGetState )
return ZE_RESULT_ERROR_UNINITIALIZED;
// convert loader handle to driver handle
hDevice = reinterpret_cast<zes_device_object_t*>( hDevice )->handle;
// forward to device-driver
result = pfnPciGetState( hDevice, pState );
return result;
}
///////////////////////////////////////////////////////////////////////////////
/// @brief Intercept function for zesDevicePciGetBars
__zedlllocal ze_result_t ZE_APICALL
zesDevicePciGetBars(
zes_device_handle_t hDevice, ///< [in] Sysman handle of the device.
uint32_t* pCount, ///< [in,out] pointer to the number of PCI bars.
///< if count is zero, then the driver shall update the value with the
///< total number of PCI bars that are setup.
///< if count is greater than the number of PCI bars that are setup, then
///< the driver shall update the value with the correct number of PCI bars.
zes_pci_bar_properties_t* pProperties ///< [in,out][optional][range(0, *pCount)] array of information about setup
///< PCI bars.
///< if count is less than the number of PCI bars that are setup, then the
///< driver shall only retrieve information about that number of PCI bars.
)
{
ze_result_t result = ZE_RESULT_SUCCESS;
// extract driver's function pointer table
auto dditable = reinterpret_cast<zes_device_object_t*>( hDevice )->dditable;
auto pfnPciGetBars = dditable->zes.Device.pfnPciGetBars;
if( nullptr == pfnPciGetBars )
return ZE_RESULT_ERROR_UNINITIALIZED;
// convert loader handle to driver handle
hDevice = reinterpret_cast<zes_device_object_t*>( hDevice )->handle;
// forward to device-driver
result = pfnPciGetBars( hDevice, pCount, pProperties );
return result;
}
///////////////////////////////////////////////////////////////////////////////
/// @brief Intercept function for zesDevicePciGetStats
__zedlllocal ze_result_t ZE_APICALL
zesDevicePciGetStats(
zes_device_handle_t hDevice, ///< [in] Sysman handle of the device.
zes_pci_stats_t* pStats ///< [in,out] Will contain a snapshot of the latest stats.
)
{
ze_result_t result = ZE_RESULT_SUCCESS;
// extract driver's function pointer table
auto dditable = reinterpret_cast<zes_device_object_t*>( hDevice )->dditable;
auto pfnPciGetStats = dditable->zes.Device.pfnPciGetStats;
if( nullptr == pfnPciGetStats )
return ZE_RESULT_ERROR_UNINITIALIZED;
// convert loader handle to driver handle
hDevice = reinterpret_cast<zes_device_object_t*>( hDevice )->handle;
// forward to device-driver
result = pfnPciGetStats( hDevice, pStats );
return result;
}
///////////////////////////////////////////////////////////////////////////////
/// @brief Intercept function for zesDeviceSetOverclockWaiver
__zedlllocal ze_result_t ZE_APICALL
zesDeviceSetOverclockWaiver(
zes_device_handle_t hDevice ///< [in] Sysman handle of the device.
)
{
ze_result_t result = ZE_RESULT_SUCCESS;
// extract driver's function pointer table
auto dditable = reinterpret_cast<zes_device_object_t*>( hDevice )->dditable;
auto pfnSetOverclockWaiver = dditable->zes.Device.pfnSetOverclockWaiver;
if( nullptr == pfnSetOverclockWaiver )
return ZE_RESULT_ERROR_UNINITIALIZED;
// convert loader handle to driver handle
hDevice = reinterpret_cast<zes_device_object_t*>( hDevice )->handle;
// forward to device-driver
result = pfnSetOverclockWaiver( hDevice );
return result;
}
///////////////////////////////////////////////////////////////////////////////
/// @brief Intercept function for zesDeviceGetOverclockDomains
__zedlllocal ze_result_t ZE_APICALL
zesDeviceGetOverclockDomains(
zes_device_handle_t hDevice, ///< [in] Sysman handle of the device.
uint32_t* pOverclockDomains ///< [in,out] Returns the overclock domains that are supported (a bit for
///< each of enum ::zes_overclock_domain_t). If no bits are set, the device
///< doesn't support overclocking.
)
{
ze_result_t result = ZE_RESULT_SUCCESS;
// extract driver's function pointer table
auto dditable = reinterpret_cast<zes_device_object_t*>( hDevice )->dditable;
auto pfnGetOverclockDomains = dditable->zes.Device.pfnGetOverclockDomains;
if( nullptr == pfnGetOverclockDomains )
return ZE_RESULT_ERROR_UNINITIALIZED;
// convert loader handle to driver handle
hDevice = reinterpret_cast<zes_device_object_t*>( hDevice )->handle;
// forward to device-driver
result = pfnGetOverclockDomains( hDevice, pOverclockDomains );
return result;
}
///////////////////////////////////////////////////////////////////////////////
/// @brief Intercept function for zesDeviceGetOverclockControls
__zedlllocal ze_result_t ZE_APICALL
zesDeviceGetOverclockControls(
zes_device_handle_t hDevice, ///< [in] Sysman handle of the device.
zes_overclock_domain_t domainType, ///< [in] Domain type.
uint32_t* pAvailableControls ///< [in,out] Returns the overclock controls that are supported for the
///< specified overclock domain (a bit for each of enum
///< ::zes_overclock_control_t).
)
{
ze_result_t result = ZE_RESULT_SUCCESS;
// extract driver's function pointer table
auto dditable = reinterpret_cast<zes_device_object_t*>( hDevice )->dditable;
auto pfnGetOverclockControls = dditable->zes.Device.pfnGetOverclockControls;
if( nullptr == pfnGetOverclockControls )
return ZE_RESULT_ERROR_UNINITIALIZED;
// convert loader handle to driver handle
hDevice = reinterpret_cast<zes_device_object_t*>( hDevice )->handle;
// forward to device-driver
result = pfnGetOverclockControls( hDevice, domainType, pAvailableControls );
return result;
}
///////////////////////////////////////////////////////////////////////////////
/// @brief Intercept function for zesDeviceResetOverclockSettings
__zedlllocal ze_result_t ZE_APICALL
zesDeviceResetOverclockSettings(
zes_device_handle_t hDevice, ///< [in] Sysman handle of the device.
ze_bool_t onShippedState ///< [in] True will reset to shipped state; false will reset to
///< manufacturing state
)
{
ze_result_t result = ZE_RESULT_SUCCESS;
// extract driver's function pointer table
auto dditable = reinterpret_cast<zes_device_object_t*>( hDevice )->dditable;
auto pfnResetOverclockSettings = dditable->zes.Device.pfnResetOverclockSettings;
if( nullptr == pfnResetOverclockSettings )
return ZE_RESULT_ERROR_UNINITIALIZED;
// convert loader handle to driver handle
hDevice = reinterpret_cast<zes_device_object_t*>( hDevice )->handle;
// forward to device-driver
result = pfnResetOverclockSettings( hDevice, onShippedState );
return result;
}
///////////////////////////////////////////////////////////////////////////////
/// @brief Intercept function for zesDeviceReadOverclockState
__zedlllocal ze_result_t ZE_APICALL
zesDeviceReadOverclockState(
zes_device_handle_t hDevice, ///< [in] Sysman handle of the device.
zes_overclock_mode_t* pOverclockMode, ///< [out] One of overclock mode.
ze_bool_t* pWaiverSetting, ///< [out] Waiver setting: 0 = Waiver not set, 1 = waiver has been set.
ze_bool_t* pOverclockState, ///< [out] Current settings 0 =manufacturing state, 1= shipped state)..
zes_pending_action_t* pPendingAction, ///< [out] This enum is returned when the driver attempts to set an
///< overclock control or reset overclock settings.
ze_bool_t* pPendingReset ///< [out] Pending reset 0 =manufacturing state, 1= shipped state)..
)
{
ze_result_t result = ZE_RESULT_SUCCESS;
// extract driver's function pointer table
auto dditable = reinterpret_cast<zes_device_object_t*>( hDevice )->dditable;
auto pfnReadOverclockState = dditable->zes.Device.pfnReadOverclockState;
if( nullptr == pfnReadOverclockState )
return ZE_RESULT_ERROR_UNINITIALIZED;
// convert loader handle to driver handle
hDevice = reinterpret_cast<zes_device_object_t*>( hDevice )->handle;
// forward to device-driver
result = pfnReadOverclockState( hDevice, pOverclockMode, pWaiverSetting, pOverclockState, pPendingAction, pPendingReset );
return result;
}
///////////////////////////////////////////////////////////////////////////////
/// @brief Intercept function for zesDeviceEnumOverclockDomains
__zedlllocal ze_result_t ZE_APICALL
zesDeviceEnumOverclockDomains(
zes_device_handle_t hDevice, ///< [in] Sysman handle of the device.
uint32_t* pCount, ///< [in,out] pointer to the number of components of this type.
///< if count is zero, then the driver shall update the value with the
///< total number of components of this type that are available.
///< if count is greater than the number of components of this type that
///< are available, then the driver shall update the value with the correct
///< number of components.
zes_overclock_handle_t* phDomainHandle ///< [in,out][optional][range(0, *pCount)] array of handle of components of
///< this type.
///< if count is less than the number of components of this type that are
///< available, then the driver shall only retrieve that number of
///< component handles.
)
{
ze_result_t result = ZE_RESULT_SUCCESS;
// extract driver's function pointer table
auto dditable = reinterpret_cast<zes_device_object_t*>( hDevice )->dditable;
auto pfnEnumOverclockDomains = dditable->zes.Device.pfnEnumOverclockDomains;
if( nullptr == pfnEnumOverclockDomains )
return ZE_RESULT_ERROR_UNINITIALIZED;
// convert loader handle to driver handle
hDevice = reinterpret_cast<zes_device_object_t*>( hDevice )->handle;
// forward to device-driver
result = pfnEnumOverclockDomains( hDevice, pCount, phDomainHandle );
if( ZE_RESULT_SUCCESS != result )
return result;
try
{
// convert driver handles to loader handles
for( size_t i = 0; ( nullptr != phDomainHandle ) && ( i < *pCount ); ++i )
phDomainHandle[ i ] = reinterpret_cast<zes_overclock_handle_t>(
context->zes_overclock_factory.getInstance( phDomainHandle[ i ], dditable ) );
}
catch( std::bad_alloc& )
{
result = ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY;
}
return result;
}
///////////////////////////////////////////////////////////////////////////////
/// @brief Intercept function for zesOverclockGetDomainProperties
__zedlllocal ze_result_t ZE_APICALL
zesOverclockGetDomainProperties(
zes_overclock_handle_t hDomainHandle, ///< [in] Handle for the component domain.
zes_overclock_properties_t* pDomainProperties ///< [in,out] The overclock properties for the specified domain.
)
{
ze_result_t result = ZE_RESULT_SUCCESS;
// extract driver's function pointer table
auto dditable = reinterpret_cast<zes_overclock_object_t*>( hDomainHandle )->dditable;
auto pfnGetDomainProperties = dditable->zes.Overclock.pfnGetDomainProperties;
if( nullptr == pfnGetDomainProperties )
return ZE_RESULT_ERROR_UNINITIALIZED;
// convert loader handle to driver handle
hDomainHandle = reinterpret_cast<zes_overclock_object_t*>( hDomainHandle )->handle;
// forward to device-driver
result = pfnGetDomainProperties( hDomainHandle, pDomainProperties );
return result;
}
///////////////////////////////////////////////////////////////////////////////
/// @brief Intercept function for zesOverclockGetDomainVFProperties
__zedlllocal ze_result_t ZE_APICALL
zesOverclockGetDomainVFProperties(
zes_overclock_handle_t hDomainHandle, ///< [in] Handle for the component domain.
zes_vf_property_t* pVFProperties ///< [in,out] The VF min,max,step for a specified domain.
)
{
ze_result_t result = ZE_RESULT_SUCCESS;
// extract driver's function pointer table
auto dditable = reinterpret_cast<zes_overclock_object_t*>( hDomainHandle )->dditable;
auto pfnGetDomainVFProperties = dditable->zes.Overclock.pfnGetDomainVFProperties;
if( nullptr == pfnGetDomainVFProperties )
return ZE_RESULT_ERROR_UNINITIALIZED;
// convert loader handle to driver handle
hDomainHandle = reinterpret_cast<zes_overclock_object_t*>( hDomainHandle )->handle;
// forward to device-driver
result = pfnGetDomainVFProperties( hDomainHandle, pVFProperties );
return result;
}
///////////////////////////////////////////////////////////////////////////////
/// @brief Intercept function for zesOverclockGetDomainControlProperties
__zedlllocal ze_result_t ZE_APICALL
zesOverclockGetDomainControlProperties(
zes_overclock_handle_t hDomainHandle, ///< [in] Handle for the component domain.
zes_overclock_control_t DomainControl, ///< [in] Handle for the component.
zes_control_property_t* pControlProperties ///< [in,out] overclock control values.
)
{
ze_result_t result = ZE_RESULT_SUCCESS;
// extract driver's function pointer table
auto dditable = reinterpret_cast<zes_overclock_object_t*>( hDomainHandle )->dditable;
auto pfnGetDomainControlProperties = dditable->zes.Overclock.pfnGetDomainControlProperties;
if( nullptr == pfnGetDomainControlProperties )
return ZE_RESULT_ERROR_UNINITIALIZED;
// convert loader handle to driver handle
hDomainHandle = reinterpret_cast<zes_overclock_object_t*>( hDomainHandle )->handle;
// forward to device-driver
result = pfnGetDomainControlProperties( hDomainHandle, DomainControl, pControlProperties );
return result;
}
///////////////////////////////////////////////////////////////////////////////
/// @brief Intercept function for zesOverclockGetControlCurrentValue
__zedlllocal ze_result_t ZE_APICALL
zesOverclockGetControlCurrentValue(
zes_overclock_handle_t hDomainHandle, ///< [in] Handle for the component.
zes_overclock_control_t DomainControl, ///< [in] Overclock Control.
double* pValue ///< [in,out] Getting overclock control value for the specified control.
)
{
ze_result_t result = ZE_RESULT_SUCCESS;
// extract driver's function pointer table
auto dditable = reinterpret_cast<zes_overclock_object_t*>( hDomainHandle )->dditable;
auto pfnGetControlCurrentValue = dditable->zes.Overclock.pfnGetControlCurrentValue;
if( nullptr == pfnGetControlCurrentValue )
return ZE_RESULT_ERROR_UNINITIALIZED;
// convert loader handle to driver handle
hDomainHandle = reinterpret_cast<zes_overclock_object_t*>( hDomainHandle )->handle;
// forward to device-driver
result = pfnGetControlCurrentValue( hDomainHandle, DomainControl, pValue );
return result;
}
///////////////////////////////////////////////////////////////////////////////
/// @brief Intercept function for zesOverclockGetControlPendingValue
__zedlllocal ze_result_t ZE_APICALL
zesOverclockGetControlPendingValue(
zes_overclock_handle_t hDomainHandle, ///< [in] Handle for the component domain.
zes_overclock_control_t DomainControl, ///< [in] Overclock Control.
double* pValue ///< [out] Returns the pending value for a given control. The units and
///< format of the value depend on the control type.
)
{
ze_result_t result = ZE_RESULT_SUCCESS;
// extract driver's function pointer table
auto dditable = reinterpret_cast<zes_overclock_object_t*>( hDomainHandle )->dditable;
auto pfnGetControlPendingValue = dditable->zes.Overclock.pfnGetControlPendingValue;
if( nullptr == pfnGetControlPendingValue )
return ZE_RESULT_ERROR_UNINITIALIZED;
// convert loader handle to driver handle
hDomainHandle = reinterpret_cast<zes_overclock_object_t*>( hDomainHandle )->handle;
// forward to device-driver
result = pfnGetControlPendingValue( hDomainHandle, DomainControl, pValue );
return result;
}
///////////////////////////////////////////////////////////////////////////////
/// @brief Intercept function for zesOverclockSetControlUserValue
__zedlllocal ze_result_t ZE_APICALL
zesOverclockSetControlUserValue(
zes_overclock_handle_t hDomainHandle, ///< [in] Handle for the component domain.
zes_overclock_control_t DomainControl, ///< [in] Domain Control.
double pValue, ///< [in] The new value of the control. The units and format of the value
///< depend on the control type.
zes_pending_action_t* pPendingAction ///< [out] Pending overclock setting.
)
{
ze_result_t result = ZE_RESULT_SUCCESS;
// extract driver's function pointer table
auto dditable = reinterpret_cast<zes_overclock_object_t*>( hDomainHandle )->dditable;
auto pfnSetControlUserValue = dditable->zes.Overclock.pfnSetControlUserValue;
if( nullptr == pfnSetControlUserValue )
return ZE_RESULT_ERROR_UNINITIALIZED;
// convert loader handle to driver handle
hDomainHandle = reinterpret_cast<zes_overclock_object_t*>( hDomainHandle )->handle;
// forward to device-driver
result = pfnSetControlUserValue( hDomainHandle, DomainControl, pValue, pPendingAction );
return result;
}
///////////////////////////////////////////////////////////////////////////////
/// @brief Intercept function for zesOverclockGetControlState
__zedlllocal ze_result_t ZE_APICALL
zesOverclockGetControlState(
zes_overclock_handle_t hDomainHandle, ///< [in] Handle for the component domain.
zes_overclock_control_t DomainControl, ///< [in] Domain Control.
zes_control_state_t* pControlState, ///< [out] Current overclock control state.
zes_pending_action_t* pPendingAction ///< [out] Pending overclock setting.
)
{
ze_result_t result = ZE_RESULT_SUCCESS;
// extract driver's function pointer table
auto dditable = reinterpret_cast<zes_overclock_object_t*>( hDomainHandle )->dditable;
auto pfnGetControlState = dditable->zes.Overclock.pfnGetControlState;
if( nullptr == pfnGetControlState )
return ZE_RESULT_ERROR_UNINITIALIZED;
// convert loader handle to driver handle
hDomainHandle = reinterpret_cast<zes_overclock_object_t*>( hDomainHandle )->handle;
// forward to device-driver
result = pfnGetControlState( hDomainHandle, DomainControl, pControlState, pPendingAction );
return result;
}
///////////////////////////////////////////////////////////////////////////////
/// @brief Intercept function for zesOverclockGetVFPointValues
__zedlllocal ze_result_t ZE_APICALL
zesOverclockGetVFPointValues(
zes_overclock_handle_t hDomainHandle, ///< [in] Handle for the component domain.
zes_vf_type_t VFType, ///< [in] Voltage or Freqency point to read.
zes_vf_array_type_t VFArrayType, ///< [in] User,Default or Live VF array to read from
uint32_t PointIndex, ///< [in] Point index - number between (0, max_num_points - 1).
uint32_t* PointValue ///< [out] Returns the frequency in 1kHz units or voltage in millivolt
///< units from the custom V-F curve at the specified zero-based index
)
{
ze_result_t result = ZE_RESULT_SUCCESS;
// extract driver's function pointer table
auto dditable = reinterpret_cast<zes_overclock_object_t*>( hDomainHandle )->dditable;
auto pfnGetVFPointValues = dditable->zes.Overclock.pfnGetVFPointValues;
if( nullptr == pfnGetVFPointValues )
return ZE_RESULT_ERROR_UNINITIALIZED;
// convert loader handle to driver handle
hDomainHandle = reinterpret_cast<zes_overclock_object_t*>( hDomainHandle )->handle;
// forward to device-driver
result = pfnGetVFPointValues( hDomainHandle, VFType, VFArrayType, PointIndex, PointValue );
return result;
}
///////////////////////////////////////////////////////////////////////////////
/// @brief Intercept function for zesOverclockSetVFPointValues
__zedlllocal ze_result_t ZE_APICALL
zesOverclockSetVFPointValues(
zes_overclock_handle_t hDomainHandle, ///< [in] Handle for the component domain.
zes_vf_type_t VFType, ///< [in] Voltage or Freqency point to read.
uint32_t PointIndex, ///< [in] Point index - number between (0, max_num_points - 1).
uint32_t PointValue ///< [in] Writes frequency in 1kHz units or voltage in millivolt units to
///< custom V-F curve at the specified zero-based index
)
{
ze_result_t result = ZE_RESULT_SUCCESS;
// extract driver's function pointer table
auto dditable = reinterpret_cast<zes_overclock_object_t*>( hDomainHandle )->dditable;
auto pfnSetVFPointValues = dditable->zes.Overclock.pfnSetVFPointValues;
if( nullptr == pfnSetVFPointValues )
return ZE_RESULT_ERROR_UNINITIALIZED;
// convert loader handle to driver handle
hDomainHandle = reinterpret_cast<zes_overclock_object_t*>( hDomainHandle )->handle;
// forward to device-driver
result = pfnSetVFPointValues( hDomainHandle, VFType, PointIndex, PointValue );
return result;
}
///////////////////////////////////////////////////////////////////////////////
/// @brief Intercept function for zesDeviceEnumDiagnosticTestSuites
__zedlllocal ze_result_t ZE_APICALL
zesDeviceEnumDiagnosticTestSuites(
zes_device_handle_t hDevice, ///< [in] Sysman handle of the device.
uint32_t* pCount, ///< [in,out] pointer to the number of components of this type.
///< if count is zero, then the driver shall update the value with the
///< total number of components of this type that are available.
///< if count is greater than the number of components of this type that
///< are available, then the driver shall update the value with the correct
///< number of components.
zes_diag_handle_t* phDiagnostics ///< [in,out][optional][range(0, *pCount)] array of handle of components of
///< this type.
///< if count is less than the number of components of this type that are
///< available, then the driver shall only retrieve that number of
///< component handles.
)
{
ze_result_t result = ZE_RESULT_SUCCESS;
// extract driver's function pointer table
auto dditable = reinterpret_cast<zes_device_object_t*>( hDevice )->dditable;
auto pfnEnumDiagnosticTestSuites = dditable->zes.Device.pfnEnumDiagnosticTestSuites;
if( nullptr == pfnEnumDiagnosticTestSuites )
return ZE_RESULT_ERROR_UNINITIALIZED;
// convert loader handle to driver handle
hDevice = reinterpret_cast<zes_device_object_t*>( hDevice )->handle;
// forward to device-driver
result = pfnEnumDiagnosticTestSuites( hDevice, pCount, phDiagnostics );
if( ZE_RESULT_SUCCESS != result )
return result;
try
{
// convert driver handles to loader handles
for( size_t i = 0; ( nullptr != phDiagnostics ) && ( i < *pCount ); ++i )
phDiagnostics[ i ] = reinterpret_cast<zes_diag_handle_t>(
context->zes_diag_factory.getInstance( phDiagnostics[ i ], dditable ) );
}
catch( std::bad_alloc& )
{
result = ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY;
}
return result;
}
///////////////////////////////////////////////////////////////////////////////
/// @brief Intercept function for zesDiagnosticsGetProperties
__zedlllocal ze_result_t ZE_APICALL
zesDiagnosticsGetProperties(
zes_diag_handle_t hDiagnostics, ///< [in] Handle for the component.
zes_diag_properties_t* pProperties ///< [in,out] Structure describing the properties of a diagnostics test
///< suite
)
{
ze_result_t result = ZE_RESULT_SUCCESS;
// extract driver's function pointer table
auto dditable = reinterpret_cast<zes_diag_object_t*>( hDiagnostics )->dditable;
auto pfnGetProperties = dditable->zes.Diagnostics.pfnGetProperties;
if( nullptr == pfnGetProperties )
return ZE_RESULT_ERROR_UNINITIALIZED;
// convert loader handle to driver handle
hDiagnostics = reinterpret_cast<zes_diag_object_t*>( hDiagnostics )->handle;
// forward to device-driver
result = pfnGetProperties( hDiagnostics, pProperties );
return result;
}
///////////////////////////////////////////////////////////////////////////////
/// @brief Intercept function for zesDiagnosticsGetTests
__zedlllocal ze_result_t ZE_APICALL
zesDiagnosticsGetTests(
zes_diag_handle_t hDiagnostics, ///< [in] Handle for the component.
uint32_t* pCount, ///< [in,out] pointer to the number of tests.
///< if count is zero, then the driver shall update the value with the
///< total number of tests that are available.
///< if count is greater than the number of tests that are available, then
///< the driver shall update the value with the correct number of tests.
zes_diag_test_t* pTests ///< [in,out][optional][range(0, *pCount)] array of information about
///< individual tests sorted by increasing value of the `index` member of ::zes_diag_test_t.
///< if count is less than the number of tests that are available, then the
///< driver shall only retrieve that number of tests.
)
{
ze_result_t result = ZE_RESULT_SUCCESS;
// extract driver's function pointer table