R/222_export_env.r

Defines functions .mpiopt_init

Documented in .mpiopt_init

### Export control to new env.
# .pbd_env <- new.env()
# .pbd_env$SPMD.CT <- SPMD.CT()
# .pbd_env$SPMD.OP <- SPMD.OP()
# .pbd_env$SPMD.IO <- SPMD.IO()
# .pbd_env$SPMD.TP <- SPMD.TP()

### For non-blocking calls.
# .pbd_env$SPMD.NB.BUFFER <- list()


### The above are fake. These only be here for reference and to fool
### ``R CMD check''.
### The real one ``in practice and runtime'' is initialed by the
### .mpiopt_init() in next which is always called by .OnLoad() in "zzz.r"
### to avoid overloaded and can be really accessed by users instead of sealed
### by R after loaded.
###
### WCC: DO ``NOT'' remark ``NOR'' use the above. Only the below are real.


### Get MPI options.
# .mpiopt_get <- function(main, sub = NULL, envir = .GlobalEnv){
#   if(!is.null(sub)){
#     envir$.pbd_env[[main]][[sub]]
#   } else{
#     envir$.pbd_env[[main]]
#   }
# } # End of .mpiopt_get().

### Set MPI options.
# .mpiopt_set <- function(val, main, sub = NULL, envir = .GlobalEnv){
#   if(!is.null(sub)){
#     envir$.pbd_env[[main]][[sub]] <- val
#   } else{
#     envir$.pbd_env[[main]] <- val
#   }
#   invisible()
# } # End of .mpiopt_set().

### Initialize MPI options.
.mpiopt_init <- function(envir = .GlobalEnv, mpi.type = "OPENMPI"){
  if(!exists(".pbd_env", envir = envir)){
    envir$.pbd_env <- new.env()
  } 
  envir$.pbd_env$SPMD.CT <- SPMD.CT()
  envir$.pbd_env$SPMD.OP <- SPMD.OP()
  envir$.pbd_env$SPMD.IO <- SPMD.IO()
  envir$.pbd_env$SPMD.TP <- SPMD.TP()
  envir$.pbd_env$SPMD.DT <- SPMD.DT()
  envir$.pbd_env$SPMD.NB.BUFFER <- list()
  envir$.pbd_env$MPI.TYPE <- mpi.type

  invisible()
} # End of .mpiopt_init().
RBigData/pbdMPI documentation built on Jan. 31, 2024, 10:34 p.m.