Difference between revisions of "User:Szha/Notes/CMSC714/note0906"

From Grad Wiki
(No difference)

Revision as of 15:01, 13 September 2012

  1. notes
  2. first assignment MPI next week
  3. accounts emailed next week for UMIACS bug cluster and for SMP
  4. check readings page to see question sending assignment:w
  5. 2-4 questions
  6. 6PM day before lecture

PVM[edit | edit source]

provide a simple, free, portable parallel environment[edit | edit source]

run on everything[edit | edit source]

parallel hardware: SMP, MPPs, Vector machines
network of workstations: ATM, ethernet,
  • UNIX machines and PCs running win32 API
works on a heterogenous collection of machines
  • handles type conversion as needed

provides two things[edit | edit source]

message pasing library
  • point-to-point messages
  • synchronization: barriers, reductions
OS support
  • process creation (pvm_spawn)


PVM environment (UNIX)[edit | edit source]

one PVMD (daemon) per machine[edit | edit source]

all processes communicate through pvmd (by default)

any number of application processes per node[edit | edit source]

PVM message passing[edit | edit source]

all messages have tags[edit | edit source]

an integer to identify the message
defined by the user

messages are constructed, then sent[edit | edit source]

pvm_pk{int,char,float}(*var, count, stride)
pvm_unpk{int,char,float} to unpack

all processes are named based on task ids (tids)[edit | edit source]

local/remote processes are the same

primary message passing functions[edit | edit source]

pvm_send(tid,tag)
pvm_recv(tid,tag) # tid to receive from, could be anywhere


PVM process control[edit | edit source]

creating a process[edit | edit source]

pvm_spawn(task,argv,flag,where,ntask,tids)
task is name of program to start
flag and where provide control of where tasks are started
ntask determines how many copies are started
program must be installed on each target machine
returns number of tasks actually started

ending a task[edit | edit source]

pvm_exit
does not exit the process, just the PVM machine

info functions[edit | edit source]

pvm_mytid() get the process task id


PVM group operations[edit | edit source]

group is the unit of communication[edit | edit source]

a collection of one or more processes
processes join group with pvm_joingroup("<group name>")
each process in the group has a unique id
  • pvm_gettid("<group name>")

barrier[edit | edit source]

can involve a subset of the processes in the group
pvm_barrier("<group name>"), count)

reduction operations[edit | edit source]

pvm_reduce( void (*func)(), void *data, int count, int datatype, int msgtag, char *group, int rootinst)
  • result is returned to rootinst node
  • does not block (does not wait until root has the return value, just indicate valid buffer value)
pre-defined funcs: PvmMin, PvmMax, PvmSum, PvmProduct


PVM performance issues[edit | edit source]

messages have to go through PVMD[edit | edit source]

can use direct route option to prevent this problem

packing messages[edit | edit source]

semantics imply a copy (at least)
extra function call to pack messages

heterogenous support[edit | edit source]

information is sent in machine independent format
has a short circuit option for known homogenous comm.
  • passes data in native format then

sample PVM program[edit | edit source]

fragment from main

myGroupNum = pvm_joingroup("ping-pong");
mytid = pvm_mytid();
if (myGroupNum == 0) {
    pvm_catchout(stdout);
    okSpawn = pvm_spawn(MYNAME, argv, 0, "", 1, &friendTid);
    if (okSpawn != 1) {
        printf("can't spawn");
        pvm_exit();
        exit(1);
    }
} else {
    friendTid = pvm_parent();
    tids[0] = friendTid;
    tids[1] = mytid;
}
pvm_barrier("ping-pong", 2);

if (myGroupNum == 0) {
    for (i = 0; i < MESSAGESIZE; i++) {
        messsage[i] = '1'l
    }
}

for (i = 0; i<ITERATIONS; i++) {
    if( myGroupNum == 0) {
        pvm_initsend(PvmDataDefault);
        pvm_pkint(message,MESSAGESIZE, 1); // stride 1 indicates no gap
        pvm_send(friendTid, msgid);
        pvm_recv(friendTid, msgid);
        pvm_upkint(message,MESSAGESIZE,1);
    }
    else {
        pvm_recv(friendTid,msgid);
        pvm_upkint(message,MESSAGESIZE, 1);
        pvm_initsend(PvmDataDefault);
        pvm_pkint(message, MESSAGESIZE, 1);
        pvm_send(friendTid,msgid);
    }
}
pvm_exit();
exit(0);