-
Notifications
You must be signed in to change notification settings - Fork 51
/
rocm_smi.h
executable file
·4033 lines (3787 loc) · 161 KB
/
rocm_smi.h
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
/*
* =============================================================================
* The University of Illinois/NCSA
* Open Source License (NCSA)
*
* Copyright (c) 2017-2023, Advanced Micro Devices, Inc.
* All rights reserved.
*
* Developed by:
*
* AMD Research and AMD ROC Software Development
*
* Advanced Micro Devices, Inc.
*
* www.amd.com
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
* deal with the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimers.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimers in
* the documentation and/or other materials provided with the distribution.
* - Neither the names of <Name of Development Group, Name of Institution>,
* nor the names of its contributors may be used to endorse or promote
* products derived from this Software without specific prior written
* permission.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS WITH THE SOFTWARE.
*
*/
#ifndef INCLUDE_ROCM_SMI_ROCM_SMI_H_
#define INCLUDE_ROCM_SMI_ROCM_SMI_H_
#ifdef __cplusplus
extern "C" {
#include <cstdint>
#else
#include <stdint.h>
#endif // __cplusplus
#include <stddef.h>
#include <stdbool.h>
#include "rocm_smi/kfd_ioctl.h"
/** \file rocm_smi.h
* Main header file for the ROCm SMI library.
* All required function, structure, enum, etc. definitions should be defined
* in this file.
*
* @brief The rocm_smi library api is new, and therefore subject to change
* either at the ABI or API level. Instead of marking every function prototype as "unstable", we are
* instead saying the API is unstable (i.e., changes are possible) while the
* major version remains 0. This means that if the API/ABI changes, we will
* not increment the major version to 1. Once the ABI stabilizes, we will
* increment the major version to 1, and thereafter increment it on all ABI
* breaks.
*/
//! Guaranteed maximum possible number of supported frequencies
#define RSMI_MAX_NUM_FREQUENCIES 32
//! Maximum possible value for fan speed. Should be used as the denominator
//! when determining fan speed percentage.
#define RSMI_MAX_FAN_SPEED 255
//! The number of points that make up a voltage-frequency curve definition
#define RSMI_NUM_VOLTAGE_CURVE_POINTS 3
/**
* @brief Error codes retured by rocm_smi_lib functions
*/
typedef enum {
RSMI_STATUS_SUCCESS = 0x0, //!< Operation was successful
RSMI_STATUS_INVALID_ARGS, //!< Passed in arguments are not valid
RSMI_STATUS_NOT_SUPPORTED, //!< The requested information or
//!< action is not available for the
//!< given input, on the given system
RSMI_STATUS_FILE_ERROR, //!< Problem accessing a file. This
//!< may because the operation is not
//!< supported by the Linux kernel
//!< version running on the executing
//!< machine
RSMI_STATUS_PERMISSION, //!< Permission denied/EACCESS file
//!< error. Many functions require
//!< root access to run.
RSMI_STATUS_OUT_OF_RESOURCES, //!< Unable to acquire memory or other
//!< resource
RSMI_STATUS_INTERNAL_EXCEPTION, //!< An internal exception was caught
RSMI_STATUS_INPUT_OUT_OF_BOUNDS, //!< The provided input is out of
//!< allowable or safe range
RSMI_STATUS_INIT_ERROR, //!< An error occurred when rsmi
//!< initializing internal data
//!< structures
RSMI_INITIALIZATION_ERROR = RSMI_STATUS_INIT_ERROR,
RSMI_STATUS_NOT_YET_IMPLEMENTED, //!< The requested function has not
//!< yet been implemented in the
//!< current system for the current
//!< devices
RSMI_STATUS_NOT_FOUND, //!< An item was searched for but not
//!< found
RSMI_STATUS_INSUFFICIENT_SIZE, //!< Not enough resources were
//!< available for the operation
RSMI_STATUS_INTERRUPT, //!< An interrupt occurred during
//!< execution of function
RSMI_STATUS_UNEXPECTED_SIZE, //!< An unexpected amount of data
//!< was read
RSMI_STATUS_NO_DATA, //!< No data was found for a given
//!< input
RSMI_STATUS_UNEXPECTED_DATA, //!< The data read or provided to
//!< function is not what was expected
RSMI_STATUS_BUSY, //!< A resource or mutex could not be
//!< acquired because it is already
//!< being used
RSMI_STATUS_REFCOUNT_OVERFLOW, //!< An internal reference counter
//!< exceeded INT32_MAX
RSMI_STATUS_SETTING_UNAVAILABLE, //!< Requested setting is unavailable
//!< for the current device
RSMI_STATUS_AMDGPU_RESTART_ERR, //!< Could not successfully restart
//!< the amdgpu driver
RSMI_STATUS_UNKNOWN_ERROR = 0xFFFFFFFF, //!< An unknown error occurred
} rsmi_status_t;
/**
* @brief Initialization flags
*
* Initialization flags may be OR'd together and passed to ::rsmi_init().
*/
typedef enum {
RSMI_INIT_FLAG_ALL_GPUS = 0x1, //!< Attempt to add all GPUs found
//!< (including non-AMD) to the list
//!< of devices from which SMI
//!< information can be retrieved. By
//!< default, only AMD devices are
//!< enumerated by RSMI.
RSMI_INIT_FLAG_RESRV_TEST1 = 0x800000000000000, //!< Reserved for test
} rsmi_init_flags_t;
/**
* @brief PowerPlay performance levels
*/
typedef enum {
RSMI_DEV_PERF_LEVEL_AUTO = 0, //!< Performance level is "auto"
RSMI_DEV_PERF_LEVEL_FIRST = RSMI_DEV_PERF_LEVEL_AUTO,
RSMI_DEV_PERF_LEVEL_LOW, //!< Keep PowerPlay levels "low",
//!< regardless of workload
RSMI_DEV_PERF_LEVEL_HIGH, //!< Keep PowerPlay levels "high",
//!< regardless of workload
RSMI_DEV_PERF_LEVEL_MANUAL, //!< Only use values defined by manually
//!< setting the RSMI_CLK_TYPE_SYS speed
RSMI_DEV_PERF_LEVEL_STABLE_STD, //!< Stable power state with profiling
//!< clocks
RSMI_DEV_PERF_LEVEL_STABLE_PEAK, //!< Stable power state with peak clocks
RSMI_DEV_PERF_LEVEL_STABLE_MIN_MCLK, //!< Stable power state with minimum
//!< memory clock
RSMI_DEV_PERF_LEVEL_STABLE_MIN_SCLK, //!< Stable power state with minimum
//!< system clock
RSMI_DEV_PERF_LEVEL_DETERMINISM, //!< Performance determinism state
RSMI_DEV_PERF_LEVEL_LAST = RSMI_DEV_PERF_LEVEL_DETERMINISM,
RSMI_DEV_PERF_LEVEL_UNKNOWN = 0x100 //!< Unknown performance level
} rsmi_dev_perf_level_t;
/// \cond Ignore in docs.
typedef rsmi_dev_perf_level_t rsmi_dev_perf_level;
/// \endcond
/**
* @brief Available clock types.
*/
/**
* @brief Software components
*/
typedef enum {
RSMI_SW_COMP_FIRST = 0x0,
RSMI_SW_COMP_DRIVER = RSMI_SW_COMP_FIRST, //!< Driver
RSMI_SW_COMP_LAST = RSMI_SW_COMP_DRIVER
} rsmi_sw_component_t;
/**
* Event counter types
*/
/**
* @brief Handle to performance event counter
*/
typedef uintptr_t rsmi_event_handle_t;
/**
* Event Groups
*
* @brief Enum denoting an event group. The value of the enum is the
* base value for all the event enums in the group.
*/
typedef enum {
RSMI_EVNT_GRP_XGMI = 0, //!< Data Fabric (XGMI) related events
RSMI_EVNT_GRP_XGMI_DATA_OUT = 10, //!< XGMI Outbound data
RSMI_EVNT_GRP_INVALID = 0xFFFFFFFF
} rsmi_event_group_t;
/**
* Event types
* @brief Event type enum. Events belonging to a particular event group
* ::rsmi_event_group_t should begin enumerating at the ::rsmi_event_group_t
* value for that group.
*/
typedef enum {
RSMI_EVNT_FIRST = RSMI_EVNT_GRP_XGMI,
RSMI_EVNT_XGMI_FIRST = RSMI_EVNT_GRP_XGMI,
RSMI_EVNT_XGMI_0_NOP_TX = RSMI_EVNT_XGMI_FIRST, //!< NOPs sent to neighbor 0
RSMI_EVNT_XGMI_0_REQUEST_TX, //!< Outgoing requests to
//!< neighbor 0
RSMI_EVNT_XGMI_0_RESPONSE_TX, //!< Outgoing responses to
//!< neighbor 0
/**
* @brief
*
* Data beats sent to neighbor 0; Each beat represents 32 bytes.<br><br>
*
* XGMI throughput can be calculated by multiplying a BEATs event
* such as ::RSMI_EVNT_XGMI_0_BEATS_TX by 32 and dividing by
* the time for which event collection occurred,
* ::rsmi_counter_value_t.time_running (which is in nanoseconds). To get
* bytes per second, multiply this value by 10<sup>9</sup>.<br>
* <br>
* Throughput = BEATS/time_running * 10<sup>9</sup> (bytes/second)<br>
*/
// ie, Throughput = BEATS/time_running 10^9 bytes/sec
RSMI_EVNT_XGMI_0_BEATS_TX,
RSMI_EVNT_XGMI_1_NOP_TX, //!< NOPs sent to neighbor 1
RSMI_EVNT_XGMI_1_REQUEST_TX, //!< Outgoing requests to
//!< neighbor 1
RSMI_EVNT_XGMI_1_RESPONSE_TX, //!< Outgoing responses to
//!< neighbor 1
RSMI_EVNT_XGMI_1_BEATS_TX, //!< Data beats sent to
//!< neighbor 1; Each beat
//!< represents 32 bytes
RSMI_EVNT_XGMI_LAST = RSMI_EVNT_XGMI_1_BEATS_TX, // 5
RSMI_EVNT_XGMI_DATA_OUT_FIRST = RSMI_EVNT_GRP_XGMI_DATA_OUT, // 10
/*
* @brief Events in the RSMI_EVNT_GRP_XGMI_DATA_OUT group measure
* the number of beats sent on an XGMI link. Each beat represents
* 32 bytes. RSMI_EVNT_XGMI_DATA_OUT_n represents the number of
* outbound beats (each representing 32 bytes) on link n.<br><br>
*
* XGMI throughput can be calculated by multiplying a event
* such as ::RSMI_EVNT_XGMI_DATA_OUT_n by 32 and dividing by
* the time for which event collection occurred,
* ::rsmi_counter_value_t.time_running (which is in nanoseconds). To get
* bytes per second, multiply this value by 10<sup>9</sup>.<br>
* <br>
* Throughput = BEATS/time_running * 10<sup>9</sup> (bytes/second)<br>
*/
// ie, Throughput = BEATS/time_running 10^9 bytes/sec
RSMI_EVNT_XGMI_DATA_OUT_0 = RSMI_EVNT_XGMI_DATA_OUT_FIRST,
RSMI_EVNT_XGMI_DATA_OUT_1, //!< Outbound beats to neighbor 1
RSMI_EVNT_XGMI_DATA_OUT_2, //!< Outbound beats to neighbor 2
RSMI_EVNT_XGMI_DATA_OUT_3, //!< Outbound beats to neighbor 3
RSMI_EVNT_XGMI_DATA_OUT_4, //!< Outbound beats to neighbor 4
RSMI_EVNT_XGMI_DATA_OUT_5, //!< Outbound beats to neighbor 5
RSMI_EVNT_XGMI_DATA_OUT_LAST = RSMI_EVNT_XGMI_DATA_OUT_5,
RSMI_EVNT_LAST = RSMI_EVNT_XGMI_DATA_OUT_LAST,
} rsmi_event_type_t;
/**
* Event counter commands
*/
typedef enum {
RSMI_CNTR_CMD_START = 0, //!< Start the counter
RSMI_CNTR_CMD_STOP, //!< Stop the counter; note that this should not
//!< be used before reading.
} rsmi_counter_command_t;
/**
* Counter value
*/
typedef struct {
uint64_t value; //!< Counter value
uint64_t time_enabled; //!< Time that the counter was enabled
//!< (in nanoseconds)
uint64_t time_running; //!< Time that the counter was running
//!< (in nanoseconds)
} rsmi_counter_value_t;
/**
* Event notification event types
*/
typedef enum {
RSMI_EVT_NOTIF_VMFAULT = KFD_SMI_EVENT_VMFAULT, //!< VM page fault
RSMI_EVT_NOTIF_FIRST = RSMI_EVT_NOTIF_VMFAULT,
RSMI_EVT_NOTIF_THERMAL_THROTTLE = KFD_SMI_EVENT_THERMAL_THROTTLE,
RSMI_EVT_NOTIF_GPU_PRE_RESET = KFD_SMI_EVENT_GPU_PRE_RESET,
RSMI_EVT_NOTIF_GPU_POST_RESET = KFD_SMI_EVENT_GPU_POST_RESET,
RSMI_EVT_NOTIF_LAST = RSMI_EVT_NOTIF_GPU_POST_RESET
} rsmi_evt_notification_type_t;
/**
* Macro to generate event bitmask from event id
*/
#define RSMI_EVENT_MASK_FROM_INDEX(i) (1ULL << ((i) - 1))
//! Maximum number of characters an event notification message will be
#define MAX_EVENT_NOTIFICATION_MSG_SIZE 64
/**
* Event notification data returned from event notification API
*/
typedef struct {
uint32_t dv_ind; //!< Index of device that corresponds to the event
rsmi_evt_notification_type_t event; //!< Event type
char message[MAX_EVENT_NOTIFICATION_MSG_SIZE]; //!< Event message
} rsmi_evt_notification_data_t;
/**
* Clock types
*/
typedef enum {
RSMI_CLK_TYPE_SYS = 0x0, //!< System clock
RSMI_CLK_TYPE_FIRST = RSMI_CLK_TYPE_SYS,
RSMI_CLK_TYPE_DF, //!< Data Fabric clock (for ASICs
//!< running on a separate clock)
RSMI_CLK_TYPE_DCEF, //!< Display Controller Engine clock
RSMI_CLK_TYPE_SOC, //!< SOC clock
RSMI_CLK_TYPE_MEM, //!< Memory clock
RSMI_CLK_TYPE_PCIE, //!< PCIE clock
// Add new clocks to the end (not in the middle) and update
// RSMI_CLK_TYPE_LAST
RSMI_CLK_TYPE_LAST = RSMI_CLK_TYPE_MEM,
RSMI_CLK_INVALID = 0xFFFFFFFF
} rsmi_clk_type_t;
/// \cond Ignore in docs.
typedef rsmi_clk_type_t rsmi_clk_type;
/// \endcond
/**
* @brief Compute Partition. This enum is used to identify
* various compute partitioning settings.
*/
typedef enum {
RSMI_COMPUTE_PARTITION_INVALID = 0,
RSMI_COMPUTE_PARTITION_CPX, //!< Core mode (CPX)- Per-chip XCC with
//!< shared memory
RSMI_COMPUTE_PARTITION_SPX, //!< Single GPU mode (SPX)- All XCCs work
//!< together with shared memory
RSMI_COMPUTE_PARTITION_DPX, //!< Dual GPU mode (DPX)- Half XCCs work
//!< together with shared memory
RSMI_COMPUTE_PARTITION_TPX, //!< Triple GPU mode (TPX)- One-third XCCs
//!< work together with shared memory
RSMI_COMPUTE_PARTITION_QPX //!< Quad GPU mode (QPX)- Quarter XCCs
//!< work together with shared memory
} rsmi_compute_partition_type_t;
/// \cond Ignore in docs.
typedef rsmi_compute_partition_type_t rsmi_compute_partition_type;
/// \endcond
/**
* @brief NPS Modes. This enum is used to identify various
* NPS mode types.
*/
typedef enum {
RSMI_MEMORY_PARTITION_UNKNOWN = 0,
RSMI_MEMORY_PARTITION_NPS1, //!< NPS1 - All CCD & XCD data is interleaved
//!< accross all 8 HBM stacks (all stacks/1).
RSMI_MEMORY_PARTITION_NPS2, //!< NPS2 - 2 sets of CCDs or 4 XCD interleaved
//!< accross the 4 HBM stacks per AID pair
//!< (8 stacks/2).
RSMI_MEMORY_PARTITION_NPS4, //!< NPS4 - Each XCD data is interleaved accross
//!< accross 2 (or single) HBM stacks
//!< (8 stacks/8 or 8 stacks/4).
RSMI_MEMORY_PARTITION_NPS8, //!< NPS8 - Each XCD uses a single HBM stack
//!< (8 stacks/8). Or each XCD uses a single
//!< HBM stack & CCDs share 2 non-interleaved
//!< HBM stacks on its AID
//!< (AID[1,2,3] = 6 stacks/6).
} rsmi_nps_mode_type_t;
/// \cond Ignore in docs.
typedef rsmi_nps_mode_type_t rsmi_nps_mode_type;
/// \endcond
/**
* @brief Temperature Metrics. This enum is used to identify various
* temperature metrics. Corresponding values will be in millidegress
* Celcius.
*/
typedef enum {
RSMI_TEMP_CURRENT = 0x0, //!< Temperature current value.
RSMI_TEMP_FIRST = RSMI_TEMP_CURRENT,
RSMI_TEMP_MAX, //!< Temperature max value.
RSMI_TEMP_MIN, //!< Temperature min value.
RSMI_TEMP_MAX_HYST, //!< Temperature hysteresis value for max limit.
//!< (This is an absolute temperature, not a
//!< delta).
RSMI_TEMP_MIN_HYST, //!< Temperature hysteresis value for min limit.
//!< (This is an absolute temperature,
//!< not a delta).
RSMI_TEMP_CRITICAL, //!< Temperature critical max value, typically
//!< greater than corresponding temp_max values.
RSMI_TEMP_CRITICAL_HYST, //!< Temperature hysteresis value for critical
//!< limit. (This is an absolute temperature,
//!< not a delta).
RSMI_TEMP_EMERGENCY, //!< Temperature emergency max value, for chips
//!< supporting more than two upper temperature
//!< limits. Must be equal or greater than
//!< corresponding temp_crit values.
RSMI_TEMP_EMERGENCY_HYST, //!< Temperature hysteresis value for emergency
//!< limit. (This is an absolute temperature,
//!< not a delta).
RSMI_TEMP_CRIT_MIN, //!< Temperature critical min value, typically
//!< lower than corresponding temperature
//!< minimum values.
RSMI_TEMP_CRIT_MIN_HYST, //!< Temperature hysteresis value for critical
//!< minimum limit. (This is an absolute
//!< temperature, not a delta).
RSMI_TEMP_OFFSET, //!< Temperature offset which is added to the
//! temperature reading by the chip.
RSMI_TEMP_LOWEST, //!< Historical minimum temperature.
RSMI_TEMP_HIGHEST, //!< Historical maximum temperature.
RSMI_TEMP_LAST = RSMI_TEMP_HIGHEST
} rsmi_temperature_metric_t;
/// \cond Ignore in docs.
typedef rsmi_temperature_metric_t rsmi_temperature_metric;
/// \endcond
/**
* @brief This enumeration is used to indicate from which part of the device a
* temperature reading should be obtained.
*/
typedef enum {
RSMI_TEMP_TYPE_FIRST = 0,
RSMI_TEMP_TYPE_EDGE = RSMI_TEMP_TYPE_FIRST, //!< Edge GPU temperature
RSMI_TEMP_TYPE_JUNCTION, //!< Junction/hotspot
//!< temperature
RSMI_TEMP_TYPE_MEMORY, //!< VRAM temperature
RSMI_TEMP_TYPE_HBM_0, //!< HBM temperature instance 0
RSMI_TEMP_TYPE_HBM_1, //!< HBM temperature instance 1
RSMI_TEMP_TYPE_HBM_2, //!< HBM temperature instance 2
RSMI_TEMP_TYPE_HBM_3, //!< HBM temperature instance 3
RSMI_TEMP_TYPE_LAST = RSMI_TEMP_TYPE_HBM_3,
RSMI_TEMP_TYPE_INVALID = 0xFFFFFFFF //!< Invalid type
} rsmi_temperature_type_t;
/**
* @brief Voltage Metrics. This enum is used to identify various
* Volatge metrics. Corresponding values will be in millivolt.
*
*/
typedef enum {
RSMI_VOLT_CURRENT = 0x0, //!< Voltage current value.
RSMI_VOLT_FIRST = RSMI_VOLT_CURRENT,
RSMI_VOLT_MAX, //!< Voltage max value.
RSMI_VOLT_MIN_CRIT, //!< Voltage critical min value.
RSMI_VOLT_MIN, //!< Voltage min value.
RSMI_VOLT_MAX_CRIT, //!< Voltage critical max value.
RSMI_VOLT_AVERAGE, //!< Average voltage.
RSMI_VOLT_LOWEST, //!< Historical minimum voltage.
RSMI_VOLT_HIGHEST, //!< Historical maximum voltage.
RSMI_VOLT_LAST = RSMI_VOLT_HIGHEST
} rsmi_voltage_metric_t;
/**
* @brief This ennumeration is used to indicate which type of
* voltage reading should be obtained.
*/
typedef enum {
RSMI_VOLT_TYPE_FIRST = 0,
RSMI_VOLT_TYPE_VDDGFX = RSMI_VOLT_TYPE_FIRST, //!< Vddgfx GPU
//!< voltage
RSMI_VOLT_TYPE_LAST = RSMI_VOLT_TYPE_VDDGFX,
RSMI_VOLT_TYPE_INVALID = 0xFFFFFFFF //!< Invalid type
} rsmi_voltage_type_t;
/**
* @brief Pre-set Profile Selections. These bitmasks can be AND'd with the
* ::rsmi_power_profile_status_t.available_profiles returned from
* ::rsmi_dev_power_profile_presets_get to determine which power profiles
* are supported by the system.
*/
typedef enum {
RSMI_PWR_PROF_PRST_CUSTOM_MASK = 0x1, //!< Custom Power Profile
RSMI_PWR_PROF_PRST_VIDEO_MASK = 0x2, //!< Video Power Profile
RSMI_PWR_PROF_PRST_POWER_SAVING_MASK = 0x4, //!< Power Saving Profile
RSMI_PWR_PROF_PRST_COMPUTE_MASK = 0x8, //!< Compute Saving Profile
RSMI_PWR_PROF_PRST_VR_MASK = 0x10, //!< VR Power Profile
//!< 3D Full Screen Power Profile
RSMI_PWR_PROF_PRST_3D_FULL_SCR_MASK = 0x20,
RSMI_PWR_PROF_PRST_BOOTUP_DEFAULT = 0x40, //!< Default Boot Up Profile
RSMI_PWR_PROF_PRST_LAST = RSMI_PWR_PROF_PRST_BOOTUP_DEFAULT,
//!< Invalid power profile
RSMI_PWR_PROF_PRST_INVALID = 0xFFFFFFFFFFFFFFFF
} rsmi_power_profile_preset_masks_t;
/// \cond Ignore in docs.
typedef rsmi_power_profile_preset_masks_t rsmi_power_profile_preset_masks;
/// \endcond
/**
* @brief This enum is used to identify different GPU blocks.
*/
typedef enum {
RSMI_GPU_BLOCK_INVALID = 0x0000000000000000, //!< Used to indicate an
//!< invalid block
RSMI_GPU_BLOCK_FIRST = 0x0000000000000001,
RSMI_GPU_BLOCK_UMC = RSMI_GPU_BLOCK_FIRST, //!< UMC block
RSMI_GPU_BLOCK_SDMA = 0x0000000000000002, //!< SDMA block
RSMI_GPU_BLOCK_GFX = 0x0000000000000004, //!< GFX block
RSMI_GPU_BLOCK_MMHUB = 0x0000000000000008, //!< MMHUB block
RSMI_GPU_BLOCK_ATHUB = 0x0000000000000010, //!< ATHUB block
RSMI_GPU_BLOCK_PCIE_BIF = 0x0000000000000020, //!< PCIE_BIF block
RSMI_GPU_BLOCK_HDP = 0x0000000000000040, //!< HDP block
RSMI_GPU_BLOCK_XGMI_WAFL = 0x0000000000000080, //!< XGMI block
RSMI_GPU_BLOCK_DF = 0x0000000000000100, //!< DF block
RSMI_GPU_BLOCK_SMN = 0x0000000000000200, //!< SMN block
RSMI_GPU_BLOCK_SEM = 0x0000000000000400, //!< SEM block
RSMI_GPU_BLOCK_MP0 = 0x0000000000000800, //!< MP0 block
RSMI_GPU_BLOCK_MP1 = 0x0000000000001000, //!< MP1 block
RSMI_GPU_BLOCK_FUSE = 0x0000000000002000, //!< Fuse block
RSMI_GPU_BLOCK_LAST = RSMI_GPU_BLOCK_FUSE, //!< The highest bit position
//!< for supported blocks
RSMI_GPU_BLOCK_RESERVED = 0x8000000000000000
} rsmi_gpu_block_t;
/// \cond Ignore in docs.
typedef rsmi_gpu_block_t rsmi_gpu_block;
/// \endcond
/**
* @brief The current ECC state
*/
typedef enum {
RSMI_RAS_ERR_STATE_NONE = 0, //!< No current errors
RSMI_RAS_ERR_STATE_DISABLED, //!< ECC is disabled
RSMI_RAS_ERR_STATE_PARITY, //!< ECC errors present, but type unknown
RSMI_RAS_ERR_STATE_SING_C, //!< Single correctable error
RSMI_RAS_ERR_STATE_MULT_UC, //!< Multiple uncorrectable errors
RSMI_RAS_ERR_STATE_POISON, //!< Firmware detected error and isolated
//!< page. Treat as uncorrectable.
RSMI_RAS_ERR_STATE_ENABLED, //!< ECC is enabled
RSMI_RAS_ERR_STATE_LAST = RSMI_RAS_ERR_STATE_ENABLED,
RSMI_RAS_ERR_STATE_INVALID = 0xFFFFFFFF
} rsmi_ras_err_state_t;
/**
* @brief Types of memory
*/
typedef enum {
RSMI_MEM_TYPE_FIRST = 0,
RSMI_MEM_TYPE_VRAM = RSMI_MEM_TYPE_FIRST, //!< VRAM memory
RSMI_MEM_TYPE_VIS_VRAM, //!< VRAM memory that is visible
RSMI_MEM_TYPE_GTT, //!< GTT memory
RSMI_MEM_TYPE_LAST = RSMI_MEM_TYPE_GTT
} rsmi_memory_type_t;
/**
* @brief The values of this enum are used as frequency identifiers.
*/
typedef enum {
RSMI_FREQ_IND_MIN = 0, //!< Index used for the minimum frequency value
RSMI_FREQ_IND_MAX = 1, //!< Index used for the maximum frequency value
RSMI_FREQ_IND_INVALID = 0xFFFFFFFF //!< An invalid frequency index
} rsmi_freq_ind_t;
/// \cond Ignore in docs.
typedef rsmi_freq_ind_t rsmi_freq_ind;
/// \endcond
/**
* @brief The values of this enum are used to identify the various firmware
* blocks.
*/
typedef enum {
RSMI_FW_BLOCK_FIRST = 0,
RSMI_FW_BLOCK_ASD = RSMI_FW_BLOCK_FIRST,
RSMI_FW_BLOCK_CE,
RSMI_FW_BLOCK_DMCU,
RSMI_FW_BLOCK_MC,
RSMI_FW_BLOCK_ME,
RSMI_FW_BLOCK_MEC,
RSMI_FW_BLOCK_MEC2,
RSMI_FW_BLOCK_PFP,
RSMI_FW_BLOCK_RLC,
RSMI_FW_BLOCK_RLC_SRLC,
RSMI_FW_BLOCK_RLC_SRLG,
RSMI_FW_BLOCK_RLC_SRLS,
RSMI_FW_BLOCK_SDMA,
RSMI_FW_BLOCK_SDMA2,
RSMI_FW_BLOCK_SMC,
RSMI_FW_BLOCK_SOS,
RSMI_FW_BLOCK_TA_RAS,
RSMI_FW_BLOCK_TA_XGMI,
RSMI_FW_BLOCK_UVD,
RSMI_FW_BLOCK_VCE,
RSMI_FW_BLOCK_VCN,
RSMI_FW_BLOCK_LAST = RSMI_FW_BLOCK_VCN
} rsmi_fw_block_t;
/**
* @brief XGMI Status
*/
typedef enum {
RSMI_XGMI_STATUS_NO_ERRORS = 0,
RSMI_XGMI_STATUS_ERROR,
RSMI_XGMI_STATUS_MULTIPLE_ERRORS,
} rsmi_xgmi_status_t;
/**
* @brief Bitfield used in various RSMI calls
*/
typedef uint64_t rsmi_bit_field_t;
/// \cond Ignore in docs.
typedef rsmi_bit_field_t rsmi_bit_field;
/// \endcond
/**
* @brief Reserved Memory Page States
*/
typedef enum {
RSMI_MEM_PAGE_STATUS_RESERVED = 0, //!< Reserved. This gpu page is reserved
//!< and not available for use
RSMI_MEM_PAGE_STATUS_PENDING, //!< Pending. This gpu page is marked
//!< as bad and will be marked reserved
//!< at the next window.
RSMI_MEM_PAGE_STATUS_UNRESERVABLE //!< Unable to reserve this page
} rsmi_memory_page_status_t;
/**
* @brief Types for IO Link
*/
typedef enum _RSMI_IO_LINK_TYPE {
RSMI_IOLINK_TYPE_UNDEFINED = 0, //!< unknown type.
RSMI_IOLINK_TYPE_PCIEXPRESS = 1, //!< PCI Express
RSMI_IOLINK_TYPE_XGMI = 2, //!< XGMI
RSMI_IOLINK_TYPE_NUMIOLINKTYPES, //!< Number of IO Link types
RSMI_IOLINK_TYPE_SIZE = 0xFFFFFFFF //!< Max of IO Link types
} RSMI_IO_LINK_TYPE;
/**
* @brief The utilization counter type
*/
typedef enum {
RSMI_UTILIZATION_COUNTER_FIRST = 0,
//!< GFX Activity
RSMI_COARSE_GRAIN_GFX_ACTIVITY = RSMI_UTILIZATION_COUNTER_FIRST,
RSMI_COARSE_GRAIN_MEM_ACTIVITY, //!< Memory Activity
RSMI_UTILIZATION_COUNTER_LAST = RSMI_COARSE_GRAIN_MEM_ACTIVITY
} RSMI_UTILIZATION_COUNTER_TYPE;
/**
* @brief The utilization counter data
*/
typedef struct {
RSMI_UTILIZATION_COUNTER_TYPE type; //!< Utilization counter type
uint64_t value; //!< Utilization counter value
} rsmi_utilization_counter_t;
/**
* @brief Reserved Memory Page Record
*/
typedef struct {
uint64_t page_address; //!< Start address of page
uint64_t page_size; //!< Page size
rsmi_memory_page_status_t status; //!< Page "reserved" status
} rsmi_retired_page_record_t;
/**
* @brief Number of possible power profiles that a system could support
*/
#define RSMI_MAX_NUM_POWER_PROFILES (sizeof(rsmi_bit_field_t) * 8)
/**
* @brief This structure contains information about which power profiles are
* supported by the system for a given device, and which power profile is
* currently active.
*/
typedef struct {
/**
* Which profiles are supported by this system
*/
rsmi_bit_field_t available_profiles;
/**
* Which power profile is currently active
*/
rsmi_power_profile_preset_masks_t current;
/**
* How many power profiles are available
*/
uint32_t num_profiles;
} rsmi_power_profile_status_t;
/// \cond Ignore in docs.
typedef rsmi_power_profile_status_t rsmi_power_profile_status;
/// \endcond
/**
* @brief This structure holds information about clock frequencies.
*/
typedef struct {
/**
* The number of supported frequencies
*/
uint32_t num_supported;
/**
* The current frequency index
*/
uint32_t current;
/**
* List of frequencies.
* Only the first num_supported frequencies are valid.
*/
uint64_t frequency[RSMI_MAX_NUM_FREQUENCIES];
} rsmi_frequencies_t;
/// \cond Ignore in docs.
typedef rsmi_frequencies_t rsmi_frequencies;
/// \endcond
/**
* @brief This structure holds information about the possible PCIe
* bandwidths. Specifically, the possible transfer rates and their
* associated numbers of lanes are stored here.
*/
typedef struct {
/**
* Transfer rates (T/s) that are possible
*/
rsmi_frequencies_t transfer_rate;
/**
* List of lanes for corresponding transfer rate.
* Only the first num_supported bandwidths are valid.
*/
uint32_t lanes[RSMI_MAX_NUM_FREQUENCIES];
} rsmi_pcie_bandwidth_t;
/// \cond Ignore in docs.
typedef rsmi_pcie_bandwidth_t rsmi_pcie_bandwidth;
/// \endcond
/**
* @brief This structure holds version information.
*/
typedef struct {
uint32_t major; //!< Major version
uint32_t minor; //!< Minor version
uint32_t patch; //!< Patch, build or stepping version
const char *build; //!< Build string
} rsmi_version_t;
/// \cond Ignore in docs.
typedef rsmi_version_t rsmi_version;
/// \endcond
/**
* @brief This structure represents a range (e.g., frequencies or voltages).
*/
typedef struct {
uint64_t lower_bound; //!< Lower bound of range
uint64_t upper_bound; //!< Upper bound of range
} rsmi_range_t;
/// \cond Ignore in docs.
typedef rsmi_range_t rsmi_range;
/// \endcond
/**
* @brief This structure represents a point on the frequency-voltage plane.
*/
typedef struct {
uint64_t frequency; //!< Frequency coordinate (in Hz)
uint64_t voltage; //!< Voltage coordinate (in mV)
} rsmi_od_vddc_point_t;
/// \cond Ignore in docs.
typedef rsmi_od_vddc_point_t rsmi_od_vddc_point;
/// \endcond
/**
* @brief This structure holds 2 ::rsmi_range_t's, one for frequency and one for
* voltage. These 2 ranges indicate the range of possible values for the
* corresponding ::rsmi_od_vddc_point_t.
*/
typedef struct {
rsmi_range_t freq_range; //!< The frequency range for this VDDC Curve point
rsmi_range_t volt_range; //!< The voltage range for this VDDC Curve point
} rsmi_freq_volt_region_t;
/// \cond Ignore in docs.
typedef rsmi_freq_volt_region_t rsmi_freq_volt_region;
/// \endcond
/**
* ::RSMI_NUM_VOLTAGE_CURVE_POINTS number of ::rsmi_od_vddc_point_t's
*/
typedef struct {
/**
* Array of ::RSMI_NUM_VOLTAGE_CURVE_POINTS ::rsmi_od_vddc_point_t's that
* make up the voltage frequency curve points.
*/
rsmi_od_vddc_point_t vc_points[RSMI_NUM_VOLTAGE_CURVE_POINTS];
} rsmi_od_volt_curve_t;
/// \cond Ignore in docs.
typedef rsmi_od_volt_curve_t rsmi_od_volt_curve;
/// \endcond
/**
* @brief This structure holds the frequency-voltage values for a device.
*/
typedef struct {
rsmi_range_t curr_sclk_range; //!< The current SCLK frequency range
rsmi_range_t curr_mclk_range; //!< The current MCLK frequency range;
//!< (upper bound only)
rsmi_range_t sclk_freq_limits; //!< The range possible of SCLK values
rsmi_range_t mclk_freq_limits; //!< The range possible of MCLK values
/**
* @brief The current voltage curve
*/
rsmi_od_volt_curve_t curve;
uint32_t num_regions; //!< The number of voltage curve regions
} rsmi_od_volt_freq_data_t;
/// \cond Ignore in docs.
typedef rsmi_od_volt_freq_data_t rsmi_od_volt_freq_data;
/// \endcond
/**
* @brief The following structures hold the gpu metrics values for a device.
*/
/**
* @brief Size and version information of metrics data
*/
struct metrics_table_header_t {
// TODO(amd) Doxygen documents
/// \cond Ignore in docs.
uint16_t structure_size;
uint8_t format_revision;
uint8_t content_revision;
/// \endcond
};
/**
* @brief The following structure holds the gpu metrics values for a device.
*/
// Below is the assumed version of gpu_metric data on the device. If the device
// is using this version, we can read data directly into rsmi_gpu_metrics_t.
// If the device is using an older format, a conversion of formats will be
// required.
// DGPU targets have a format version of 1. APU targets have a format version of
// 2. Currently, only version 1 (DGPU) gpu_metrics is supported.
#define RSMI_GPU_METRICS_API_FORMAT_VER 1
// The content version increments when gpu_metrics is extended with new and/or
// existing field sizes are changed.
#define RSMI_GPU_METRICS_API_CONTENT_VER_1 1
#define RSMI_GPU_METRICS_API_CONTENT_VER_2 2
#define RSMI_GPU_METRICS_API_CONTENT_VER_3 3
// This should match NUM_HBM_INSTANCES
#define RSMI_NUM_HBM_INSTANCES 4
// Unit conversion factor for HBM temperatures
#define CENTRIGRADE_TO_MILLI_CENTIGRADE 1000
typedef struct {
// TODO(amd) Doxygen documents
/// \cond Ignore in docs.
struct metrics_table_header_t common_header;
/* Temperature */
uint16_t temperature_edge;
uint16_t temperature_hotspot;
uint16_t temperature_mem;
uint16_t temperature_vrgfx;
uint16_t temperature_vrsoc;
uint16_t temperature_vrmem;
/* Utilization */
uint16_t average_gfx_activity;
uint16_t average_umc_activity; // memory controller
uint16_t average_mm_activity; // UVD or VCN
/* Power/Energy */
uint16_t average_socket_power;
uint64_t energy_accumulator; // v1 mod. (32->64)
/* Driver attached timestamp (in ns) */
uint64_t system_clock_counter; // v1 mod. (moved from top of struct)
/* Average clocks */
uint16_t average_gfxclk_frequency;
uint16_t average_socclk_frequency;
uint16_t average_uclk_frequency;
uint16_t average_vclk0_frequency;
uint16_t average_dclk0_frequency;
uint16_t average_vclk1_frequency;
uint16_t average_dclk1_frequency;
/* Current clocks */
uint16_t current_gfxclk;
uint16_t current_socclk;
uint16_t current_uclk;
uint16_t current_vclk0;
uint16_t current_dclk0;
uint16_t current_vclk1;
uint16_t current_dclk1;
/* Throttle status */
uint32_t throttle_status;
/* Fans */
uint16_t current_fan_speed;
/* Link width/speed */
uint16_t pcie_link_width; // v1 mod.(8->16)
uint16_t pcie_link_speed; // in 0.1 GT/s; v1 mod. (8->16)
uint16_t padding; // new in v1
uint32_t gfx_activity_acc; // new in v1
uint32_t mem_actvity_acc; // new in v1
uint16_t temperature_hbm[RSMI_NUM_HBM_INSTANCES]; // new in v1
/// \endcond
} rsmi_gpu_metrics_t;
/**
* @brief This structure holds error counts.
*/
typedef struct {
uint64_t correctable_err; //!< Accumulated correctable errors
uint64_t uncorrectable_err; //!< Accumulated uncorrectable errors
} rsmi_error_count_t;
/**
* @brief This structure contains information specific to a process.
*/
typedef struct {
uint32_t process_id; //!< Process ID
uint32_t pasid; //!< PASID
uint64_t vram_usage; //!< VRAM usage
uint64_t sdma_usage; //!< SDMA usage in microseconds
uint32_t cu_occupancy; //!< Compute Unit usage in percent
} rsmi_process_info_t;
/**
* @brief Opaque handle to function-support object
*/
typedef struct rsmi_func_id_iter_handle * rsmi_func_id_iter_handle_t;
//! Place-holder "variant" for functions that have don't have any variants,
//! but do have monitors or sensors.
#define RSMI_DEFAULT_VARIANT 0xFFFFFFFFFFFFFFFF
/**
* @brief This union holds the value of an ::rsmi_func_id_iter_handle_t. The
* value may be a function name, or an ennumerated variant value of types
* such as ::rsmi_memory_type_t, ::rsmi_temperature_metric_t, etc.
*/
typedef union id {
uint64_t id; //!< uint64_t representation of value
const char *name; //!< name string (applicable to functions only)
union {
//!< Used for ::rsmi_memory_type_t variants
rsmi_memory_type_t memory_type;
//!< Used for ::rsmi_temperature_metric_t variants
rsmi_temperature_metric_t temp_metric;
//!< Used for ::rsmi_event_type_t variants