[llvm-commits] Static Profile Patch

Andrei Alvares logytech at gmail.com
Fri Sep 11 18:46:51 PDT 2009


Hello everyone,
  Since this patch hasn't been applied yet, I'm taking the liberty to send a
more updated version. I made several changes in the branch predictor
(BranchPredictionPass) and in the intra procedural static profiler
(BlockEdgeFrequencyPass).
  Attachment: stprof-11.09.09.patch.

  While I was debbuging the code, I've noticed that I was maintaining data
across multiple calls of runOnFunction on both passes, which was indeed an
undesirable behavior. After cleaning up, both passes shown improved results.
In fact, the branch predictor produced very close related prediction as
Ball's predictor. I ran the branch predictor on the SPEC 2000 (int and
float). I'm attaching "heuristics.txt" which compared results separated by
heuristic for both predictors. While most heuristics predicted more
accurately, the call and opcode heuristics shown worst results. This means
that is still space for improvements. Also, I've found a bug in the way the
predictor threats a branch that have some backedge sucessors, but not all. I
expected that the other branches were always exit edges, but there are cases
that this situation is not true.

  Moreover, while calculating blocks and edge frequencies it is possible to
verify if it is calculating correct frequency information. Since the entry
block frequency is always one, is expected that the exit's total frequency
is also one. So, all we need to do is check the sum of all predecessors
edges of exit's basic blocks to match one. However, I've found two cases of
miscalculation by the pass: (1) when the control flow graph is not
reducible; (2) when seems to be a loop that does not terminates (has no exit
blocks). Although this pass can calculate frequencies for those situations,
it might not be accurate. Nevertheless, seems like the pass is doing what is
supposed to.

  The global static profiler (inter procedural) is not as accurate as Wu's
paper yet. But after those fixes, it has improved quite significantly. I'm
attaching the results of the profiler comparing the correct prediction rate
of the top most executed blocks, edges, and function call invocations
(ranging from 10% to 50%). Attachments: block.txt, edge.txt and call.txt.

  Thanks,
    Andrei

On Wed, Sep 2, 2009 at 3:37 PM, Andrei Alvares <logytech at gmail.com> wrote:

> Hello everyone,
>  Here it follows the static profiler implementation, developed as
> part of my google summer of code project. It performs branch
> predictions in compilation time, i.e., assign probabilities to branch
> outcomes using a set of predefined heuristics. Also, it calculates
> intra and interprocedural profiling by staticly estimate basic blocks
> and edges frequencies (local and global) and function call invocations
> frequencies.
>  Attachment: stprof-02.02.09.patch
>
>  I've run the static profiler on some of the SPECint 2000 programs
> (those that I was able to compile and run).  It has not yet achieved
> the accuracy found in Wu's paper, but I believe it can still be
> improved.
>  Best regards,
>    Andrei
>
> Youfeng Wu and James R. Larus. Static branch frequency and program
> profile analysis. In MICRO 27: Proceedings of the 27th annual
> international symposium on Microarchitecture. IEEE, 1994.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20090911/a7cf4244/attachment.html>
-------------- next part --------------
     LBH PH  CH  OH  LEH RH  SH  LHH GH
Ball 88% 60% 78% 84% 80% 72% 55% 75% 62%
LLVM 85% 85% 57% 60% 85% 86% 55% 77% 67%





-------------- next part --------------
	        Coverage	10%	20%	30%	40%	50%
164.gzip	58.17%		31.10%	54.71%	68.02%	75.38%	73.27%
175.vpr		74.52%		36.90%	42.57%	46.59%	53.57%	61.25%
176.gcc		59.74%		 9.52%	16.44%	28.78%	40.91%	53.21%
181.mcf		37.94%		50.00%	68.49%	71.82%	74.83%	80.43%
186.crafty	40.13%		38.69%	56.70%	69.18%	73.37%	73.63%
197.parser	40.27%		48.24%	54.31%	59.15%	68.68%	74.27%
254.gap		72.31%		 8.41%	22.31%	37.05%	63.41%	77.25%
256.bzip2	36.99%		28.57%	52.68%	67.26%	77.23%	79.14%
300.twolf	59.62%		8.61%	24.83%	37.94%	43.57%	51.01%
177.mesa	94.45%		55.92%	78.07%	85.38%	89.03%	91.23%
179.art		40.27%		61.36%	61.80%	70.15%	83.71%	77.13%
183.equake	27.04%		45.16%	55.56%	62.11%	77.17%	78.62%
188.ammp	80.38%		19.18%	27.60%	36.72%	46.50%	49.75%

-------------- next part --------------
		Coverage	10%	20%	30%	40%	50%
164.gzip	62.30%		31.62%	56.29%	67.00%	69.19%	71.25%
175.vpr		77.89%		35.14%	39.41%	47.13%	51.67%	60.80%
176.gcc		66.58%		8.77%	16.04%	28.94%	40.29%	53.61%
181.mcf		44.28%		49.09%	60.91%	64.85%	74.09%	83.27%
186.crafty	46.12%		34.26%	52.15%	66.46%	68.43%	68.89%
197.parser	45.53%		44.53%	51.61%	56.59%	65.86%	71.53%
254.gap		78.22%		 7.81%	22.37%	51.37%	71.56%	77.95%
256.bzip2	38.82%		28.10%	53.42%	65.94%	74.31%	76.33%
300.twolf	66.53%		10.59%	30.48%	38.09%	40.88%	52.25%
177.mesa	95.52%		45.29%	72.82%	81.88%	86.41%	89.13%
179.art		50.59%		50.75%	65.19%	71.29%	71.85%	71.89%
183.equake	28.87%		45.24%	56.47%	66.14%	77.06%	76.06%
188.ammp	84.47%		21.53%	27.03%	39.40%	44.45%	53.02%

-------------- next part --------------
		Coverage	10%	20%	30%	40%	50%
164.gzip	67.71%		33.33%	57.89%	60.71%	65.79%	66.67%
175.vpr		83.85%		21.05%	26.32%	40.35%	47.37%	47.92%
176.gcc		58.64%		16.06%	43.67%	51.98%	64.90%	69.04%
181.mcf		65.85%		50.00%	37.50%	66.67%	56.25%	50.00%
186.crafty	54.36%		42.86%	51.72%	54.55%	55.93%	60.81%
197.parser	56.06%		51.43%	61.97%	67.92%	73.24%	75.14%
254.gap		57.29%		24.14%	18.86%	30.80%	46.15%	66.06%
256.bzip2	72.53%		44.44%	44.44%	51.85%	58.33%	64.44%
300.twolf	59.81%		 0.00%	23.81%	39.06%	56.47%	57.01%
177.mesa	93.15%		59.05%	79.52%	86.35%	89.76%	92.19%
179.art		73.81%		50.00%	37.50%	33.33%	31.25%	38.10%
183.equake	72.50%		 0.00%	 0.00%	8.33%	31.25%	45.00%
188.ammp	81.52%		19.05%	28.57%	23.81%	40.48%	47.62%

-------------- next part --------------
A non-text attachment was scrubbed...
Name: stprof-11.09.09.patch
Type: text/x-patch
Size: 98407 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20090911/a7cf4244/attachment.bin>


More information about the llvm-commits mailing list