@@ -5793,6 +5793,44 @@ impl<'nvml> Device<'nvml> {
57935793 }
57945794 }
57955795
5796+ /**
5797+ Get the list of performance modes for `Device`
5798+
5799+ Originally, NVML returns as a list in a form of a single string separated by comma.
5800+
5801+ # Errors
5802+
5803+ * `Uninitialized`, if the library has not been successfully initialized
5804+ * `NotSupported`, if the platform does not support this feature or some of the
5805+ requested event types.
5806+ * `GpuLost`, if this `Device` has fallen off the bus or is otherwise inaccessible
5807+ * `Unknown`, on any unexpected error. **If this error is returned, the `set` you
5808+
5809+ # Platform Support
5810+
5811+ Only supports Linux.
5812+ */
5813+ // Checked against local
5814+ // Tested
5815+ #[ cfg( target_os = "linux" ) ]
5816+ #[ doc( alias = "nvmlDeviceGetPerformanceModes" ) ]
5817+ pub fn performance_modes ( & self ) -> Result < ( Vec < String > , u32 ) , NvmlError > {
5818+ let sym = nvml_sym ( self . nvml . lib . nvmlDeviceGetPerformanceModes . as_ref ( ) ) ?;
5819+
5820+ unsafe {
5821+ let mut pmodes: nvmlDevicePerfModes_t = mem:: zeroed ( ) ;
5822+
5823+ nvml_try ( sym ( self . device , & mut pmodes) ) ?;
5824+
5825+ let modes_str = CStr :: from_ptr ( pmodes. str_ . as_ptr ( ) ) ;
5826+ let modes = modes_str. to_str ( ) ?;
5827+ Ok ( (
5828+ modes. split ( ';' ) . map ( str:: to_string) . collect ( ) ,
5829+ pmodes. version ,
5830+ ) )
5831+ }
5832+ }
5833+
57965834 /**
57975835 Gets the active vGPU instances for `Device`
57985836
@@ -7112,6 +7150,13 @@ mod test {
71127150 test_with_device ( 3 , & nvml, |device| device. is_drain_enabled ( None ) )
71137151 }
71147152
7153+ #[ cfg( target_os = "linux" ) ]
7154+ #[ test]
7155+ fn performance_modes ( ) {
7156+ let nvml = nvml ( ) ;
7157+ test_with_device ( 3 , & nvml, |device| device. performance_modes ( ) )
7158+ }
7159+
71157160 #[ cfg( target_os = "linux" ) ]
71167161 #[ test]
71177162 fn active_vgpus ( ) {
0 commit comments