-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Finished Activity #1 of Matrix Multiplication
- Loading branch information
1 parent
4e50a70
commit 1148264
Showing
5 changed files
with
167 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
topic_rigid_programs/matrixmultiplication/cluster_crossbar_64.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?xml version='1.0'?> | ||
<!DOCTYPE platform SYSTEM "http://simgrid.gforge.inria.fr/simgrid.dtd"> | ||
<platform version="3"> | ||
<AS id="AS0" routing="Full"> | ||
<cluster id="cluster" prefix="host-" suffix=".hawaii.edu" radical="0-63" power="1" bw="10Gbps" lat="20us"/> | ||
</AS> | ||
</platform> |
90 changes: 87 additions & 3 deletions
90
topic_rigid_programs/matrixmultiplication/data_distribution.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,96 @@ | ||
<p class="ui"> | ||
Implement a program called <code>matmul_init</code> (<code>matmul_init.c</code>) that takes a | ||
Implement an MPI program called <code>matmul_init</code> (<code>matmul_init.c</code>) that takes a | ||
single command-line argument, <i>N</i>, which is a strictly positive integer. <i>N</i> is the | ||
dimension of the square matrices that we multiply. | ||
dimension of the square matrices that we multiply. Your program should check that the number of processes | ||
is a perfect square, and that its square root divides N (printing an error message and exiting if this is | ||
not the case). | ||
</p> | ||
|
||
<p class="ui"> | ||
The objective of the program is for each process to allocate and initialize its block of each matrix. | ||
We multiply particular matrices, defined by: | ||
</p> | ||
<p class="ui"> | ||
<i>A<sub>i,j</sub> = i</i> and <i>B<sub>i,j</sub> = i + j</i>. | ||
</p> | ||
|
||
|
||
|
||
<p class="ui"> | ||
<b>The above is with global indices, which go from 0 to N-1.</b> | ||
</p> | ||
|
||
|
||
<p class="ui"> | ||
Given the above definitions of A and B, there is a simple analytical solution | ||
for C. There is thus a closed-form expression for the sum of the | ||
elements of C: <b><i>N<sup>3</sup> (N - 1)<sup>2</sup> / 2</i></b>. | ||
You will use this formula to check the validity of your matrix | ||
multiplication implementation in Activity #2. | ||
</p> | ||
|
||
<p class="ui"> | ||
Have each process allocate its blocks of A, B, and C, initialize its blocks | ||
of A and B to the appropriate values, and then print out the content of | ||
these blocks. Each process should print its MPI rank (the "linear rank") | ||
as well as its | ||
2-D rank, which is easy to determine based on the linear rank. Note that MPI | ||
provides a set of functions for handling Cartesian coordinates, which you | ||
can also use (see the documentation for <code>MPI_Cart_rank</code> and | ||
related functions). | ||
</p> | ||
|
||
<p class="ui"> | ||
For instance, here is an excerpt from the output (that generated by the process of rank 2) | ||
for p=4 and N=8, using | ||
<a href="./cluster_crossbar_64.xml">cluster_crossbar_64.xml</a> as a platform file | ||
and <a href="./hostfile_64.txt">hostfile_64.txt</a> as a hostfile (since this module is | ||
about correctness, you can use pretty much any such valid files). | ||
</p> | ||
|
||
<div class="ui container raised segment"> | ||
{% highlight text %} | ||
% smpirun --cfg=smpi/running_power:1Gf -np 4 \ | ||
-platform cluster_crossbar_64.xml \ | ||
-hostfile hostfile_64.txt \ | ||
./matmul_init 8 | ||
[...] | ||
Process rank 2 (coordinates: 1,0), block of A: | ||
4.0 4.0 4.0 4.0 | ||
5.0 5.0 5.0 5.0 | ||
6.0 6.0 6.0 6.0 | ||
7.0 7.0 7.0 7.0 | ||
Process rank 2 (coordinates: 1,0), block of A: | ||
4.0 5.0 6.0 7.0 | ||
5.0 6.0 7.0 8.0 | ||
6.0 7.0 8.0 9.0 | ||
7.0 8.0 9.0 10.0 | ||
[...] | ||
{% endhighlight %} | ||
</div> | ||
|
||
|
||
|
||
<p class="ui"> | ||
YYY | ||
Note that due to the convenience of simulation, | ||
the output from one process will never be interleaved with the output of | ||
another process. If you run this code "for real" with MPI instead of SMPI | ||
output will be interleaved and additional synchronization will be needed | ||
to make the output look nice. | ||
The order in which the processes output their blocks is inconsequential. | ||
You may want to use a barrier synchronization | ||
to first see all blocks of A and then all blocks of B. | ||
|
||
</p> | ||
|
||
<p class="ui"> | ||
Obviously, we won’t run this program for large N. | ||
The goal is simply to make sure that matrix blocks are initialized | ||
correctly on all processes. You can run this program on any XML | ||
platform file. | ||
|
||
</p> | ||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
host-0.hawaii.edu | ||
host-1.hawaii.edu | ||
host-2.hawaii.edu | ||
host-3.hawaii.edu | ||
host-4.hawaii.edu | ||
host-5.hawaii.edu | ||
host-6.hawaii.edu | ||
host-7.hawaii.edu | ||
host-8.hawaii.edu | ||
host-9.hawaii.edu | ||
host-10.hawaii.edu | ||
host-11.hawaii.edu | ||
host-12.hawaii.edu | ||
host-13.hawaii.edu | ||
host-14.hawaii.edu | ||
host-15.hawaii.edu | ||
host-16.hawaii.edu | ||
host-17.hawaii.edu | ||
host-18.hawaii.edu | ||
host-19.hawaii.edu | ||
host-20.hawaii.edu | ||
host-21.hawaii.edu | ||
host-22.hawaii.edu | ||
host-23.hawaii.edu | ||
host-24.hawaii.edu | ||
host-25.hawaii.edu | ||
host-26.hawaii.edu | ||
host-27.hawaii.edu | ||
host-28.hawaii.edu | ||
host-29.hawaii.edu | ||
host-30.hawaii.edu | ||
host-31.hawaii.edu | ||
host-32.hawaii.edu | ||
host-33.hawaii.edu | ||
host-34.hawaii.edu | ||
host-35.hawaii.edu | ||
host-36.hawaii.edu | ||
host-37.hawaii.edu | ||
host-38.hawaii.edu | ||
host-39.hawaii.edu | ||
host-40.hawaii.edu | ||
host-41.hawaii.edu | ||
host-42.hawaii.edu | ||
host-43.hawaii.edu | ||
host-44.hawaii.edu | ||
host-45.hawaii.edu | ||
host-46.hawaii.edu | ||
host-47.hawaii.edu | ||
host-48.hawaii.edu | ||
host-49.hawaii.edu | ||
host-50.hawaii.edu | ||
host-51.hawaii.edu | ||
host-52.hawaii.edu | ||
host-53.hawaii.edu | ||
host-54.hawaii.edu | ||
host-55.hawaii.edu | ||
host-56.hawaii.edu | ||
host-57.hawaii.edu | ||
host-58.hawaii.edu | ||
host-59.hawaii.edu | ||
host-60.hawaii.edu | ||
host-61.hawaii.edu | ||
host-62.hawaii.edu | ||
host-63.hawaii.edu |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters