WP 4: Code generation script |
We have run experiments using a variety of matrices, machines, and methods, by employing a Python script that generates multipliers. A separate script (not provided here) runs these generated codes; as described in WP 1, we run each for 10,000 repetitions five times, and report the minimum of those five timings.
The script is called specialize.py.
To use it, place it in a folder, and also create a new (empty) folder called
matrices
within that folder
Invoke specialize.py as follows:
        python specialize.py
<matrixname> <specializer-specification>
The matrix name is a name from the
Matrix Market.
If the matrix has been previously used, it will be in the
matrices
folder; otherwise, it will be fetched
from the Matrix Market.
(Warning: some matrices in the Matrix Market, are not actual
matrices, but only templates of matrices - that is,
they show where the nonzeros would be in a family of matrices,
without giving their values.
The scripts fails on such matrices.)
The specification is more complex. It indicates how the matrix should be partitioned (if at all), and what specializers should be applied (along with their parameters). Here are three examples:
python specialize.py fidap005 stencil
fidap005
using the stencil
method.
python specialize.py add32 "[unrolling, 5]"
fidap005
using a standard
CSR (compressed sparse rows) representation, but with the
inner loop unrolled 5 times.
Note that if the method specification is more than a single word,
it has to be surrounded by square brackets and the entire thing quoted.
python specialize.py cavity02 "[split_by_band, 10, 10, [diagonal], [unrolling, 1]]"
cavity02
by first splitting it into
two matrices, the first consisting of just the elements within a
10-index band around the diagonal and the second consisting of the
remaining elements,
then using the diagonal method for the first matrix and plain
CSR for the second.
For very large matrices, this can take some time, although usually
it is very quick.
Each invocation creates a folder containing several files:
the C code generated for this method (sometimes in multiple files, if
it is very long), and any associated declarations,
as well as a file called info.csv
containing some
information about the matrix that was
calculated while generating the code.
The folder's name is formed from the matrix name and the method
specification.
These files together define a function with prototype:
void multByM (double v[], double w[])
which multiplies M by v and puts the
result in w.
You will need a main
function to invoke this.
Full details are given in the documentation. Click here for the script.
Last updated on Fri Jul 6 17:46:00 CDT 2012