From 5169b73062601508c8701a8953f2164b9ab0d66d Mon Sep 17 00:00:00 2001 From: Thierry Gosselin Date: Tue, 29 Nov 2016 17:39:27 -0500 Subject: [PATCH] * new function to help work in parallel using PCs --- R/mclapply_win.R | 6 +++--- man/mclapply_win.Rd | 45 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+), 3 deletions(-) create mode 100644 man/mclapply_win.Rd diff --git a/R/mclapply_win.R b/R/mclapply_win.R index d240d44..43c9ae0 100644 --- a/R/mclapply_win.R +++ b/R/mclapply_win.R @@ -1,4 +1,4 @@ -#' @name .mclapply_win +#' @name mclapply_win #' @title hack to switch function for parallel computation based on OS #' @description \code{parallel::mclapply} doesn't work on Windows, #' because forking is not supported. @@ -30,7 +30,7 @@ #' @importFrom parallel detectCores makeCluster clusterExport mclapply parLapply stopCluster #' @keywords internal -.mclapply_win <- function( +mclapply_win <- function( X, FUN, ..., mc.preschedule = TRUE, mc.set.seed = TRUE, mc.silent = FALSE, mc.cores = NULL, mc.cleanup = TRUE, mc.allow.recursive = TRUE ) { @@ -97,7 +97,7 @@ # @export .stackr_parallel <- switch( Sys.info()[['sysname']], - Windows = {.mclapply_win}, + Windows = {mclapply_win}, Linux = {parallel::mclapply}, Darwin = {parallel::mclapply} ) diff --git a/man/mclapply_win.Rd b/man/mclapply_win.Rd new file mode 100644 index 0000000..70a73cb --- /dev/null +++ b/man/mclapply_win.Rd @@ -0,0 +1,45 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/mclapply_win.R +\name{mclapply_win} +\alias{mclapply_win} +\title{hack to switch function for parallel computation based on OS} +\usage{ +mclapply_win(X, FUN, ..., mc.preschedule = TRUE, mc.set.seed = TRUE, + mc.silent = FALSE, mc.cores = NULL, mc.cleanup = TRUE, + mc.allow.recursive = TRUE) +} +\arguments{ +\item{X}{see \pkg{parallel} \code{\link{mclapply}}} + +\item{FUN}{see \pkg{parallel} \code{\link{mclapply}}} + +\item{...}{see \pkg{parallel} \code{\link{mclapply}}} + +\item{mc.preschedule}{see \pkg{parallel} \code{\link{mclapply}}} + +\item{mc.set.seed}{see \pkg{parallel} \code{\link{mclapply}}} + +\item{mc.silent}{see \pkg{parallel} \code{\link{mclapply}}} + +\item{mc.cores}{see \pkg{parallel} \code{\link{mclapply}}} + +\item{mc.cleanup}{see \pkg{parallel} \code{\link{mclapply}}} + +\item{mc.allow.recursive}{see \pkg{parallel} \code{\link{mclapply}}} +} +\value{ +For mclapply, a list of the same length as X and named by X. +} +\description{ +\code{parallel::mclapply} doesn't work on Windows, +because forking is not supported. +This function defines a socket version of mclapply for windows computer +An implementation that switch automatically the parallel process when detecting +the os. +The code below was inspired from +\pkg{parallel} \code{\link{mclapply}}, +\href{https://github.com/nathanvan}{Nathan VanHoudnos} and +\href{https://github.com/EricArcher/}{Eric Archer}. +} +\keyword{internal} +