24.02.2014 Views

Parallel Processing: A KISS Approach - University of North Dakota

Parallel Processing: A KISS Approach - University of North Dakota

Parallel Processing: A KISS Approach - University of North Dakota

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

* process. If slave fails to spawn, it is */<br />

/* not used. */<br />

/***********************************************/<br />

void SPAWN_PVM_NODES(void) {<br />

int cc, j, n;<br />

int tid;<br />

// Initialize array to hold node IDs.<br />

for (j = 0; j < jobsPerNode; j++) {<br />

for (n = 0; n < nodesWanted; n++) {<br />

TID[j*nodesWanted+n] = -1;<br />

}<br />

}<br />

// Spawn slave processes.<br />

if (verbose == yes) {<br />

printf("*************************************************\n");<br />

printf("* MESSAGE - Spawning slave processes.<br />

*\n");<br />

printf("*************************************************\n");<br />

}<br />

for (j = 0; j < jobsPerNode; j++) {<br />

for (n = 0; n < nodesWanted; n++) {<br />

cc = pvm_spawn(slavePath, NULL, 1, nodeNames[n], 1, &tid);<br />

if (cc == 1) {<br />

TID[j*nodesWanted+n] = tid;<br />

if (verbose == yes) {<br />

printf("MESSAGE - Slave spawned on node: %s\n",<br />

nodeNames[n]);<br />

}<br />

} else {<br />

if (verbose == yes) {<br />

printf("WARNING - Slave failed on node: %s\n",<br />

nodeNames[n]);<br />

}<br />

}<br />

}<br />

}<br />

}<br />

/***********************************************/<br />

/* SHUT_DOWN_PVM */<br />

/* This routine does the following: */<br />

/* 1. Shuts down PVM. */<br />

/* */<br />

/* !No changes should be made to this routine! */<br />

/* */<br />

/* R. Marsh. July 2006. UND Computer Science. */<br />

/***********************************************/<br />

void SHUT_DOWN_PVM(void) {<br />

if (verbose == yes) {<br />

printf("*************************************************\n");<br />

printf("* MESSAGE - Shutting down PVM deamons.<br />

*\n");<br />

}<br />

printf("*************************************************\n");<br />

}<br />

pvm_halt();<br />

44

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!