load-parallel-results.r: R funcction to load results into R.

This commit is contained in:
Ole Tange 2014-01-04 08:11:02 +01:00
parent 79c05280e3
commit 78f6607159
7 changed files with 70 additions and 15 deletions

View file

@ -0,0 +1,34 @@
load_parallel_results <- function(resdir) {
## Find files called .../stdout
stdoutnames <- list.files(path=resdir, pattern="stdout", recursive=T);
## Read them
stdoutcontents <-
lapply(stdoutnames, function(x) { return(paste(readLines(paste(resdir,x,sep="/")),collapse="\n")) } );
## Find files called .../stderr
stderrnames <- list.files(path=resdir, pattern="stderr", recursive=T);
## Read them
stderrcontents <-
lapply(stderrnames, function(x) { return(paste(readLines(paste(resdir,x,sep="/")),collapse="\n")) } );
if(length(stdoutnames) == 0) {
## Return empty data frame if no files found
return(data.frame());
}
## Make the columns containing the variable values
m <- matrix(unlist(strsplit(stdoutnames, "/")),nrow = length(stdoutnames),byrow=T);
mm <- m[,c(F,T)];
## Append the stdout and stderr column
mmm <- cbind(mm,unlist(stdoutcontents),unlist(stderrcontents));
colnames(mmm) <- c(strsplit(stdoutnames[1],"/")[[1]][c(T,F)],"stderr");
## Example:
## parallel --results my/res/dir --header : 'echo {};seq {myvar2}' ::: myvar1 1 2 ::: myvar2 A B
## > load_parallel_results("my/res/dir")
## myvar1 myvar2 stdout stderr
## [1,] "1" "A" "1 A\n1" ""
## [2,] "1" "B" "1 B\n1" ""
## [3,] "2" "A" "2 A\n1\n2" ""
## [4,] "2" "B" "2 B\n1\n2" ""
return(mmm);
}

View file

@ -625,7 +625,7 @@ sub get_options_from_array {
sub parse_options { sub parse_options {
# Returns: N/A # Returns: N/A
# Defaults: # Defaults:
$Global::version = 20140102; $Global::version = 20140103;
$Global::progname = 'parallel'; $Global::progname = 'parallel';
$Global::infinity = 2**31; $Global::infinity = 2**31;
$Global::debug = 0; $Global::debug = 0;
@ -3398,6 +3398,8 @@ sub no_of_cpus {
|| no_of_cpus_openserver() || no_of_cpus_openserver()
|| no_of_cpus_irix() || no_of_cpus_irix()
|| no_of_cpus_tru64() || no_of_cpus_tru64()
# Number of cores is better than no guess for #CPUs
|| nproc()
); );
} }
if($no_of_cpus) { if($no_of_cpus) {
@ -3454,6 +3456,7 @@ sub no_of_cores {
|| no_of_cores_openserver() || no_of_cores_openserver()
|| no_of_cores_irix() || no_of_cores_irix()
|| no_of_cores_tru64() || no_of_cores_tru64()
|| nproc()
); );
} }
if($no_of_cores) { if($no_of_cores) {
@ -3465,6 +3468,13 @@ sub no_of_cores {
} }
} }
sub nproc {
# Returns:
# Number of cores using `nproc`
my $no_of_cores = `nproc 2>/dev/null`;
return $no_of_cores;
}
sub no_of_cpus_gnu_linux { sub no_of_cpus_gnu_linux {
# Returns: # Returns:
# Number of physical CPUs on GNU/Linux # Number of physical CPUs on GNU/Linux
@ -3480,7 +3490,7 @@ sub no_of_cpus_gnu_linux {
if(/^physical id.*[:](.*)/ and not $seen{$1}++) { if(/^physical id.*[:](.*)/ and not $seen{$1}++) {
$no_of_cpus++; $no_of_cpus++;
} }
/^processor.*[:]/ and $no_of_cores++; /^processor.*[:]/i and $no_of_cores++;
} }
close $in_fh; close $in_fh;
} }
@ -3496,7 +3506,7 @@ sub no_of_cores_gnu_linux {
$no_of_cores = 0; $no_of_cores = 0;
open(my $in_fh, "-|", "cat /proc/cpuinfo") || return undef; open(my $in_fh, "-|", "cat /proc/cpuinfo") || return undef;
while(<$in_fh>) { while(<$in_fh>) {
/^processor.*[:]/ and $no_of_cores++; /^processor.*[:]/i and $no_of_cores++;
} }
close $in_fh; close $in_fh;
} }

Binary file not shown.

View file

@ -44,13 +44,19 @@ often be used as a substitute for B<xargs> or B<cat | bash>.
=head2 Reader's guide =head2 Reader's guide
Before looking at the options you may want to check out the B<EXAMPLE>s Start by watching the intro videos for a quick introduction:
after the list of options. That will give you an idea of what GNU
B<parallel> is capable of.
You can also watch the intro video for a quick introduction:
http://www.youtube.com/playlist?list=PL284C9FF2488BC6D1 http://www.youtube.com/playlist?list=PL284C9FF2488BC6D1
Then look at the B<EXAMPLE>s after the list of B<OPTIONS>. That will
give you an idea of what GNU B<parallel> is capable of.
Then spend an hour walking through the tutorial (B<man
parallel_tutorial>). Your command line will love you for it.
Finally you may want to look at the rest of this manual if you have
special needs not already covered.
=head1 OPTIONS =head1 OPTIONS
=over 9 =over 9

View file

@ -54,13 +54,18 @@ often be used as a substitute for @strong{xargs} or @strong{cat | bash}.
@section Reader's guide @section Reader's guide
@anchor{Reader's guide} @anchor{Reader's guide}
Before looking at the options you may want to check out the @strong{EXAMPLE}s Start by watching the intro videos for a quick introduction:
after the list of options. That will give you an idea of what GNU
@strong{parallel} is capable of.
You can also watch the intro video for a quick introduction:
http://www.youtube.com/playlist?list=PL284C9FF2488BC6D1 http://www.youtube.com/playlist?list=PL284C9FF2488BC6D1
Then look at the @strong{EXAMPLE}s after the list of @strong{OPTIONS}. That will
give you an idea of what GNU @strong{parallel} is capable of.
Then spend an hour walking through the tutorial (@strong{man
parallel_tutorial}). Your command line will love you for it.
Finally you may want to look at the rest of this manual if you have
special needs not already covered.
@chapter OPTIONS @chapter OPTIONS
@anchor{OPTIONS} @anchor{OPTIONS}

View file

@ -40,7 +40,7 @@ GNU parallel comes with no warranty.
Web site: http://www.gnu.org/software/parallel Web site: http://www.gnu.org/software/parallel
When using GNU Parallel for a publication please cite: When using programs that use GNU Parallel to process data for publication please cite:
O. Tange (2011): GNU Parallel - The Command-Line Power Tool, O. Tange (2011): GNU Parallel - The Command-Line Power Tool,
;login: The USENIX Magazine, February 2011:42-47. ;login: The USENIX Magazine, February 2011:42-47.

View file

@ -87,7 +87,7 @@ cat ... | parallel --pipe [options] [command [arguments]]
See 'man parallel' for details See 'man parallel' for details
When using GNU Parallel for a publication please cite: When using programs that use GNU Parallel to process data for publication please cite:
O. Tange (2011): GNU Parallel - The Command-Line Power Tool, O. Tange (2011): GNU Parallel - The Command-Line Power Tool,
;login: The USENIX Magazine, February 2011:42-47. ;login: The USENIX Magazine, February 2011:42-47.