Download Sequoia++ User Manual
Transcript
8.6
Mapping File Invariants
In the process of writing a mapping file there are some rules that should be followed to map the iteration
space onto a given machine. The first two rules are correctness requirements that must be followed for
the compiler to be able to correctly compile the program. The other rule is a guideline to ensure good
performance. We give both mathematical definitions as well as intuition for these rules.
The first rule involves the relationship between the ways for each loop in a control statement and the
corresponding fullrange component. For a set of loop statements over iteration variables I = {i1 , i2 , . . . , in }
with ways W = w1 , w2 , . . . , wn and fullrange, F , should obey the equality
n
Y
wi = F
(1)
i
That is, the product of the ways for each nested loop should be equal to the number of processors (the
fullrange) used by the loop. The ways specify a w1 ∗ w2 ∗ . . . ∗ wn block of the iteration space; the number
of iterations in the block must be equal to the number of processors used by the loop nest. The compiler
will assign one iteration of the block to each of the processors.
The second rule ensures there is sufficient work that each processor specified in fullrange is assigned at
least one task to perform. For a set of loop statements over iteration variables I = {i1 , i2 , . . . , in } with ranges
R = {r1 , r2 , . . . , rn } and iteration blocks B = {b1 , b2 , . . . bn } and fullrange F , should obey the inequality
n
Y
ri
i
bi
≥F
(2)
This statement is concerned with the amount of work that the compiler is given to schedule onto the child
processors. Since the iteration blocks chunk of the iteration space into a coarser granularity it gives the
compiler fewer units of work to schedule. The left side of equation 2 specifies the total units of work that
the compiler is responsible for scheduling. Therefore equation 2 states that there must be enough work such
that each processor is assigned at least one unit of work to perform.
The last rule is not mandatory for correctness, but should be followed in order to ensure good performance
using software pipelining (see Section 9.4.4). Currently software pipelining can be applied only to a single
loop in an iteration space at present. For a set of loop statements over iteration variables I = {i1 , i2 , . . . , in }
with ranges R = {ri , r2 , . . . , rn } and iteration blocks B = {b1 , b2 , . . . bn }, fullrange F and level of software
pipeline for a single loop SW P should obey the inequality
n
Y
ri
i
bi
F ∗ SW P
(3)
Again the left hand side of Equation 3 represents the total number of chunks of work the compiler is
responsible for scheduling. This rule says that the total units of work should be much greater than the
number of different contexts the compiler can schedule. The idea is that the space overhead of software
pipelining is often not worth the cost unless you have a large number of tasks to amortize the additional
cost over. That being said, the working set size of each individual chunk of work to be used for software
pipelining should be small enough so that multiple task iterations can fit in a child’s memory space at any
point in time.
8.7
Error Checking for the Mapping File
The mapping file is the link between the machine file and source file. As a result there are often inter-file
dependencies that need to be verified by the compiler. We’ve done our best to at least provide checks for
many of these dependencies to ensure they are consistent, however there is no guarantee at present that the
checking is both sound and complete. Therefore there may still exist compiler bugs that will allow invalid
code past the front-end of the compiler and result in either the compiler crashing or throwing an assertion
at a later stage due to some cross-file inconsistency. If you run into such a problem and can’t figure it out
please contact us.
21