@@ -624,6 +624,45 @@ impl<'nvml> Device<'nvml> {
624624 }
625625 }
626626
627+ /**
628+ Gets information about processes with a compute context running on this `Device`.
629+ Note that processes list can differ between the accounting call and the list gathering
630+
631+ # Errors
632+
633+ * `Uninitialized`, if the library has not been successfully initialized
634+ * `InvalidArg`, if this `Device` is invalid
635+ * `GpuLost`, if this `Device` has fallen off the bus or is otherwise inaccessible
636+ * `Unknown`, on any unexpected error
637+
638+ # Device Support
639+
640+ Supports Volta or newer fully supported devices.
641+ */
642+ #[ doc( alias = "nvmlDeviceGetiMPSComputeRunningProcesses_v3" ) ]
643+ pub fn mps_running_compute_processes ( & self ) -> Result < Vec < ProcessInfo > , NvmlError > {
644+ let sym = nvml_sym (
645+ self . nvml
646+ . lib
647+ . nvmlDeviceGetMPSComputeRunningProcesses_v3
648+ . as_ref ( ) ,
649+ ) ?;
650+
651+ unsafe {
652+ let mut hints: c_uint = 0 ;
653+
654+ nvml_try ( sym ( self . device , & mut hints, ptr:: null_mut ( ) ) ) ?;
655+
656+ hints. checked_shr ( 1 ) ;
657+ let mut processes: Vec < nvmlProcessInfo_t > = Vec :: with_capacity ( hints as usize ) ;
658+
659+ nvml_try ( sym ( self . device , & mut hints, processes. as_mut_ptr ( ) ) ) ?;
660+
661+ processes. truncate ( hints as usize ) ;
662+ Ok ( processes. into_iter ( ) . map ( ProcessInfo :: from) . collect ( ) )
663+ }
664+ }
665+
627666 /**
628667 Gets the number of processes with a compute context running on this `Device`.
629668
@@ -6633,6 +6672,12 @@ mod test {
66336672 test_with_device ( 3 , & nvml, |device| device. running_compute_processes_v2 ( ) )
66346673 }
66356674
6675+ #[ test]
6676+ fn mps_running_compute_processes ( ) {
6677+ let nvml = nvml ( ) ;
6678+ test_with_device ( 3 , & nvml, |device| device. mps_running_compute_processes ( ) )
6679+ }
6680+
66366681 #[ cfg( target_os = "linux" ) ]
66376682 #[ test]
66386683 fn cpu_affinity ( ) {
0 commit comments