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.

The only constraint on the data processing is that all <strong>of</strong> the rows be processed before<br />

moving on to the next iteration. The specific ordering <strong>of</strong> row processing is not<br />

important. Thus, this problem is considered loosely coupled parallel.<br />

3. The mst.h file:<br />

The mst.h file is used to define include paths required by C/C++, to define global<br />

variables that would be common to any program using this example, to define<br />

PBS/PVM utility routines that would also be common to any program using this<br />

example, and to define user definable parameters that govern the problem size (see<br />

USER DEFINES and USER GLOBAL VARIABLES).<br />

4. The mstSlave.cpp file:<br />

The mstSlave.cpp file is the example for the slave program. Typically, this program is<br />

rather short as all it is usually intended to do is process the blocks <strong>of</strong> data sent by the<br />

master and return results back to the master.<br />

In the example, the slave program starts and waits (a blocking wait) for a message to<br />

be received from the master. The message contains either data to be processed or a<br />

termination message. If it is data to be processed it will include some “bookkeeping”<br />

data (data I found useful for troubleshooting and monitoring the progress <strong>of</strong> the<br />

processing) and the data to be processed. The data is then processed and sent back to<br />

the master. If the message contains the termination string (“stop” in this example), the<br />

slave program terminates. Obviously, the processing done in this example is trivial,<br />

but the intent is to show how to pass different data types, the structure <strong>of</strong> the slave<br />

program, and to stress the need to terminate the slave process when it is no longer<br />

required.<br />

5. Compiling code based on this example:<br />

Like many UNIX systems, Shale has a “make” utility for compiling programs. The<br />

Makefile for the examples is shown below.<br />

C =gcc<br />

CC =g++<br />

OFLAG=-O2<br />

LIBP=-L/usr/lib64/ -L/usr/local/lib/<br />

-L/usr/share/pvm3/lib/LINUXX86_64<br />

LIBS=-lpvm3 -lm<br />

INCP=-I/usr/share/pvm3/include<br />

mst:<br />

$(CC) $@.cpp $(OFLAG) $(INCP) $(LIBP) $(LIBS) -o $@<br />

mstSlave:<br />

36

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

Saved successfully!

Ooh no, something went wrong!