[PATCH 4/N] Add new analyze_brprob_spec.py script

Jan Hubicka hubicka@ucw.cz
Wed Jun 8 15:12:00 GMT 2016


> Hi.
> 
> The second follow up patch adds new script which is a simple wrapper around
> analyze_brprob.py and can be used to dump statistics for results that are in
> different folder (like SPEC benchmarks).
> 
> Sample:
> ./contrib/analyze_brprob_spec.py --sorting=hitrate /home/marxin/Programming/cpu2006/benchspec/CPU2006/
> 
> Sample output:
> 401.bzip2
> HEURISTICS                           BRANCHES  (REL)  HITRATE                COVERAGE COVERAGE  (REL)
> no prediction                             107  14.0%  19.45% /  84.37%     2768134733    2.77G  10.8%
> opcode values nonequal (on trees)          76  10.0%  32.24% /  85.06%     4034681344    4.03G  15.8%
> call                                       95  12.5%  45.50% /  93.31%      152224913  152.22M   0.6%
> DS theory                                 275  36.1%  45.56% /  84.30%     7308863904    7.31G  28.6%
> continue                                   14   1.8%  48.44% /  73.14%     1479774996    1.48G   5.8%
> guessed loop iterations                    12   1.6%  68.30% /  71.61%      269705737  269.71M   1.1%
> combined                                  762 100.0%  69.52% /  89.32%    25553311262   25.55G 100.0%
> goto                                       40   5.2%  72.41% /  98.80%      882062676  882.06M   3.5%
> opcode values positive (on trees)          40   5.2%  76.74% /  88.09%     1394104926    1.39G   5.5%
> pointer (on trees)                         61   8.0%  83.79% / 100.00%         931107  931.11K   0.0%
> early return (on trees)                    31   4.1%  84.39% /  84.41%     2548058402    2.55G  10.0%
> first match                               380  49.9%  89.79% /  92.57%    15476312625   15.48G  60.6%
> loop exit                                 316  41.5%  90.09% /  92.88%    15065219828   15.07G  59.0%
> guess loop iv compare                       2   0.3%  99.61% /  99.61%       26987995   26.99M   0.1%
> loop iv compare                             1   0.1%  99.61% /  99.61%         105411  105.41K   0.0%
> loop iterations                            38   5.0%  99.64% /  99.64%      140236649  140.24M   0.5%
> null return                                 2   0.3% 100.00% / 100.00%             18    18.00   0.0%
> noreturn call                              13   1.7% 100.00% / 100.00%        1045000    1.04M   0.0%
> const return                                2   0.3% 100.00% / 100.00%            816   816.00   0.0%
> negative return                            62   8.1% 100.00% / 100.00%      618097152  618.10M   2.4%
> 
> 410.bwaves
> HEURISTICS                           BRANCHES  (REL)  HITRATE                COVERAGE COVERAGE  (REL)
> call                                        1   0.6%   0.00% / 100.00%             20    20.00   0.0%
> no prediction                               6   3.7%   0.28% /  99.72%        2704184    2.70M   0.1%
> opcode values nonequal (on trees)           4   2.4%  60.00% /  70.00%            200   200.00   0.0%
> loop iterations                             7   4.3%  80.00% /  80.00%      112892000  112.89M   2.4%
> first match                                83  50.6%  81.67% /  81.67%     4393885465    4.39G  92.1%
> loop exit                                  76  46.3%  81.71% /  81.71%     4280993465    4.28G  89.8%
> combined                                  164 100.0%  83.05% /  83.11%     4768545507    4.77G 100.0%
> DS theory                                  75  45.7% 100.00% / 100.00%      371955858  371.96M   7.8%
> early return (on trees)                     3   1.8% 100.00% / 100.00%            688   688.00   0.0%
> opcode values positive (on trees)          71  43.3% 100.00% / 100.00%      371955658  371.96M   7.8%
> 
> ...
> 
> Thanks,
> Martin
> 

> >From ca9806bf77bd90df43913f5f1552ed16379dcf38 Mon Sep 17 00:00:00 2001
> From: marxin <mliska@suse.cz>
> Date: Fri, 3 Jun 2016 12:46:43 +0200
> Subject: [PATCH 4/4] Add new analyze_brprob_spec.py script
> 
> contrib/ChangeLog:
> 
> 2016-06-08  Martin Liska  <mliska@suse.cz>
> 
> 	* analyze_brprob_spec.py: New file.

OK,
thanks

Honza
> ---
>  contrib/analyze_brprob_spec.py | 58 ++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 58 insertions(+)
>  create mode 100755 contrib/analyze_brprob_spec.py
> 
> diff --git a/contrib/analyze_brprob_spec.py b/contrib/analyze_brprob_spec.py
> new file mode 100755
> index 0000000..a28eaac
> --- /dev/null
> +++ b/contrib/analyze_brprob_spec.py
> @@ -0,0 +1,58 @@
> +#!/usr/bin/env python3
> +
> +# This file is part of GCC.
> +#
> +# GCC is free software; you can redistribute it and/or modify it under
> +# the terms of the GNU General Public License as published by the Free
> +# Software Foundation; either version 3, or (at your option) any later
> +# version.
> +#
> +# GCC is distributed in the hope that it will be useful, but WITHOUT ANY
> +# WARRANTY; without even the implied warranty of MERCHANTABILITY or
> +# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
> +# for more details.
> +#
> +# You should have received a copy of the GNU General Public License
> +# along with GCC; see the file COPYING3.  If not see
> +# <http://www.gnu.org/licenses/>.  */
> +
> +import sys
> +import os
> +import subprocess
> +import tempfile
> +import argparse
> +
> +script_location = os.path.realpath(__file__)
> +
> +parser = argparse.ArgumentParser()
> +parser.add_argument('location', metavar = 'dump_file', help = 'Location with SPEC benchmarks')
> +parser.add_argument('-s', '--sorting', dest = 'sorting', choices = ['branches', 'hitrate', 'coverage'], default = 'branches')
> +
> +args = parser.parse_args()
> +
> +benchmarks = os.listdir(args.location)
> +
> +for b in sorted(benchmarks):
> +    dumps = []
> +    for root, dirs, files in os.walk(os.path.join(args.location, b)):
> +        for x in files:
> +            if x.endswith('.profile'):
> +                dumps.append(os.path.join(root, x))
> +
> +    if len(dumps) == 0:
> +        continue
> +
> +    temp = tempfile.NamedTemporaryFile(delete = False)
> +    for d in dumps:
> +        temp.write(open(d, 'rb').read())
> +
> +    temp.close()
> +
> +    print()
> +    print(b)
> +    sys.stdout.flush()
> +    p = [os.path.join(os.path.dirname(script_location), 'analyze_brprob.py'), temp.name, '--sorting', args.sorting]
> +    p = subprocess.check_call(p)
> +    sys.stdout.flush()
> +
> +    os.remove(temp.name)
> -- 
> 2.8.3
> 



More information about the Gcc-patches mailing list