01.12.2012 Views

Architecture of Computing Systems (Lecture Notes in Computer ...

Architecture of Computing Systems (Lecture Notes in Computer ...

Architecture of Computing Systems (Lecture Notes in Computer ...

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

192 M. Sch<strong>in</strong>dewolf, D. Kramer, and M. C<strong>in</strong>tra<br />

latch<br />

edge<br />

preheader<br />

preheader edge<br />

header<br />

loop body<br />

next basic block<br />

exit<br />

edge<br />

Fig. 2. GCC <strong>in</strong>ternal representation <strong>of</strong> a s<strong>in</strong>gle exit loop<br />

the already described identifier and the value <strong>of</strong> the loop count (if available from<br />

static analysis).<br />

Operation Count Analysis. The ma_<strong>in</strong>sert pass <strong>in</strong>vestigates the basic blocks.<br />

Each statement is exam<strong>in</strong>ed whether it conta<strong>in</strong>s: function calls, float<strong>in</strong>g po<strong>in</strong>t or<br />

<strong>in</strong>teger operations, or load/store operations. The obta<strong>in</strong>ed values are added to<br />

operation count data structures. Additionally variable est_cnt holds the estimated<br />

number <strong>of</strong> times a basic block is executed. The results from the iteration<br />

analysis <strong>of</strong> the loops (as far as available) are stored <strong>in</strong>to this variable. Nested<br />

loops lead to a multiplication <strong>of</strong> the trip counts. Loops with <strong>in</strong>determ<strong>in</strong>able<br />

number <strong>of</strong> iterations are assumed to be executed ma_loop times. Hence, the user<br />

sett<strong>in</strong>g the ma_loop parameter <strong>in</strong>fluences the effect <strong>of</strong> such loops on the model.<br />

Further, our approach relies on the fact that functions are compiled one at a<br />

time. We take advantage <strong>of</strong> the fact that functions are compiled first, hence,<br />

the results from the operation count analysis are made available to later passes.<br />

This operation count data gathered by visit<strong>in</strong>g the basic blocks are saved <strong>in</strong><br />

a per function statistic. This allows the computation <strong>of</strong> an overall statistic <strong>in</strong>clud<strong>in</strong>g<br />

all compiled functions. The ma<strong>in</strong> function is processed last. When the<br />

ma<strong>in</strong> function is compiled, the global statistic is complete as far as the data is<br />

available 1 . The process<strong>in</strong>g <strong>of</strong> the data evaluates the relative contribution <strong>of</strong> the<br />

functions to the statistics and <strong>in</strong>serts them <strong>in</strong>to a sorted array. This array is<br />

pruned until all rema<strong>in</strong><strong>in</strong>g functions or basic blocks meet the user constra<strong>in</strong>ts<br />

passed with the compiler options. The ma_<strong>in</strong>sert pass traverses the array and<br />

annotates the rema<strong>in</strong><strong>in</strong>g parts.<br />

Nam<strong>in</strong>g Scheme. A nam<strong>in</strong>g scheme (us<strong>in</strong>g unique names) ensures that annotated<br />

call expressions are dist<strong>in</strong>guishable at run time. This nam<strong>in</strong>g scheme enables<br />

correlat<strong>in</strong>g measured values to certa<strong>in</strong> regions <strong>of</strong> source code, simplify<strong>in</strong>g the<br />

implementation <strong>of</strong> the post-process<strong>in</strong>g tools. Besides, the nam<strong>in</strong>g scheme enables<br />

an optimized generation <strong>of</strong> traces, by omitt<strong>in</strong>g redundant actions <strong>in</strong>side the<br />

runtime library.<br />

1<br />

Externally l<strong>in</strong>ked libraries and third party object files are not subject to the compiler’s<br />

operation count analysis.

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

Saved successfully!

Ooh no, something went wrong!