ComEnvir: Function to set the parallel computational environment

Description Usage Arguments Value Author(s) Examples

View source: R/ComEnvir.R

Description

This function is used to set the parallel environment. For Linux system, a cluster of 'FORK' is created. For Windows system, a cluster of 'PSOCK' is created.

Usage

1
ComEnvir(is_Unix = TRUE, core_num = 1, clusterExport = list('py','Y','Npop','dmvnorm'))

Arguments

is_Unix

Indicate if your system is Linux or Windows

core_num

The number of cores

clusterExport

If Windows is used, please state the list of values involved on the master process of the variables to variables of the same names in the global environment of each node. This normalily is a list that includes 'py' (the unnormalized density2: Y|theta&phi * theta), observation 'Y' and other variables or functions.

Value

If is_Unix == TRUE, a list of is_Unix is returned. If is_Unix == FALSE, the list of is_Unix and clusterExport is returned.

Author(s)

Yang Liu

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
## The function is currently defined as
function(is_Unix = TRUE, core_num = 1, clusterExport = list('py','Y','Npop','dmvnorm')){
  if(is_Unix){
    cl<-makeCluster(core_num,type = 'FORK')
    registerDoParallel(cl)
  }else{
    #cl<-makeCluster(detectCores( ))
    cl<-makeCluster(core_num)
    registerDoParallel(cl)
    return(clusterExport)
  }
}

MathBilibili/Stochastic-approximation-cut-algorithm documentation built on Dec. 25, 2021, 2:44 p.m.