georob (version 0.3-6)

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 = detectCores(), f = 1, sfstop = FALSE, allow.recursive = TRUE, fork = !identical(.Platform[["OS.type"]], "windows"), ...)

Arguments

A, B

matrices to be multiplied.

control

a list of 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

number (integer, default 1) of cores used for parallelized matrix multiplication.

gcr.ncores

number (integer, default 1) of cores used for parallelized computation of semi-variance matrix.

max.ncores

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

f

number (integer, default 2) of tasks assigned to each core in parallelized operations.

sfstop

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

allow.recursive

logical controlling whether nested parallelized computation should be allowed (default TRUE).

fork

logical 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.

Value

pmm:

the matrix product A %*% B,

control.pcmp:

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

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 parallel matrix multiplication does not always result in reduced computing time. A sensible default for the number of cores is likely pmm.ncores=2.

Note, however, 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 http://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 argument 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

georobIntro 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
# NOT RUN {
A <- as.matrix(dist(rnorm(2000)))
B <- as.matrix(dist(rnorm(2000)))
system.time(C <- pmm(A, B, control = control.pcmp(pmm.ncores = 1)))
system.time(C <- pmm(A, B, control = control.pcmp(pmm.ncores = 4)))
# }

Run the code above in your browser using DataLab