Table of Contents

NAME

pvm_reduce - Performs a reduction operation over members of the specified group.

SYNOPSIS

C int info = pvm_reduce( void (*func)(),
void *data, int count, int datatype,
int msgtag, char *group, int rootginst)

Fortran call pvmfreduce(func, data, count, datatype,
msgtag, group, rootginst, info)

PARAMETERS

func
Function which defines the operation performed on the global data. Predefined are PvmMax, PvmMin, PvmSum, and PvmProduct. Users can define their own function.
SYNOPSIS for func
C void func(int *datatype, void *x, void *y,
int *num, int *info)
Fortran call func(datatype, x, y, num, info)
data
Pointer to the starting address of an array of local values. On return, the data array on the root will be overwritten with the result of the reduce operation over the group.
count
Integer specifying the number of elements of datatype in the data array.
datatype
Integer specifying the type of the entries in the data array. (See below for defined types.)
msgtag
Integer message tag supplied by the user. msgtag should be >= 0. It allows the user's program to distinguish between different kinds of messages.
group
Character string group name of an existing group.
rootginst
Integer instance number of group member who gets the result.
info
Integer status code returned by the routine. Values less than zero indicate an error.

DISCUSSION

pvm_reduce() performs global operations such as max, min, and sum over all the tasks in a group. All group members call pvm_reduce() with their local data, and the result of the reduction operation appears on the user specified root task root. The root task is identified by its instance number in the group.

PVM supplies the following predefined functions that can be specified in func. PvmMin
PvmMax
PvmSum
PvmProduct

PvmMax and PvmMin are implemented for all the dataypes listed below. For complex values the minimum [maximum] is that complex pair with the minimum [maximum] modulus. PvmSum and PvmProduct are implemented for all the dataypes listed below with the exception of PVM_BYTE and BYTE1.

C and Fortran defined datatypes are: C datatypes FORTRAN datatypes
-----------------------------------
PVM_BYTE BYTE1
PVM_SHORT INTEGER2
PVM_INT INTEGER4
PVM_FLOAT REAL4
PVM_CPLX COMPLEX8
PVM_DOUBLE REAL8
PVM_DCPLX COMPLEX16
PVM_LONG

A user defined function may be used used in func. The argument func is a function with four arguments. It is the base function used for the reduction operation. Both x and y are arrays of type specified by datatype with num entries. The arguments datatype and info are as specified above. The arguments x and num correspond to data and count above. The argument y contains received values.

Note: pvm_reduce() does not block. If a task calls pvm_reduce and then leaves the group before the root has called pvm_reduce an error may occur.

The current algorithm is very simple and robust. A future implementation may make more efficient use of the architecture to allow greater parallelism.

EXAMPLES

C:
info = pvm_reduce(PvmMax, &myvals, 10, PVM_INT,
msgtag, "workers", rootginst);

Fortran:
CALL PVMFREDUCE(PvmMax, MYVALS, COUNT, INTEGER4,
& MTAG, 'workers', ROOT, INFO)

ERRORS

These error conditions can be returned by pvm_reduce

   PvmNoInst    Calling task is not in the group
   PvmBadParam    The datatype specified is not appropriate
       for the specified reduction function.
   PvmSysErr    Pvm system error

SEE ALSO

pvm_bcast(3PVM), pvm_barrier(3PVM), pvm_psend(3PVM)


Table of Contents


www.fiveanddime.net


Google
Web www.fiveanddime.net