- Review sections 6.1-6.2 in Hartley's text concerning SR's capabilities
for using message passing to coordinate tasks involving parallel
processing.
-
Copy Program 6.1 of Hartley's text to your account. (This program is
available as ~walker/parallel/sr/book/messages.sr .)
Compile and run the program to check that it works as expected.
Complete Program 6.1 by providing appropriate comments, including notes
about relevant variables, procedures, operations, and messages.
-
Program simple-send.sr demonstrates how one process, running on
one processor, can pass a message to a second process, running on another
processor. (This program is available as
~walker/parallel/sr/examples/simple-send.sr .)
-
Copy this program to your account and run it.
-
Be sure you understand how this program produces its output.
-
Add appropriate comments to the program to explain how each part of the
code contributes to the running of the program.
-
Program two-way-send.sr uses a single operation for
two-way communication between processes running on different processors.
Copy this program (from directory ~walker/parallel/sr/examples),
run it, study the output, and comment relevant lines to explain how the
program works.
Experiment changing the call statement to send and rerun
the program. Explain any similarities or differences in the output.
Similarly, change the send statement to call and review
the output.
What happens if you remove the operations send and call
(but leave the msg lines in both processes)?
-
Program two-way-alt.sr (also in directory
~walker/parallel/sr/examples) demonstrates two-way communication
through two operations. In this program, the main program can tell
process_b where to find operation a_msg in
process_a, because process_a is created before
process_b. However, process_a cannot know about
b_msg, which is created in a resource later.
Thus, in this program, the first message from process_b to
process_a includes the specifics of where process_b might
be referenced. This allows process_a to find b_msg when
later communication is desired.
As with the previous steps, copy this program, run it, and comment relevant
lines.
-
Program find-max.sr (from directory
~walker/parallel/sr/examples) finds the maximum in a data array
of size n, using n processes distributed over 6 processors.
Copy this program to your account, run it, and describe in a few sentences
what it does and how it works.
-
What output is generated?
-
What are the differences among the resources in_out_2_node,
in_out_1_node, and out_node? Why are these different types
of processes needed?
-
What is the purpose of the channel resource?
-
How are the processes distributed over various processors? How many
processes run on each processor?
-
How might the program be simplified if you knew the number of
processes always would be odd?
-
Draw a diagram showing each processor and identifying the communication
channels between processors. That is, draw an arrow from one processor to
another if the first processor sends a message to the second.
-
Describe in a few sentences the channel configuration shown in your
diagram.
-
What changes are needed in the diagram if the number of processes is
odd instead of even?
-
Program find-max.sr may be modified to compute the sum of the
elements in the array rather than the maximum. In this approach, each
processor adds the value at its array location to the values received from
other processors. This sum is then sent out along the processor's output
channel.
-
Modify the program as suggested to compute the sum of the values in
an array.
-
Compile and run your program on a variety of data, including at least
one case where the size of the array is even and at least one case where the
size is odd.
-
Describe in a few sentences why this program works.