georob (version 0.3-19)

pmm: Parallelized Matrix Multiplication

Description

This page documents the function pmm for parallelized matrix multiplication and the function
control.pcmp, which controls the behaviour of pmm and other functions that execute tasks in parallel.

Usage

pmm(A, B, control = control.pcmp())

control.pcmp(pmm.ncores = 1, gcr.ncores = 1, max.ncores = parallel::detectCores(), f = 1, sfstop = FALSE, allow.recursive = FALSE, fork = !identical(.Platform[["OS.type"]], "windows"), ...)

Value

pmm:

the matrix product A %*% B,

control.pcmp:

a list with components pmm.ncores, gcr.ncores, max.ncores, f, sfstop,
allow.recursive.

Arguments

A, B

two numeric matrices to be multiplied.

control

a list with the arguments pmm.ncores, gcr.ncores, max.ncores, f, sfstop and allow.recursive or a function such as control.pcmp that generates such a list.

pmm.ncores

an integer (default 1) with the number of cores used for parallelized matrix multiplication.

gcr.ncores

an integer (default 1) with the number of cores used for parallelized computation of (generalized) covariances or semi-variances.

max.ncores

maximum number of cores (integer, default all cores of a machine) used for parallelized computations.

f

an integer (default 1) with the number of tasks assigned to each core in parallelized operations.

sfstop

a logical scalar controlling whether the SNOW socket cluster is stopped after each parallelized matrix multiplication on windows OS (default FALSE).

allow.recursive

a logical scalar controlling whether parallelized matrix multiplicaction and computation of generalized) covariances should be allowed by child processes running already in parallel (default FALSE).

fork

a logical scalar controlling whether forking should be used for parallel computations (default TRUE on unix and FALSE on windows operating systems). Note that settting fork = TRUE on windows suppresses parallel computations.

...

further arguments, currently not used.

Author

Andreas Papritz papritz@retired.ethz.ch.

Details

Parallelized matrix multiplication shortens computing time for large data sets (\(n>1000\)). However, spawning child processes requires itself resources and increasing the number of cores for parallelized matrix multiplication and parallelized computation of covariances does not always result in reduced computing time. Furthermore, these operations may be initiated by child processes, that were itself spawned by functions like cv.georob, predict.georob, profilelogLik, add1.georob, drop1.georob and step.georob. By default, parallelized matrix multiplication and computation of covariances is then suppressed to avoid that child processes itself spawn child processes. To allow parallelized matrix multipliation and parallelized computation of covariances by child processes one has to use the argument allow.recursive = TRUE.

Note that very substantial reductions in computing time results when one uses the OpenBLAS library instead of the reference BLAS library that ships with R, see https://www.openblas.net/ and R FAQ for your OS. With OpenBLAS no gains are obtained by using more than one core for matrix multiplication, and one should therefore use the default arguments pmm.ncores = 1 for control.pcmp().

max.ncores controls how many child processes are spawned in total. This can be used to prevent that child processes spawn themselves children which may result in a considerable number of child processes.

See Also

georobPackage for a description of the model and a brief summary of the algorithms;

georob for (robust) fitting of spatial linear models.

Examples

Run this code
if(interactive()){
  ## example is run only in interactive session because cpu times exceeds 5 s
  A <- as.matrix(dist(rnorm(2000)))
  B <- as.matrix(dist(rnorm(2000)))
  system.time(C <- A %*% B)
  system.time(C <- pmm(
      A, B, control = control.pcmp(pmm.ncores = 2L)))
}

Run the code above in your browser using DataLab