4949 StaticBoard ,
5050 StaticBus ,
5151 StaticCacheInfoItem ,
52+ StaticClockData ,
5253 StaticDriver ,
54+ StaticFrequencyLevels ,
5355 StaticNuma ,
5456 StaticPolicy ,
5557 StaticSocPstate ,
@@ -111,7 +113,7 @@ def _get_amdsmi_data(self) -> AmdSmiDataModel | None:
111113 try :
112114 version = self ._get_amdsmi_version ()
113115 processes = self .get_process ()
114- partition = self .get_partition ()
116+ partition = self ._get_partition ()
115117 firmware = self .get_firmware ()
116118 gpu_list = self .get_gpu_list ()
117119 statics = self .get_static ()
@@ -296,7 +298,7 @@ def get_process(self) -> list[Processes] | None:
296298 )
297299 return out
298300
299- def get_partition (self ) -> Partition | None :
301+ def _get_partition (self ) -> Partition | None :
300302 devices = self ._get_handles ()
301303 current : list [PartitionCurrent ] = []
302304 memparts : list [PartitionMemory ] = []
@@ -608,6 +610,7 @@ def _vu(val: object, unit: str) -> ValueUnit | None:
608610 soc_pstate_model = self ._get_soc_pstate (h )
609611 xgmi_plpd_model = self ._get_xgmi_plpd (h )
610612 cache_info_model = self ._get_cache_info (h )
613+ clock_model = self ._get_clock (h )
611614
612615 try :
613616 out .append (
@@ -626,10 +629,11 @@ def _vu(val: object, unit: str) -> ValueUnit | None:
626629 vram = vram_model ,
627630 cache_info = cache_info_model ,
628631 partition = None ,
629- clock = None , # TODO amdsmi_get_clk_freq??
632+ clock = clock_model ,
630633 )
631634 )
632635 except ValidationError as e :
636+ self .logger .error (e )
633637 self ._log_event (
634638 category = EventCategory .APPLICATION ,
635639 description = "Failed to build AmdSmiStatic" ,
@@ -640,7 +644,16 @@ def _vu(val: object, unit: str) -> ValueUnit | None:
640644 return out
641645
642646 def _get_soc_pstate (self , h ) -> StaticSocPstate | None :
643- data = self ._smi_try (self ._amdsmi .amdsmi_get_soc_pstate , h , default = None )
647+ fn = getattr (self ._amdsmi , "amdsmi_get_soc_pstate" , None )
648+ if not callable (fn ):
649+ self ._log_event (
650+ category = EventCategory .APPLICATION ,
651+ description = "amdsmi_get_soc_pstate not exposed by amdsmi build" ,
652+ priority = EventPriority .INFO ,
653+ )
654+ return None
655+
656+ data = self ._smi_try (fn , h , default = None )
644657 if not isinstance (data , dict ):
645658 return None
646659
@@ -684,7 +697,16 @@ def _get_soc_pstate(self, h) -> StaticSocPstate | None:
684697 return None
685698
686699 def _get_xgmi_plpd (self , h ) -> StaticXgmiPlpd | None :
687- data = self ._smi_try (self ._amdsmi .amdsmi_get_xgmi_plpd , h , default = None )
700+ fn = getattr (self ._amdsmi , "amdsmi_get_xgmi_plpd" , None )
701+ if not callable (fn ):
702+ self ._log_event (
703+ category = EventCategory .APPLICATION ,
704+ description = "XGMI PLPD not exposed by this amdsmi build" ,
705+ priority = EventPriority .INFO ,
706+ )
707+ return None
708+
709+ data = self ._smi_try (fn , h , default = None )
688710 if not isinstance (data , dict ):
689711 return None
690712
@@ -802,6 +824,52 @@ def _as_list_str(v) -> list[str]:
802824
803825 return out
804826
827+
828+ def _get_clock (self , h ) -> StaticClockData | None :
829+ """
830+ """
831+ fn = getattr (self ._amdsmi , "amdsmi_get_clk_freq" , None )
832+ clk_type = getattr (self ._amdsmi , "AmdSmiClkType" , None )
833+ if not callable (fn ) or clk_type is None or not hasattr (clk_type , "SYS" ):
834+ return None
835+
836+ data = self ._smi_try (fn , h , clk_type .SYS , default = None )
837+ if not isinstance (data , dict ):
838+ return None
839+
840+ freqs_raw = data .get ("frequency" )
841+ if not isinstance (freqs_raw , list ):
842+ return None
843+
844+ freqs_mhz : list [int ] = []
845+ for v in freqs_raw :
846+ if isinstance (v , (int , float )):
847+ freqs_mhz .append (int (round (float (v ) / 1_000_000.0 )))
848+
849+ if not freqs_mhz :
850+ return None
851+
852+ def _fmt (n : int | None ) -> str | None :
853+ return None if n is None else f"{ n } MHz"
854+
855+ level0 : str = _fmt (freqs_mhz [0 ]) or "0 MHz"
856+ level1 : str | None = _fmt (freqs_mhz [1 ]) if len (freqs_mhz ) > 1 else None
857+ level2 : str | None = _fmt (freqs_mhz [2 ]) if len (freqs_mhz ) > 2 else None
858+
859+ cur_raw = data .get ("current" )
860+ try :
861+ current : int | None = None if cur_raw in (None , "" , "N/A" ) else int (cur_raw )
862+ except Exception :
863+ current = None
864+
865+ try :
866+ levels = StaticFrequencyLevels (Level_0 = level0 , Level_1 = level1 , Level_2 = level2 )
867+ return StaticClockData (frequency = levels , current = current )
868+ except ValidationError :
869+ return None
870+
871+
872+
805873 def collect_data (
806874 self ,
807875 args = None ,
0 commit comments