X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;ds=sidebyside;f=dqsub;h=7fe5f9afd7949fd0d991321c97aec7b36b4b826c;hb=2051f76c3a53881a1d524e7923bb2592798534d4;hp=af930905c2ba33bf1636b5ae04cec47c38b0e522;hpb=25c7a523f17b043a2a8f6abc9715e11e78256b7f;p=uiuc_igb_scripts.git diff --git a/dqsub b/dqsub index af93090..7fe5f9a 100755 --- a/dqsub +++ b/dqsub @@ -26,6 +26,8 @@ dqsub [options] --nodes nodes to use --array array mode (one of 'chdir' or 'xargs' or '') --array-from file to read arrays from (default STDIN) + --array-per-job number of array items to handle in each job (default 1) + --array-all-in-one-job Run all of the array items in one job --ppn processors per node to use --mem memory to request --dir Directory to run the script in (default current directory) @@ -79,6 +81,7 @@ dqsub use IO::File; use Cwd qw(getcwd abs_path); +use POSIX qw(ceil); use vars qw($DEBUG); my %options = (nodes => 1, @@ -88,6 +91,7 @@ my %options = (nodes => 1, help => 0, man => 0, interactive => 0, + array_per_job => 1, ); GetOptions(\%options, @@ -96,6 +100,9 @@ GetOptions(\%options, 'nodes=i', 'array=s', 'array_from|array-from=s', + 'array_per_job|array-per-job=i', + 'array_slot_limit|array-slot-limit=i', + 'array_all_in_one_job|array-all-in-one-job!', 'ppn|processors-per-node=i', 'mem|memory=s', 'dir=s', @@ -135,7 +142,14 @@ if ($options{interactive}) { if ($options{array}) { @array = read_array_options(\%options) if $options{array}; # the -t option gives the range of elements for an array job - push @qsub_options,'-t','1-'. scalar @array; + if ($options{array_all_in_one_job}) { + $options{array_per_job} = scalar @array; + } else { + push @qsub_options,'-t','1-'. ceil(scalar @array / $options{array_per_job}); + if ($options{array_slot_limit}) { + $qsub_options[$#qsub_options] .= '%'.$options{array_slot_limit}; + } + } } call_qsub(\@qsub_options,write_qsub_script(\%options,\@ARGV,\@array)); } @@ -158,9 +172,12 @@ sub generate_qsub_options{ $l[$#l] .= ':ppn='.$options->{ppn}; } if ($options->{mem}) { - push @l,'mem=',$options->{mem}; + push @l,'mem='.$options->{mem}; } push @qo,'-l',join(',',@l) if @l; + if ($options->{interactive}) { + push @qo,'-I'; + } return @qo; } @@ -199,7 +216,51 @@ sub write_qsub_script { # this script was written by dqsub EOF if (defined $opt->{array}) { - die "--array is currently not implemented"; + my @subshell = ('',''); + my $array_opt = join("\n",@{$array}); + my $max_array = scalar @{$array}; + my $apjm1 = $opt->{array_per_job} - 1; + if ($opt->{array_per_job} > 1) { + # we will use subshells if there are more than one array + # items per job + @subshell = ('(',')'); + $script .= <{array_per_job}); do +# in some cases, the jobs aren't going to come out evenly. Handle that. +JOBNUM=\$(( \${PBS_ARRAYID:=1} * $opt->{array_per_job} + \$i - $opt->{array_per_job} )) +if [ \$JOBNUM -le $max_array ]; then +OPT=\$(sed -n -e "\$JOBNUM p"<<'_HERE_DOC_END_' +EOF + } else { + $script .= <{array} eq 'chdir') { + $script .= <{array_per_job} > 1) { + $script .= <