as.ddmatrix: Non-Distributed object to Distributed Object Converters

Description Usage Arguments Details Value Examples

Description

A simplified interface to the distribute() and redistribute() functions.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
as.ddmatrix(x, ...)

distribute(x, bldim = .pbd_env$BLDIM, xCTXT = 0, ICTXT = .pbd_env$ICTXT)

## S4 method for signature 'matrix'
as.ddmatrix(x, bldim = .pbd_env$BLDIM,
  ICTXT = .pbd_env$ICTXT)

## S4 method for signature ''NULL''
as.ddmatrix(x, bldim = .pbd_env$BLDIM,
  ICTXT = .pbd_env$ICTXT)

## S4 method for signature 'vector'
as.ddmatrix(x, bldim = .pbd_env$BLDIM,
  ICTXT = .pbd_env$ICTXT)

Arguments

x

a numeric matrix

...

Additional arguments.

bldim

the blocking dimension for block-cyclically distributing the matrix across the process grid.

xCTXT

the BLACS context number for initial distribution of the matrix x.

ICTXT

BLACS context number for return.

Details

A simplified wrapper for the distribute() function, especially in the case that the matrix x is global (which you really should not ever let happen outside of testing, but I won't stop you).

The function will only work if x is stored on all processes, or x is stored on a single process (does not matter which) and every other process has NULL stored for x.

If several processes own pieces of the matrix x, then you can not use this function. You will have to create an appropriate ddmatrix on all processes and redistriubte the data with the redistribute() function.

As usual, the ICTXT number is the BLACS context corresponding to the process grid onto which the output distributed matrix will be distributed.

Value

Returns a distributed matrix.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
## Not run: 
# Save code in a file "demo.r" and run with 2 processors by
# > mpiexec -np 2 Rscript demo.r

library(pbdDMAT, quiet = TRUE)
init.grid()

if (comm.rank()==0){
  x <- matrix(1:16, ncol=4)
} else {
  x <- NULL
}

dx <- as.ddmatrix(x, bldim=2)
dx

### Can also be common to all ranks
y <- matrix(1:25, 5, bldim=2)
dy <- as.ddmatrix(y)
dy

finalize()

## End(Not run)

pbdDMAT documentation built on May 29, 2017, 1:23 p.m.