Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r81826 - sandbox/variadic_templates/sandbox/slim/test
From: cppljevans_at_[hidden]
Date: 2012-12-10 12:18:39


Author: cppljevans
Date: 2012-12-10 12:18:38 EST (Mon, 10 Dec 2012)
New Revision: 81826
URL: http://svn.boost.org/trac/boost/changeset/81826

Log:
Added guage_gprof, guage_heapprof. Both tested using
tuple_benchmark_run.py; however, the last run with
tuple_benchamr_run.py had to be aborted because
took too long with:
  TUPLE_IMPL=bcon12_vertical
  TUPLE_SIZE=15
  TREE_DEPTH=5

Text files modified:
   sandbox/variadic_templates/sandbox/slim/test/Makefile | 4
   sandbox/variadic_templates/sandbox/slim/test/command_guage.py | 133 ++++++++++++++++++++++++++++++++++++++-
   sandbox/variadic_templates/sandbox/slim/test/compiler_map.py | 22 ++++++
   sandbox/variadic_templates/sandbox/slim/test/tuple_benchmark_run.py | 8 +-
   4 files changed, 158 insertions(+), 9 deletions(-)

Modified: sandbox/variadic_templates/sandbox/slim/test/Makefile
==============================================================================
--- sandbox/variadic_templates/sandbox/slim/test/Makefile (original)
+++ sandbox/variadic_templates/sandbox/slim/test/Makefile 2012-12-10 12:18:38 EST (Mon, 10 Dec 2012)
@@ -1,6 +1,8 @@
 BENCHMARK.suffix=mini
 BENCHMARK.suffix=tree_builder
-GUAGE=guage_time #how to measure the performance (python class in command_guage.py)
+GUAGE=guage_gprof #how to measure the performance (python class in command_guage.py)
+#GUAGE=guage_time
+GUAGE=guage_heapprof
 
 TIMEFMT:=%Y%m%d_%H%M%S_%N
 TIMEVAL:=$(shell date +$(TIMEFMT))

Modified: sandbox/variadic_templates/sandbox/slim/test/command_guage.py
==============================================================================
--- sandbox/variadic_templates/sandbox/slim/test/command_guage.py (original)
+++ sandbox/variadic_templates/sandbox/slim/test/command_guage.py 2012-12-10 12:18:38 EST (Mon, 10 Dec 2012)
@@ -3,6 +3,7 @@
 """
 import abc
 import subprocess
+import shlex
 
 class guage_abstract:
     """
@@ -47,8 +48,8 @@
         return self.measured
 
     def measure(self, command_exe, command_args, measure_out):
- compile_cmd=command_exe+command_args
- measure_cmd='time --format '+self.format+' '+compile_cmd
+ measure_cmd=command_exe+command_args
+ measure_cmd='time --format '+self.format+' '+measure_cmd
         print(":measure_cmd=",measure_cmd)
         if True:
           rc=subprocess.call(
@@ -74,12 +75,136 @@
         measure_cmd=command_exe+" -ftime-report "+command_args
         print(":measure_cmd=",measure_cmd)
         if True:
+ measure_lst=shlex.split(measure_cmd)
           rc=subprocess.call(
- measure_cmd
- , shell=True
+ measure_lst
+ , stdout=measure_out
+ , stderr=subprocess.STDOUT
+ )
+ print(":rc=",rc)
+ return rc
+ return 0
+
+import os.path, re
+
+class guage_gprof(guage_abstract):
+ """
+ Concrete class using gprof for measuring performance.
+ This requires that the command_exe arg to be measured
+ has been compiled with the -pg flag.
+ """
+
+ def __init__(self):
+ if False:
+ errmsg="guage_gprof not implemented yet. Try another guage."
+ print(errmsg)
+ raise NotImplementedError
+ self.re_clang=re.compile(".*Profile.*/bin/clang")
+
+ def names(self):
+ return []
+
+ def measure(self, command_exe, command_args, measure_out):
+ found=self.re_clang.search(command_exe)
+ if not found:
+ print(":command_exe=",command_exe,"not clang profiled compiler")
+ rc=1
+ print(":rc=",rc)
+ return rc
+ measure_cmd=command_exe+" -### "+command_args
+ print(":measure_cmd(to get compiler front-end args)=",measure_cmd)
+ if True:
+ measure_lst=shlex.split(measure_cmd)
+ pipe=subprocess.Popen(
+ measure_lst
+ , stderr=subprocess.PIPE
+ )
+ lines=pipe.stderr.readlines()
+ rc=pipe.wait()
+ print(":rc=",rc)
+ if rc != 0:
+ print(":measure_cmd(with -###).",rc)
+ return rc
+ measure_cmd=lines.pop().decode("utf-8")
+ #frontend_cmd should include 'clang -cc1'.
+ #This invokes just the compiler front-end (no driver).
+ print(":measure_cmd=",measure_cmd)
+ measure_cmd=shlex.split(measure_cmd)
+ pipe=subprocess.Popen(
+ measure_lst
+ , stderr=subprocess.PIPE
+ )
+ lines=pipe.stderr.readlines()
+ rc=pipe.wait()
+ print(":rc=",rc)
+ if rc != 0:
+ print(":frontend command failed.",rc)
+ print(":stderr=\n",lines)
+ return rc
+ data_out="./gmon.out"
+ if not os.path.exists(data_out):
+ print(data_out,"does not exist, as required by guage_prof.measure(...)\n")
+ return 1
+ measure_cmd="gprof "+command_exe+" "+data_out
+ print(":gprof_cmd=",measure_cmd)
+ measure_lst=shlex.split(measure_cmd)
+ rc=subprocess.call(
+ measure_lst
             , stdout=measure_out
             , stderr=subprocess.STDOUT
             )
+ print(":gprof rc=",rc)
+ return rc
+ return 0
+
+class guage_heapprof(guage_abstract):
+ """
+ Concrete class for porfiling heap usage.
+ This requires that the command_exe arg to be measured
+ has been compiled with the -g flag.
+ """
+
+ def __init__(self):
+ if False:
+ errmsg="guage_heapprof not implemented yet. Try another guage."
+ print(errmsg)
+ raise NotImplementedError
+ self.re_clang=re.compile(".*Debug.*/bin/clang")
+
+ def names(self):
+ return []
+
+ def measure(self, command_exe, command_args, measure_out):
+ found=self.re_clang.search(command_exe)
+ if not found:
+ print(":command_exe=",command_exe,"not clang created with debugging.")
+ rc=1
           print(":rc=",rc)
           return rc
+ data_out="./massif.out"
+ measure_cmd="valgrind --tool=massif --massif-out-file="+data_out+".%p "+command_exe+" "+command_args
+ print(":valgrind_cmd(to profile heap)=",measure_cmd)
+ if True:
+ measure_lst=shlex.split(measure_cmd)
+ proc=subprocess.Popen(
+ measure_lst
+ )
+ rc=proc.wait();
+ print(":valgrind rc=",rc)
+ if rc != 0:
+ return rc
+ data_pid=data_out+"."+str(proc.pid)
+ if not os.path.exists(data_pid):
+ print(data_pid,"does not exist, as required by guage_helpprof.measure(...)\n")
+ return 1
+ measure_cmd="ms_print "+data_pid
+ print(":ms_print_cmd=",measure_cmd)
+ measure_lst=shlex.split(measure_cmd)
+ rc=subprocess.call(
+ measure_lst
+ , stdout=measure_out
+ , stderr=subprocess.STDOUT
+ )
+ print(":ms_print rc=",rc)
+ return rc
         return 0

Modified: sandbox/variadic_templates/sandbox/slim/test/compiler_map.py
==============================================================================
--- sandbox/variadic_templates/sandbox/slim/test/compiler_map.py (original)
+++ sandbox/variadic_templates/sandbox/slim/test/compiler_map.py 2012-12-10 12:18:38 EST (Mon, 10 Dec 2012)
@@ -1,3 +1,4 @@
+#!/usr/bin/env python3.1
 """
   Provide map from compiler short name to
   a tuple of:
@@ -15,3 +16,24 @@
        "/home/evansl/download/llvm/svn/build/Release/bin/clang"
      , "-std=c++11 -cxx-isystem /home/evansl/download/llvm/svn/llvm/projects/libcxx/include"
      )
+COMPILER_MAP["clangxx_prof"]=(
+ "/home/evansl/download/llvm/svn/build/Release+Profile/bin/clang"
+ , "-std=c++11 -cxx-isystem /home/evansl/download/llvm/svn/llvm/projects/libcxx/include"
+ )
+COMPILER_MAP["clangxx_debass"]=(
+ "/home/evansl/download/llvm/svn/build/Debug+Asserts/bin/clang"
+ , "-std=c++11 -cxx-isystem /home/evansl/download/llvm/svn/llvm/projects/libcxx/include"
+ )
+
+import sys
+
+if __name__ == '__main__':
+ if len(sys.argv) == 1 :
+ if False:
+ print(COMPILER_MAP)
+ else:
+ clang_prof=COMPILER_MAP["clangxx_prof"][0]
+ print("clang_prof=",clang_prof)
+ else:
+ print(sys.argv[1],":",COMPILER_MAP[sys.argv[1]])
+

Modified: sandbox/variadic_templates/sandbox/slim/test/tuple_benchmark_run.py
==============================================================================
--- sandbox/variadic_templates/sandbox/slim/test/tuple_benchmark_run.py (original)
+++ sandbox/variadic_templates/sandbox/slim/test/tuple_benchmark_run.py 2012-12-10 12:18:38 EST (Mon, 10 Dec 2012)
@@ -40,14 +40,14 @@
 
 def domain_defs(benchmark_suffix):
   """defines domains used in benchmark"""
- compiler_domain=['clangxx']
+ compiler_domain=['clangxx_debass']
   niter=1#number of iterations to run with same values for other domains.
   impl_domain=\
     [ 'bcon12_horizontal'
- #, 'bcon12_vertical'
+ , 'bcon12_vertical'
     ]
   tuple_size_domain_del=5
- tuple_sizes_domain=range(10,11,tuple_size_domain_del)
+ tuple_sizes_domain=range(10,16,tuple_size_domain_del)
   name_domain=collections.OrderedDict\
     ( ( ('iter', lambda ignore:range(niter))
       , ('compiler', compilers(compiler_domain))
@@ -59,7 +59,7 @@
   if benchmark_suffix == "mini" :
     name_domain['LAST_LESS']=lasts(4,tuple_size_domain_del)
   else:
- name_domain['TREE_DEPTH']=tree_depths(2,4,1)
+ name_domain['TREE_DEPTH']=tree_depths(5,7,1)
     name_domain['TUPLE_TEMPLATED_CTOR']=templated_ctor_flags(1,2)
   domain_names=name_domain.keys()
   indices_type=collections.namedtuple('domain_indices',domain_names)


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk