[padb] r333 committed - Convert mpd to use setup_job rather than setup_pcmd....

padb at googlecode.com padb at googlecode.com
Wed Nov 25 13:50:10 GMT 2009


Revision: 333
Author: apittman
Date: Wed Nov 25 05:49:12 2009
Log: Convert mpd to use setup_job rather than setup_pcmd.
Handle the removal of the temory file with a callback function
(which is shared with open_setup_job) which allows me to get
rid of cleanup_pcmd() completely.
Return the pid=>rank mapping from mpd_setup_job which avoids
having to call mpdlistjobs on the target nodes.  As this was
calling a global operation from every node simultanously this
should help the startup time dramatically on larger mpich2 jobs.

http://code.google.com/p/padb/source/detail?r=333

Modified:
  /trunk/src/padb

=======================================
--- /trunk/src/padb	Wed Nov 25 05:15:57 2009
+++ /trunk/src/padb	Wed Nov 25 05:49:12 2009
@@ -359,7 +359,6 @@
  # get_active_jobs user List      yes      Return list of all active job  
for user.
  # is_job_running  job  Bool      no       Check if a given job is running.
  # job_to_key      job  key       no       Convert from jobId to shm key.
-# cleanup_pcmd    -    -         no       Cleans up and temporary files.
  # find_pids       job  -         maybe    Called on the inner to locate  
pids.

  # In addition one of these two is preferred setup_job has more
@@ -421,9 +420,7 @@
  $rmgr{mpd} = {
      is_installed           => \&mpd_is_installed,
      get_active_jobs        => \&mpd_get_jobs,
-    setup_pcmd             => \&mpd_setup_pcmd,
-    cleanup_pcmd           => \&mpd_cleanup_pcmd,
-    find_pids              => \&mpd_find_pids,
+    setup_job              => \&mpd_setup_job,
      require_inner_callback => 1,
  };

@@ -2574,10 +2571,9 @@
          }
          if ( $key eq 'pid' ) {
              $pid = $value;
-            $jobs{$job}{pids}{$host}{$value}++;
          }
          if ( $key eq 'rank' ) {
-            $jobs{$job}{pids}{$host}{$pid} = $value;
+            $jobs{$job}{pids}{$host}{$value} = $pid;
              if (   ( not defined $jobs{$job}{lastproc} )
                  or ( $value > $jobs{$job}{lastproc} ) )
              {
@@ -2598,9 +2594,7 @@
      return @jobs;
  }

-my $mpd_dfile;
-
-sub mpd_setup_pcmd {
+sub mpd_setup_job {
      my $job = shift;

      my $d = mpd_get_data();
@@ -2614,17 +2608,23 @@
      }
      close $fh;

-    $mpd_dfile = $fn;
-
      my $cmd = "mpdrun -machinefile $fn -np $i";

-    my $hosts = @hosts;
-
-    return ( $cmd, $d->{$job}{lastproc} + 1, $hosts );
+    my %pcmd;
+    $pcmd{nprocesses}   = $d->{$job}{lastproc} + 1;
+    $pcmd{nhosts}       = @hosts;
+    $pcmd{process_data} = $d->{$job}{pids};
+    $pcmd{command}      = $cmd;
+    @{ $pcmd{host_list} } = @hosts;
+    $pcmd{cleanup_cb}     = \&unlink_file;
+    $pcmd{cleanup_handle} = $fn;
+
+    return %pcmd;
  }

-sub mpd_cleanup_pcmd {
-    unlink $mpd_dfile if ( defined $mpd_dfile );
+sub unlink_file {
+    my $file = shift;
+    unlink $file;
      return;
  }

@@ -2828,18 +2828,12 @@
      $pcmd{process_data} = $open_jobs{$job}{ranks};
      $pcmd{command}      = $cmd;
      @{ $pcmd{host_list} } = @hosts;
-    $pcmd{cleanup_cb}     = \&open_cleanup_job;
+    $pcmd{cleanup_cb}     = \&unlink_file;
      $pcmd{cleanup_handle} = $fn;

      return %pcmd;

  }
-
-sub open_cleanup_job {
-    my $file = shift;
-    unlink $file;
-    return;
-}

   
###############################################################################
  #
@@ -2992,15 +2986,6 @@
      @{ $pcmd{host_list} } = @hosts;

      return %pcmd;
-
-    my $cmd = $EMPTY_STRING;
-    if ( $hosts[0] ne hostname() or @hosts > 1 ) {
-        my $hlist = join q{,}, @hosts;
-        $cmd = "pdsh -w $hlist";
-    }
-
-    my $hc = @hosts;
-    return ( $cmd, $nprocs, $hc, \%pt );
  }

   
###############################################################################
@@ -3177,11 +3162,13 @@
          my ( $cmd, $nprocesses, $nhosts, $pd ) =
            $rmgr{ $conf{rmgr} }{setup_pcmd}($job);
          my %pcmd = (
-            command      => $cmd,
-            nprocesses   => $nprocesses,
-            nhosts       => $nhosts,
-            process_data => $pd
+            command    => $cmd,
+            nprocesses => $nprocesses,
+            nhosts     => $nhosts,
          );
+        if ( defined $pd ) {
+            $pcmd{process_data} = $pd;
+        }
          return %pcmd;
      }

@@ -3213,14 +3200,6 @@
      }
      return %pcmd;
  }
-
-sub cleanup_pcmd {
-    my $job = shift;
-    if ( defined $rmgr{ $conf{rmgr} }{cleanup_pcmd} ) {
-        $rmgr{ $conf{rmgr} }{cleanup_pcmd}();
-    }
-    return;
-}

   
###############################################################################
  #
@@ -4866,8 +4845,6 @@
      if ( defined $pcmd{cleanup_cb} ) {
          $pcmd{cleanup_cb}( $pcmd{cleanup_handle} );
      }
-
-    cleanup_pcmd();

      return $errors;
  }
@@ -8127,18 +8104,6 @@
      maybe_show_pid( 0, $pid );
      return;
  }
-
-sub mpd_find_pids {
-    my $job = shift;
-    my $d   = mpd_get_data();
-
-    my $j = $d->{$job}{pids}{ $inner_conf{hostname} };
-
-    foreach my $pid ( keys %{$j} ) {
-        maybe_show_pid( $j->{$pid}, $pid );
-    }
-    return;
-}

  #
  # PBS support




More information about the padb-devel mailing list