Monday, June 18, 2012

Parallel job handler using Perl

Many times as the ASIC design/verification engineer, we need to run several simulation (regressions) or many jobs in parallel. I often uses Parallel:ForkManager module from Perl to handle this parallel jobs submission easily.

E.g.

 # Run all test cases
  use Parallel::ForkManager; # beautiful parallel processor
  local $max = 20; # Max number of jobs to submit in parallel.
  $max =   0 unless $opt_parallel;
  $pm =    new Parallel::ForkManager($max) ;
  foreach (@tests) { // array of testcase names @tests
    my $pid = $pm->start and next ;
    local $t = $_;
    RunSim($t); // Run simulation for testcase $t
    $pm->finish;
  }
  $pm->wait_all_children;
}

No comments: