summaryrefslogtreecommitdiff
path: root/vest/parallelize.pl
diff options
context:
space:
mode:
authorredpony <redpony@ec762483-ff6d-05da-a07a-a48fb63a330f>2010-06-28 00:23:35 +0000
committerredpony <redpony@ec762483-ff6d-05da-a07a-a48fb63a330f>2010-06-28 00:23:35 +0000
commit875daff93c149ca5ed63ae0cdcf20be06b72d778 (patch)
tree27adfb34f335ab85a5301ae4e8d62e261f021d12 /vest/parallelize.pl
parentdb978c786c2b9eef4d730f68e3ae6cf6081c1d29 (diff)
fix mert to avoid fork problem, simplify parallelize
git-svn-id: https://ws10smt.googlecode.com/svn/trunk@30 ec762483-ff6d-05da-a07a-a48fb63a330f
Diffstat (limited to 'vest/parallelize.pl')
-rwxr-xr-xvest/parallelize.pl30
1 files changed, 11 insertions, 19 deletions
diff --git a/vest/parallelize.pl b/vest/parallelize.pl
index f01232c8..8b3f56dd 100755
--- a/vest/parallelize.pl
+++ b/vest/parallelize.pl
@@ -26,7 +26,7 @@ my $errordir;
my $multiline;
my @files_to_stage;
my $verbose = 1;
-my $nodelist;
+my $numnodes;
my $user = $ENV{"USER"};
my $pmem = "2g";
@@ -40,21 +40,12 @@ if (GetOptions(
"multi-line" => \$multiline,
"file=s" => \@files_to_stage,
"verbose" => \$verbose,
- "nodelist=s" => \$nodelist,
+ "jobs=i" => \$numnodes,
"pmem=s" => \$pmem
) == 0 || @ARGV == 0){
print_help();
}
-my @nodes = grep(/^[cd]\d\d$/, split(/\n/, `pbsnodes -a`));
-if ($nodelist){
- @nodes = split(/ /, $nodelist);
-}
-
-if ($verbose){
- print STDERR "Compute nodes: @nodes\n";
-}
-
my $cmd = "";
for my $arg (@ARGV){
if ($arg=~ /\s/){
@@ -64,6 +55,8 @@ for my $arg (@ARGV){
}
}
+die "Please specify a command to parallelize\n" if $cmd eq '';
+
if ($errordir){
`mkdir -p $errordir`;
}
@@ -132,8 +125,8 @@ if (my $pid = fork){
print STDERR $script;
print STDERR "====\n";
}
- for my $node (@nodes){
- launch_job_on_node($node);
+ for (my $jobn=0; $jobn<$numnodes; $jobn++){
+ launch_job_on_node(1);
}
if ($recycle_clients) {
my $ret;
@@ -143,9 +136,8 @@ if (my $pid = fork){
#print STDERR "waitpid $pid ret = $ret \n";
if ($ret != 0) {last; } # break
$livejobs = numof_live_jobs();
- if ( $#nodes >= $livejobs ) { # a client terminated
- my $numof_nodes = scalar @nodes;
- print STDERR "num of requested nodes = $numof_nodes; num of currently live jobs = $livejobs; Client terminated - launching another.\n";
+ if ($numnodes >= $livejobs ) { # a client terminated
+ print STDERR "num of requested nodes = $numnodes; num of currently live jobs = $livejobs; Client terminated - launching another.\n";
launch_job_on_node(1); # TODO: support named nodes
} else {
sleep (60);
@@ -197,6 +189,7 @@ sub launch_job_on_node {
if ($verbose){ print STDERR "Launched client job: $jobid"; }
push(@cleanup_cmds, "`qdel $jobid 2> /dev/null`");
$jobid =~ s/^(\d+)(.*?)$/\1/g;
+ $jobid =~ s/^Your job (\d+) .*$/\1/;
print STDERR "short job id $jobid\n";
if ($joblist == "") { $joblist = $jobid; }
else {$joblist = $joblist . "\|" . $jobid; }
@@ -244,9 +237,8 @@ options:
-v, --verbose
Print diagnostic informatoin on stderr.
- -n, --nodelist
- Space-delimited list of nodes to request. There is
- one qsub command per node.
+ -j, --jobs
+ Number of jobs to use.
-p, --pmem
pmem setting for each job.