Last data update: 2014.03.03

R: Parallelized Matrix Multiplication
pmmR Documentation

Parallelized Matrix Multiplication

Description

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

Usage

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

control.pmm(ncores = 1, max.ncores = detectCores(), 
    f = 2, sfstop = FALSE, allow.recursive = TRUE, ...)

Arguments

A, B

matrices to be mulitplied.

control

a list of with the arguments ncores, f, and sfstop or a function such as control.pmm that generates such a list.

ncores

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

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 on non-Windows OS to each core in parallelized matrix multiplication.

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

...

further arguments, currently not used.

Details

Parallelized matrix multiplication shortens computing time for large data sets (n>1000). However, the spawning of child processes requires itself ressources and increasing the number of cores for parallel matrix multiplication and evaluation of estimating equations/gradient does not always result in reduced computing time. A sensible default for the number of cores assigned to both tasks is likely ncores=2.

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

Value

pmm:

the matrix product A %*% B,

control.pmm:

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

Author(s)

Andreas Papritz andreas.papritz@env.ethz.ch

Examples

## Not run: 
A <- as.matrix(dist(rnorm(2000)))
B <- as.matrix(dist(rnorm(2000)))
system.time(C <- pmm(A, B, control = control.pmm(ncores = 1)))
system.time(C <- pmm(A, B, control = control.pmm(ncores = 4)))

## End(Not run)

Results