Synergy User Manual and Tutorial. - THE CORE MEMORY
Synergy User Manual and Tutorial. - THE CORE MEMORY
Synergy User Manual and Tutorial. - THE CORE MEMORY
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
<strong>Synergy</strong> <strong>User</strong> <strong>Manual</strong> <strong>and</strong> <strong>Tutorial</strong><br />
[c615111@owin ~/pvm ]>aimk master slave<br />
[c615111@owin ~/pvm ]>master<br />
The amik comm<strong>and</strong> compiles the application <strong>and</strong> the executable name of the master<br />
executable runs the application. An example of a PVM “Hello worker—Hello master”<br />
application is below. It demonstrates the structure of a basic PVM program. The master<br />
program is:<br />
// master.c: “Hello worker” program<br />
#include <br />
#define NUM_WKRS 3<br />
main(){<br />
int status; // Status of operation<br />
int tid[NUM_WKRS];// Array of task ID’s all must be unique in system<br />
int msgtag; // Message tag to ID a message<br />
int flag = 0; // Used to specify options for pvm_spawn<br />
char buf[100]; // Message string buffer<br />
char wkr_arg0 = 0;// Null argument to activate workers<br />
char** wkr_args; // Array of args to activate workers<br />
char host[128]; // Host machine name<br />
// Set wkr_args to start worker program to address of wkr_arg0<br />
// which has been set to 0 (NULL)<br />
wkr_args = &wkr_arg0;<br />
// Get host machine name<br />
gethostname(host, sizeof(host));<br />
// Get my task ID <strong>and</strong> print ID <strong>and</strong> host name to screen<br />
printf("Master: ID is %x, name is %s\n", pvm_mytid(), host);<br />
// Spawn a program executable named “worker”<br />
// Will return the number of workers spawned on success or 0 on error<br />
// The empty string (fourth arg) requests any machine<br />
// Putting a name in this arg would request a specific machine<br />
status = pvm_spawn("worker", wkr_args, flag, "", NUM_WKRS, tid);<br />
// If spawn was successful it will return NUM_WKRS<br />
// since there are NUM_WKRS workers<br />
if(status == NUM_WKRS){<br />
// Label first message as 1<br />
msgtag = 1;<br />
// Put message in buffer<br />
sprintf(buf, "Hello worker from %s", host);<br />
// Initialize the send message operation<br />
pvm_initsend(PvmDataDefault);<br />
69