@@ -624,6 +624,63 @@ impl<'nvml> Device<'nvml> {
624
624
}
625
625
}
626
626
627
+ fn mps_running_compute_processes_count ( & self ) -> Result < c_uint , NvmlError > {
628
+ let sym = nvml_sym (
629
+ self . nvml
630
+ . lib
631
+ . nvmlDeviceGetMPSComputeRunningProcesses_v3
632
+ . as_ref ( ) ,
633
+ ) ?;
634
+
635
+ unsafe {
636
+ let mut len: c_uint = 0 ;
637
+
638
+ match sym ( self . device , & mut len, ptr:: null_mut ( ) ) {
639
+ nvmlReturn_enum_NVML_ERROR_INSUFFICIENT_SIZE => Ok ( len) ,
640
+ another_attempt => nvml_try ( another_attempt) . map ( |_| 0 ) ,
641
+ }
642
+ }
643
+ }
644
+
645
+ /**
646
+ Gets information about processes with a compute context running on this `Device`.
647
+ Note that processes list can differ between the accounting call and the list gathering
648
+
649
+ # Errors
650
+
651
+ * `Uninitialized`, if the library has not been successfully initialized
652
+ * `InvalidArg`, if this `Device` is invalid
653
+ * `GpuLost`, if this `Device` has fallen off the bus or is otherwise inaccessible
654
+ * `Unknown`, on any unexpected error
655
+
656
+ # Device Support
657
+
658
+ Supports Volta or newer fully supported devices.
659
+ */
660
+ #[ doc( alias = "nvmlDeviceGetMPSComputeRunningProcesses_v3" ) ]
661
+ pub fn mps_running_compute_processes ( & self ) -> Result < Vec < ProcessInfo > , NvmlError > {
662
+ let sym = nvml_sym (
663
+ self . nvml
664
+ . lib
665
+ . nvmlDeviceGetMPSComputeRunningProcesses_v3
666
+ . as_ref ( ) ,
667
+ ) ?;
668
+
669
+ unsafe {
670
+ let mut len: c_uint = match self . mps_running_compute_processes_count ( ) ? {
671
+ 0 => return Ok ( vec ! [ ] ) ,
672
+ value => value,
673
+ } ;
674
+
675
+ let mut processes: Vec < nvmlProcessInfo_t > = Vec :: with_capacity ( len as usize ) ;
676
+
677
+ nvml_try ( sym ( self . device , & mut len, processes. as_mut_ptr ( ) ) ) ?;
678
+
679
+ processes. set_len ( len as usize ) ;
680
+ Ok ( processes. into_iter ( ) . map ( ProcessInfo :: from) . collect ( ) )
681
+ }
682
+ }
683
+
627
684
/**
628
685
Gets the number of processes with a compute context running on this `Device`.
629
686
@@ -6633,6 +6690,12 @@ mod test {
6633
6690
test_with_device ( 3 , & nvml, |device| device. running_compute_processes_v2 ( ) )
6634
6691
}
6635
6692
6693
+ #[ test]
6694
+ fn mps_running_compute_processes ( ) {
6695
+ let nvml = nvml ( ) ;
6696
+ test_with_device ( 3 , & nvml, |device| device. mps_running_compute_processes ( ) )
6697
+ }
6698
+
6636
6699
#[ cfg( target_os = "linux" ) ]
6637
6700
#[ test]
6638
6701
fn cpu_affinity ( ) {
0 commit comments