parallel: Implemented buggy :::+ and ::::+

This commit is contained in:
Ole Tange 2016-03-23 00:20:42 +01:00
parent 72df609f3d
commit 1cad1cf939
5 changed files with 59 additions and 29 deletions

3
NEWS
View file

@ -1,7 +1,8 @@
20160322 20160322
* env_parallel is a function that exports the environment (functions, * env_parallel is a function that exports the environment (functions,
aliases, variables, and arrays) to GNU Parallel. aliases, variables, and arrays) to GNU Parallel. Run 'man
env_parallel' for details.
* niceload --prg now searches for substrings if no process with the * niceload --prg now searches for substrings if no process with the
name is found. name is found.

View file

@ -154,6 +154,12 @@ git push origin $YYYYMMDD
== Update documentation == == Update documentation ==
Update version number + 1 Update version number + 1
YYYYMMDD=$(echo `yyyymmdd`+1 | bc)
perl -i -pe "/version/ and s/20\d\d\d\d\d\d/$YYYYMMDD/" src/parallel
perl -i -pe "/version/ and s/20\d\d\d\d\d\d/$YYYYMMDD/" src/sql
perl -i -pe "/version/ and s/20\d\d\d\d\d\d/$YYYYMMDD/" src/niceload
Unmodified beta since last version => production Unmodified beta since last version => production
Unmodified alpha since last version => beta Unmodified alpha since last version => beta
Modified => alpha Modified => alpha
@ -213,14 +219,15 @@ cc:Tim Cuthbertson <tim3d.junk@gmail.com>,
Ryoichiro Suzuki <ryoichiro.suzuki@gmail.com>, Ryoichiro Suzuki <ryoichiro.suzuki@gmail.com>,
Jesse Alama <jesse.alama@gmail.com> Jesse Alama <jesse.alama@gmail.com>
Subject: GNU Parallel 20160322 ('Bruxelles') released <<[stable]>> Subject: GNU Parallel 20160422 ('') released <<[stable]>>
GNU Parallel 20160322 ('Bruxelles') <<[stable]>> has been released. It is available for download at: http://ftp.gnu.org/gnu/parallel/ GNU Parallel 20160422 ('') <<[stable]>> has been released. It is available for download at: http://ftp.gnu.org/gnu/parallel/
<<No new functionality was introduced so this is a good candidate for a stable release.>> <<No new functionality was introduced so this is a good candidate for a stable release.>>
Haiku of the month: Haiku of the month:
<<>>
-- Ole Tange -- Ole Tange
New in this release: New in this release:
@ -241,18 +248,6 @@ for Big Data Applications https://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&arnumb
* <<Citation needed: Introspecting for RSA Key Material to Assist Intrusion Detection http://ieeexplore.ieee.org/xpl/login.jsp?tp=&arnumber=7331177&url=http%3A%2F%2Fieeexplore.ieee.org%2Fxpls%2Fabs_all.jsp%3Farnumber%3D7331177>> * <<Citation needed: Introspecting for RSA Key Material to Assist Intrusion Detection http://ieeexplore.ieee.org/xpl/login.jsp?tp=&arnumber=7331177&url=http%3A%2F%2Fieeexplore.ieee.org%2Fxpls%2Fabs_all.jsp%3Farnumber%3D7331177>>
* env_parallel is a function that exports the environment (functions, aliases, variables, and arrays) to GNU Parallel.
* niceload --prg now searches for substrings if no process with the name is found.
* GNU Parallel was cited in: Random Forest DBSCAN for USPTO Inventor Name Disambiguation http://arxiv.org/pdf/1602.01792.pdf
* GNU Parallel was mentioned (with wrong citation) in: Dual Level Parallel Computations for LargeScale High-Fidelity Database to Design Aerospace Vehicles http://www.nas.nasa.gov/assets/pdf/papers/Guruswamy_2013_DualLevelParallelComputations.pdf
* Using Parallel in Unix https://shearnrylan.wordpress.com/2016/02/22/using-parallel-in-unix/
* JPEG Squish uses (and co-distributes) GNU Parallel: http://dantidswell.co.uk/jpeg-squish/
* Bug fixes and man page updates. * Bug fixes and man page updates.
GNU Parallel - For people who live life in the parallel lane. GNU Parallel - For people who live life in the parallel lane.

View file

@ -24,7 +24,7 @@
use strict; use strict;
use Getopt::Long; use Getopt::Long;
$Global::progname="niceload"; $Global::progname="niceload";
$Global::version = 20160322; $Global::version = 20160323;
Getopt::Long::Configure("bundling","require_order"); Getopt::Long::Configure("bundling","require_order");
get_options_from_array(\@ARGV) || die_usage(); get_options_from_array(\@ARGV) || die_usage();
if($opt::version) { if($opt::version) {

View file

@ -854,6 +854,7 @@ sub options_hash {
"tollef" => \$opt::tollef, "tollef" => \$opt::tollef,
"gnu" => \$opt::gnu, "gnu" => \$opt::gnu,
"xapply" => \$opt::xapply, "xapply" => \$opt::xapply,
"xapplyinputsource=i" => \@opt::xapplyinputsource,
"bibtex|citation" => \$opt::bibtex, "bibtex|citation" => \$opt::bibtex,
"wc|willcite|will-cite|nn|nonotice|no-notice" => \$opt::willcite, "wc|willcite|will-cite|nn|nonotice|no-notice" => \$opt::willcite,
# Termination and retries # Termination and retries
@ -1180,7 +1181,7 @@ sub check_invalid_option_combinations {
sub init_globals { sub init_globals {
# Defaults: # Defaults:
$Global::version = 20160322; $Global::version = 20160323;
$Global::progname = 'parallel'; $Global::progname = 'parallel';
$Global::infinity = 2**31; $Global::infinity = 2**31;
$Global::debug = 0; $Global::debug = 0;
@ -1693,9 +1694,12 @@ sub read_args_from_command_line {
# Arguments given on the command line after: # Arguments given on the command line after:
# ::: ($Global::arg_sep) # ::: ($Global::arg_sep)
# :::: ($Global::arg_file_sep) # :::: ($Global::arg_file_sep)
# :::+ ($Global::arg_sep with --xapply)
# ::::+ ($Global::arg_file_sep with --xapply)
# Removes the arguments from @ARGV and: # Removes the arguments from @ARGV and:
# - puts filenames into -a # - puts filenames into -a
# - puts arguments into files and add the files to -a # - puts arguments into files and add the files to -a
# - adds --xapplyinputsource with 0/1 for each -a depending on :::+/::::+
# Input: # Input:
# @::ARGV = command option ::: arg arg arg :::: argfiles # @::ARGV = command option ::: arg arg arg :::: argfiles
# Uses: # Uses:
@ -1710,29 +1714,47 @@ sub read_args_from_command_line {
for(my $arg = shift @ARGV; @ARGV; $arg = shift @ARGV) { for(my $arg = shift @ARGV; @ARGV; $arg = shift @ARGV) {
if($arg eq $Global::arg_sep if($arg eq $Global::arg_sep
or or
$arg eq $Global::arg_file_sep) { $arg eq $Global::arg_sep."+"
or
$arg eq $Global::arg_file_sep
or
$arg eq $Global::arg_file_sep."+") {
my $group = $arg; # This group of arguments is args or argfiles my $group = $arg; # This group of arguments is args or argfiles
my @group; my @group;
while(defined ($arg = shift @ARGV)) { while(defined ($arg = shift @ARGV)) {
if($arg eq $Global::arg_sep if($arg eq $Global::arg_sep
or or
$arg eq $Global::arg_file_sep) { $arg eq $Global::arg_sep."+"
or
$arg eq $Global::arg_file_sep
or
$arg eq $Global::arg_file_sep."+") {
# exit while loop if finding new separator # exit while loop if finding new separator
last; last;
} else { } else {
# If not hitting ::: or :::: # If not hitting ::: :::+ :::: or ::::+
# Append it to the group # Append it to the group
push @group, $arg; push @group, $arg;
} }
} }
if($group=~/\+$/) {
# :::+ or ::::+
push @opt::xapplyinputsource, 1;
} else {
push @opt::xapplyinputsource, 0;
}
if($group eq $Global::arg_file_sep if($group eq $Global::arg_file_sep
or
$group eq $Global::arg_file_sep."+"
or ($opt::internal_pipe_means_argfiles and $opt::pipe) or ($opt::internal_pipe_means_argfiles and $opt::pipe)
) { ) {
# Group of file names on the command line. # Group of file names on the command line.
# Append args into -a # Append args into -a
push @opt::a, @group; push @opt::a, @group;
} elsif($group eq $Global::arg_sep) { } elsif($group eq $Global::arg_sep
or
$group eq $Global::arg_sep."+") {
# Group of arguments on the command line. # Group of arguments on the command line.
# Put them into a file. # Put them into a file.
# Create argfile # Create argfile
@ -9411,13 +9433,15 @@ sub nest_get {
# make all new combinations # make all new combinations
my @combarg = (); my @combarg = ();
for (my $fhn = 0; $fhn < $no_of_inputsources; $fhn++) { for (my $fhn = 0; $fhn < $no_of_inputsources; $fhn++) {
push @combarg, [0, $#{$self->{'arg_matrix'}[$fhn]}]; push(@combarg, [0, $#{$self->{'arg_matrix'}[$fhn]}],
# Is input source --xapply linked to the next?
$opt::xapplyinputsource[$fhn+1]);
} }
$combarg[$fhno] = [$len,$len]; # Find only combinations with this new entry $combarg[2*$fhno] = [$len,$len]; # Find only combinations with this new entry
# map combinations # map combinations
# [ 1, 3, 7 ], [ 2, 4, 1 ] # [ 1, 3, 7 ], [ 2, 4, 1 ]
# => # =>
# [ m[0][1], m[1][3], m[3][7] ], [ m[0][2], m[1][4], m[2][1] ] # [ m[0][1], m[1][3], m[2][7] ], [ m[0][2], m[1][4], m[2][1] ]
my @mapped; my @mapped;
for my $c (expand_combinations(@combarg)) { for my $c (expand_combinations(@combarg)) {
my @a; my @a;
@ -9429,9 +9453,11 @@ sub nest_get {
# append the mapped to the ungotten arguments # append the mapped to the ungotten arguments
push @{$self->{'unget'}}, @mapped; push @{$self->{'unget'}}, @mapped;
# get the first # get the first
if(@mapped) {
return shift @{$self->{'unget'}}; return shift @{$self->{'unget'}};
} }
} }
}
# all are eof or at EOF string; return from the unget queue # all are eof or at EOF string; return from the unget queue
return shift @{$self->{'unget'}}; return shift @{$self->{'unget'}};
} }
@ -9496,15 +9522,23 @@ sub expand_combinations {
# Returns: ([x,y,...],[x,y,...]) # Returns: ([x,y,...],[x,y,...])
# where xmin <= x <= xmax and ymin <= y <= ymax # where xmin <= x <= xmax and ymin <= y <= ymax
my $minmax_ref = shift; my $minmax_ref = shift;
my $xapply = shift; # This is linked to the next input source
my $xmin = $$minmax_ref[0]; my $xmin = $$minmax_ref[0];
my $xmax = $$minmax_ref[1]; my $xmax = $$minmax_ref[1];
my @p; my @p;
if(@_) { if(@_) {
# If there are more columns: Compute those recursively
my @rest = expand_combinations(@_); my @rest = expand_combinations(@_);
if($xapply) {
# Linked to next col with xapply
# TODO BUG does not wrap values if not same number of vals
push(@p, map { [$$_[0], @$_] }
grep { $xmin <= $$_[0] and $$_[0] <= $xmax } @rest);
} else {
# If there are more columns: Compute those recursively
for(my $x = $xmin; $x <= $xmax; $x++) { for(my $x = $xmin; $x <= $xmax; $x++) {
push @p, map { [$x, @$_] } @rest; push @p, map { [$x, @$_] } @rest;
} }
}
} else { } else {
for(my $x = $xmin; $x <= $xmax; $x++) { for(my $x = $xmin; $x <= $xmax; $x++) {
push @p, [$x]; push @p, [$x];

View file

@ -566,7 +566,7 @@ $Global::Initfile && unlink $Global::Initfile;
exit ($err); exit ($err);
sub parse_options { sub parse_options {
$Global::version = 20160322; $Global::version = 20160323;
$Global::progname = 'sql'; $Global::progname = 'sql';
# This must be done first as this may exec myself # This must be done first as this may exec myself