The Queen's University of Belfast

Parallel Computer Centre
[Next] [Previous] [Top]
Dynamic Process Groups
Dynamic Process Groups
- Group functions are built on top of the core PVM routines
- libgpvm3.a must be linked with user programs using any of the group functions
- pvmd does not perform the group functions - they are performed by a group server which is automatically started when the first group function is invoked.
- Any PVM task can join or leave a group at any time without having to inform any other task in the affected groups.
- Tasks can broadcast messages to groups of which they are not a member
- Any PVM task may call any of the group functions except for - pvmflvgroup(), pvmfbarrier(), and pvmfreduce()
Joining a Group
pvmfjoingroup
- pvmfjoingroup creates a group -
CALL PVMFJOINGROUP(GROUP, INUM)
- puts the calling task in the group
- group is a character string containing the group name
- returns the instance number, inum, of the process in this group - ie a number from 0 to the number of group members -1
- a task may join multiple groups
- on leaving and rejoining a group a task may receive a different instance number
- instance numbers are recycled and a task joining a group gets the lowest instance number available
Leaving a Group
pvmflvgroup
- pvmflvgroup() removes a task from a group but does not return until the task is confirmed to have left, a subsequent pvmfjoingroup will assign the vacant instance number to the new task
CALL PVMFLVGROUP(GROUP, INFO)
General Group Functions
- The following functions may be used to perform group related actions
- pvmfgettid
- pvmfgetinst
- pvmfgsize
- pvmfbarrier
- pvmfbcast
- pvmfreduce
Group Functions
- pvmfgettid() returns the TID of the process with a given group name and instance number, it also allows two tasks to get each other's TID simply by joining a common group
CALL PVMFGETTID(GROUP, INUM, TID)
- pvmfgetinst returns the instance number of TID in the specified group
CALL PVMFGETINST(GROUP, TID, INUM)
- pvmfgetsize returns the number of members in the group
CALL PVMFGSIZE(GROUP, SIZE)
- pvmfbarrier() blocks a process until count number of processes have joined the group.
CALL PVMFBARRIER(GROUP, COUNT, INFO)
- pvmfbcast broadcasts to all the tasks in the specified group except itself ie all tasks that the group server thinks are in the group when the routine is called
CALL PVMFBCAST(GROUP, MSGTAG, INFO)
- pvmfreduce() performs a global arithmetic operation across the group, the result appears on root eg predefined functions that the user can place in func - PvmMax, PvmMin, PvmProduct, and PvmSum
CALL PVMFREDUCE (FUNC, DATA, COUNT, DATATYPE,MSGTAG, GROUP, ROOT, INFO)
Example SPMD
c Join a group and if I am the first instance
c ie me=0 spawn more copies of myself
call pvmfjoingroup(`foo', me)
if(me .eq. 0) call pvmfspawn (`spmd',
& PVMDEFAULT, '*', NPROC-1, tids(1), info)
c Wait for everyone to startup before proceeding.
call pvmfbarrier(`foo', NPROC, info)
if(me .eq. 0) print*, 'setup complete'
call dowork(me, NPROC)
c program finished leave group and exit pvm
call pvmflvgroup(`foo', info)
... etc
subroutine dowork(me, nproc)
include `/totem/pvm3/include/fpvm3.h'
c Simple subroutine to pass a token around a ring
integer me, nproc
integer token, src, dest, msgtag
c Determine neighbours in the ring
call pvmfgettid(`foo', me-1, src)
call pvmfgettid(`foo', me+1, dest)
if(me .eq. 0) then
call pvmfgettid(`foo', NPROC-1,src)
else if(me .eq. NPROC-1) then
call pvmfgettid(`foo', 0, dest)
endif
msgtag = 4
call pvmfinitsend(PVMDEFAULT, info)
if (me .eq. 0) then
token = dest
call pvmfpack(INTEGER4, token, 1, 1, info)
call pvmfsend(dest, msgtag, info)
call pvmfrecv(src, msgtag, info)
print*, `token ring done'
else
call pvmfrecv(src, msgtag, info)
call pvmfunpack(INTEGER4, token,1,1, info)
token = dest
call pvmfpack(INTEGER4, token, 1, 1, info)
call pvmfsend(dest, msgtag, info)
endif
[Next] [Previous] [Top]
All documents are the responsibility of, and copyright, © their authors and do not represent the views of The Parallel Computer Centre, nor of The Queen's University of Belfast.
Maintained by Alan Rea, email A.Rea@qub.ac.uk
Generated with CERN WebMaker