[Vegan-commits] r1986 - in pkg/vegan: R inst man
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Sat Nov 5 14:40:24 CET 2011
Author: jarioksa
Date: 2011-11-05 14:40:24 +0100 (Sat, 05 Nov 2011)
New Revision: 1986
Modified:
pkg/vegan/R/permutest.cca.R
pkg/vegan/inst/ChangeLog
pkg/vegan/man/anova.cca.Rd
Log:
parallel processing modelled like in oecosimu()
Modified: pkg/vegan/R/permutest.cca.R
===================================================================
--- pkg/vegan/R/permutest.cca.R 2011-11-03 07:23:37 UTC (rev 1985)
+++ pkg/vegan/R/permutest.cca.R 2011-11-05 13:40:24 UTC (rev 1986)
@@ -7,10 +7,8 @@
`permutest.cca` <-
function (x, permutations = 99,
model = c("reduced", "direct", "full"), first = FALSE,
- strata = NULL, parallel = 1, ..., kind = c("snow", "multicore"))
+ strata = NULL, parallel = getOption("mc.cores", 1L) , ...)
{
- kind <- match.arg(kind)
- parallel <- as.integer(parallel)
model <- match.arg(model)
isCCA <- !inherits(x, "rda")
isPartial <- !is.null(x$pCCA)
@@ -115,18 +113,24 @@
function(x) vegan:::permuted.index(N, strata=strata)))
}
nperm <- nrow(permutations)
- if (parallel > 1 && getRversion() >= "2.14" && require(parallel)) {
- if (kind == "snow") {
- cl <- makeCluster(parallel)
- clusterEvalQ(cl, library(vegan))
- tmp <- parRapply(cl, permutations, function(i) getF(i))
- tmp <- matrix(tmp, ncol=3, byrow=TRUE)
- stopCluster(cl)
- } else {
+ ## Parallel processing (similar as in oecosimu)
+ hasClus <- inherits(parallel, "cluster") || is.null(parallel)
+ if ((hasClus || parallel > 1) && require(parallel)) {
+ if(.Platform$OS.type == "unix" && !hasClus) {
tmp <- do.call(rbind,
mclapply(1:nperm,
function(i) getF(permutations[i,]),
mc.cores = parallel))
+ } else {
+ ## if hasClus, do not set up and stop a temporary cluster
+ if (!hasClus) {
+ parallel <- makeCluster(parallel)
+ clusterEvalQ(parallel, library(vegan))
+ }
+ tmp <- parRapply(parallel, permutations, function(i) getF(i))
+ tmp <- matrix(tmp, ncol=3, byrow=TRUE)
+ if (!hasClus)
+ stopCluster(parallel)
}
} else {
tmp <- getF(permutations)
Modified: pkg/vegan/inst/ChangeLog
===================================================================
--- pkg/vegan/inst/ChangeLog 2011-11-03 07:23:37 UTC (rev 1985)
+++ pkg/vegan/inst/ChangeLog 2011-11-05 13:40:24 UTC (rev 1986)
@@ -42,6 +42,8 @@
(incl. MacOS X and Linux) to use the socket processing instead of
forking.
+ * permutest.cca: parallel processing modelled after oecosimu().
+
Version 2.1-5 (closed October 30, 2011)
* opened a new version with the release of vegan 2.0-1 on Oct 20,
Modified: pkg/vegan/man/anova.cca.Rd
===================================================================
--- pkg/vegan/man/anova.cca.Rd 2011-11-03 07:23:37 UTC (rev 1985)
+++ pkg/vegan/man/anova.cca.Rd 2011-11-05 13:40:24 UTC (rev 1986)
@@ -25,8 +25,8 @@
\method{permutest}{cca}(x, permutations = 99,
model = c("reduced", "direct", "full"),
- first = FALSE, strata = NULL, parallel = 1, ...,
- kind = c("snow", "multicore"))
+ first = FALSE, strata = NULL,
+ parallel = getOption("mc.cores", 1L) , ...)
}
\arguments{
@@ -55,15 +55,10 @@
permutation. If supplied, observations are permuted only within the
specified strata.}
- \item{parallel, kind}{Number of parallel processes. The parallel
- processing is only possible in \R version 2.14.x and later. The
- argument is silently ignored if the system is not capable of
- parallel processing. There are two \code{kind} of parallelization:
- \code{kind = "snow"} selects a socket cluster which is available
- in all operationg systems, and \code{kind = "multicore"} selects a
- fork cluster that is available only in unix-like systems (Linux,
- MacOS X), but is usually faster. These arguments are experimental
- and may change or disappear in any version. }
+ \item{parallel}{Number of parallel processes or a predefined socket
+ cluster. With \code{parallel = 1} uses ordinary, non-parallel
+ processing. The parallel processing is done with \pkg{parallel}
+ package which is available only for \R 2.14.0 and later.}
}
\details{
More information about the Vegan-commits
mailing list