PVM.reduce {rpvm}R Documentation

Reduction

Description

Performs a reduction operation over members of the specified group.

Usage

.PVM.reduce (x, func = "Min", count = length (x), msgtag, group,
             rootginst = 0)

Arguments

x an integer or double vector of length at least count
func a character string specifying the name of the operation (function), must be one of "Min", "Max", "Sum", "Product"
count the number of elements in x, must be the same among all members of the group
msgtag an integer message tag supplied by the user.
group a character string naming the group
rootginst an integer instance number of group member who performs the reduce of its array to the members of the group.

Details

.PVM.reduce performs global operations such as max, min, sum, or a user provided operation on the data provided by the members of a group. All group members call .PVM.reduce with the same size local data array which may contain one or more entries. The root task is identified by its instance number in the

When the .PVM.reduce completes, it returns a vector on the root which will be equal to the specified operation applied element-wise to the data vectors of all the group members.

A broadcast by the root can be used if the other members of the group need the resultant value(s).

func corresponds the four predefined functions in pvm, PvmMin, PvmMax, PvmSum, PvmProduct. It is possible to definer user function in C with the following prototype, void func(int *datatype, void *x, void *y, int *num, int *info). However, it is not clear how to pass its name from C or how to use user function written in R which limits the usefulness of this function.

Value

On the root, a vector of length count.

Note

.PVM.reduce does not block, a call to .PVM.barrier may be necessary. For example, an error may occur if a task calls .PVM.reduce and then leaves the group before the root has completed its call to .PVM.reduce. Similarly, an error may occur if a task joins the group after the root has issued its call to .PVM.reduce. Synchronization of the tasks (such as a call to .PVM.barrier) was not included within the .PVM.reduce implementation since this overhead is unnecessary in many user codes (which may already synchronize the tasks for other purposes).

Author(s)

Na (Michael) Li nali@umn.edu and A.J. Rossini rossini@u.washington.edu

References

PVM documentation, http://www.netlib.org/pvm3/book/pvm-book.html

See Also

.PVM.joingroup, .PVM.gather, .PVM.scatter

Examples

gname <- "pvmtest"
## Not run: 
if (myinum == 0) {
   result <- .PVM.reduce (as.double (rnorm (10)),
                          "Sum", msgtag = 11, group = gname, root = 0)
}
## End(Not run)

[Package rpvm version 0.6-2 Index]