Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r81637 - sandbox/variadic_templates/sandbox/slim/test
From: cppljevans_at_[hidden]
Date: 2012-11-30 12:45:45


Author: cppljevans
Date: 2012-11-30 12:45:44 EST (Fri, 30 Nov 2012)
New Revision: 81637
URL: http://svn.boost.org/trac/boost/changeset/81637

Log:
 1) *_run.py more explicit on how to set domains
 2) New domain, TUPLE_TEMPLATED_CTOR, which is flag
    indicating whether bcon12* tuples have templated
    CTOR's taking args for tuple elements.
 3) *.run.txt using new domain, and still shows
    clang better at horizontal than vertical implementation.
 4) Missing: changes in tuple_impl.bcon12*.hpp.
    Don't (yet) know why.

Text files modified:
   sandbox/variadic_templates/sandbox/slim/test/RETURN_ENABLE_IF_DEFAULTS.hpp | 1
   sandbox/variadic_templates/sandbox/slim/test/compiler_map.py | 18 ++++-----
   sandbox/variadic_templates/sandbox/slim/test/make_tuple.hpp | 20 +++++++---
   sandbox/variadic_templates/sandbox/slim/test/tree_builder.hpp | 52 +++++++++++++++++++++++---
   sandbox/variadic_templates/sandbox/slim/test/tuple.benchmark.tree_builder.cpp | 8 ++-
   sandbox/variadic_templates/sandbox/slim/test/tuple.benchmark.tree_builder.guage_time._.run.txt | 66 +++++++++++++++++++++++++++++----
   sandbox/variadic_templates/sandbox/slim/test/tuple_benchmark_domain.py | 16 ++++++++
   sandbox/variadic_templates/sandbox/slim/test/tuple_benchmark_filt.py | 3 +
   sandbox/variadic_templates/sandbox/slim/test/tuple_benchmark_run.py | 78 ++++++++++++++++++++--------------------
   9 files changed, 187 insertions(+), 75 deletions(-)

Modified: sandbox/variadic_templates/sandbox/slim/test/RETURN_ENABLE_IF_DEFAULTS.hpp
==============================================================================
--- sandbox/variadic_templates/sandbox/slim/test/RETURN_ENABLE_IF_DEFAULTS.hpp (original)
+++ sandbox/variadic_templates/sandbox/slim/test/RETURN_ENABLE_IF_DEFAULTS.hpp 2012-11-30 12:45:44 EST (Fri, 30 Nov 2012)
@@ -9,6 +9,7 @@
 // To enable reuse in other code using #include's.
 //
 //=====================================================
+#include <type_traits>
 
 // C++11 eliminates the need for macros! Oh, wait ...
 #define RETURN(...) -> decltype(__VA_ARGS__) { return __VA_ARGS__; }

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-11-30 12:45:44 EST (Fri, 30 Nov 2012)
@@ -7,13 +7,11 @@
 
 COMPILER_MAP={}
 
-if True:
- COMPILER_MAP["gcc4_8"]=(
- "/home/evansl/download/gcc/4.8-20121028/install/bin/g++"
- , "-std=gnu++11"
- )
-if True:
- COMPILER_MAP["clangxx"]=(
- "/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["gcc4_8"]=(
+ "/home/evansl/download/gcc/4.8-20121028/install/bin/g++"
+ , "-std=gnu++11"
+ )
+COMPILER_MAP["clangxx"]=(
+ "/home/evansl/download/llvm/svn/build/Release/bin/clang"
+ , "-std=c++11 -cxx-isystem /home/evansl/download/llvm/svn/llvm/projects/libcxx/include"
+ )

Modified: sandbox/variadic_templates/sandbox/slim/test/make_tuple.hpp
==============================================================================
--- sandbox/variadic_templates/sandbox/slim/test/make_tuple.hpp (original)
+++ sandbox/variadic_templates/sandbox/slim/test/make_tuple.hpp 2012-11-30 12:45:44 EST (Fri, 30 Nov 2012)
@@ -1,11 +1,13 @@
 #ifndef MAKE_TUPLE_INCLUDE_HPP
 #define MAKE_TUPLE_INCLUDE_HPP
-#include <boost/preprocessor/stringize.hpp>
+#ifndef TUPLE_TEMPLATED_CTOR
+ #define TUPLE_TEMPLATED_CTOR 1
+#endif
 #ifndef TUPLE_IMPL
- #define TUPLE_IMPL bcon12_vertical
+ #define TUPLE_IMPL bcon12_horizontal
 #endif
+#include <boost/preprocessor/stringize.hpp>
 #include BOOST_PP_STRINGIZE(tuple_impl.TUPLE_IMPL.hpp)
-#if TUPLE_BENCH_TEMPLATED_CTOR == 1
 //Acknowlegements:
 // The following code was adapted from part of the code in:
 // https://github.com/ericniebler/home/blob/master/src/tuple/unrolled_tuple.hpp
@@ -39,10 +41,16 @@
 ///////////////////////////////////////////////////////////////////////////////
 // make_tuple
   template<typename ...T>
- tuple_bench<detail::as_tuple_element<T>...>
+ inline
+ tuple_bench<detail::as_tuple_element<T>...>
 make_tuple(T &&...t)
 {
- return {t...};
+ typedef tuple_bench<detail::as_tuple_element<T>...> tuple_t;
+#if TUPLE_TEMPLATED_CTOR == 1
+ tuple_t a_tuple(static_cast<T &&>(t)...);
+#else
+ tuple_t a_tuple;
+#endif//TUPLE_TEMPLATED_CTOR == 1
+ return a_tuple;
 }
-#endif//TUPLE_BENCH_TEMPLATED_CTOR == 1
 #endif

Modified: sandbox/variadic_templates/sandbox/slim/test/tree_builder.hpp
==============================================================================
--- sandbox/variadic_templates/sandbox/slim/test/tree_builder.hpp (original)
+++ sandbox/variadic_templates/sandbox/slim/test/tree_builder.hpp 2012-11-30 12:45:44 EST (Fri, 30 Nov 2012)
@@ -20,20 +20,58 @@
 #endif
 
 #ifndef TREE_DEPTH
-#define TREE_DEPTH 5
+#define TREE_DEPTH 2
 #endif
 
-template<int I>
+ template
+ < int Depth//tree depth
+ , int Index//index of tuple element (used in get<Index>(tuple))
+ >
+struct node_tag
+ /**@brief
+ * A 'tag' to put into tree node showing at what
+ * depth it's located in the tree, and what child
+ * the node is in it's parent's node.
+ */
+{
+};
+
+ template
+ < int Depth
+ , int Index
+ , typename Children
+ >
+ using
+tree_node
+ =tuple_bench<node_tag<Depth,Index>,Children>
+ ;
+ template
+ < int Depth
+ , int Index
+ , typename Children
+ >
+ tree_node<Depth,Index,Children>
+make_node
+ ( Children&& t
+ )
+ {
+ return ::make_tuple
+ ( node_tag<Depth,Index>()
+ , static_cast<Children&&>(t)
+ );
+ }
+
+template<int Depth>
 struct tree_builder
 {
- #define M0(Z, N, D) ::make_tuple( static_cast<T &&>(t), std::integral_constant<int, N>())
- #define M1(Z, N, D) auto BOOST_PP_CAT(tmp, N) = ::get<N>(res);
+ #define M0(Z, Index, D) ::make_node<Depth,Index>(static_cast<T &&>(t))
+ #define M1(Z, Index, D) auto BOOST_PP_CAT(tmp, Index) = ::get<Index>(res);
 
     template<typename T>
     static auto make_tree(T &&t)
- -> decltype(tree_builder<I+1>::make_tree(::make_tuple(BOOST_PP_ENUM(TUPLE_SIZE, M0, ~))))
+ -> decltype(tree_builder<Depth+1>::make_tree(::make_tuple(BOOST_PP_ENUM(TUPLE_SIZE, M0, ~))))
     {
- auto res = tree_builder<I+1>::make_tree(::make_tuple(BOOST_PP_ENUM(TUPLE_SIZE, M0, ~)));
+ auto res = tree_builder<Depth+1>::make_tree(::make_tuple(BOOST_PP_ENUM(TUPLE_SIZE, M0, ~)));
         // Get each element of the tuple.
         BOOST_PP_REPEAT(TUPLE_SIZE, M1, ~)
         return res;
@@ -44,7 +82,7 @@
 };
 
 template<>
-struct tree_builder<TREE_DEPTH+1>
+struct tree_builder<TREE_DEPTH>
 {
     template<typename T>
     static T make_tree(T &&t)

Modified: sandbox/variadic_templates/sandbox/slim/test/tuple.benchmark.tree_builder.cpp
==============================================================================
--- sandbox/variadic_templates/sandbox/slim/test/tuple.benchmark.tree_builder.cpp (original)
+++ sandbox/variadic_templates/sandbox/slim/test/tuple.benchmark.tree_builder.cpp 2012-11-30 12:45:44 EST (Fri, 30 Nov 2012)
@@ -12,11 +12,13 @@
 // http://www.boost.org/LICENSE_1_0.txt)
 //
 #include "./tree_builder.hpp"
+template<unsigned I>
+struct leaf
+{};
+
 int main()
 {
- char sz[] = "hello";
- tuple_bench<int, char(&)[6]> x = ::make_tuple(1, std::ref(sz));
- auto y = tree_builder<1>::make_tree(::make_tuple(1, "hello", 3.14, 'a', x));
+ auto y = tree_builder<1>::make_tree(::make_tuple(leaf<100>(),leaf<101>(),leaf<102>()));
     return 0;
 }
 

Modified: sandbox/variadic_templates/sandbox/slim/test/tuple.benchmark.tree_builder.guage_time._.run.txt
==============================================================================
--- sandbox/variadic_templates/sandbox/slim/test/tuple.benchmark.tree_builder.guage_time._.run.txt (original)
+++ sandbox/variadic_templates/sandbox/slim/test/tuple.benchmark.tree_builder.guage_time._.run.txt 2012-11-30 12:45:44 EST (Fri, 30 Nov 2012)
@@ -17,21 +17,69 @@
 compiler_exe: /home/evansl/download/llvm/svn/build/Release/bin/clang
 ]version
 ]compilers
-domain_names['compiler', 'TUPLE_IMPL', 'TUPLE_SIZE', 'TUPLE_UNROLL_MAX', 'TREE_DEPTH']domain_names
+domain_names['compiler', 'TUPLE_IMPL', 'TUPLE_SIZE', 'TUPLE_UNROLL_MAX', 'TREE_DEPTH', 'TUPLE_TEMPLATED_CTOR']domain_names
 range_how['guage_time', 'UserTime', 'SystemTime', 'ElapsedTime', 'MajorPageFaults', 'MaxResidentSetSize', 'Swaps', 'ContextSwitches']range_how
-domain_values['gcc4_8', 'bcon12_horizontal', 10, -1, 2]domain_values
+domain_values['gcc4_8', 'bcon12_horizontal', 15, -1, 4, 0]domain_values
 range_out[
-UserTime[0.56]SystemTime[0.07]ElapsedTime[0.63]MajorPageFaults[64]MaxResidentSetSize[140704]Swaps[0]ContextSwitches[13]
+UserTime[0.81]SystemTime[0.09]ElapsedTime[0.89]MajorPageFaults[0]MaxResidentSetSize[221744]Swaps[0]ContextSwitches[5]
 ]range_out
-domain_values['gcc4_8', 'bcon12_horizontal', 10, -1, 3]domain_values
+domain_values['gcc4_8', 'bcon12_horizontal', 15, -1, 4, 1]domain_values
 range_out[
-UserTime[0.65]SystemTime[0.05]ElapsedTime[0.68]MajorPageFaults[0]MaxResidentSetSize[165408]Swaps[0]ContextSwitches[6]
+UserTime[1.01]SystemTime[0.12]ElapsedTime[1.10]MajorPageFaults[0]MaxResidentSetSize[222000]Swaps[0]ContextSwitches[5]
 ]range_out
-domain_values['clangxx', 'bcon12_horizontal', 10, -1, 2]domain_values
+domain_values['gcc4_8', 'bcon12_horizontal', 15, -1, 5, 0]domain_values
 range_out[
-UserTime[0.38]SystemTime[0.05]ElapsedTime[0.45]MajorPageFaults[24]MaxResidentSetSize[108016]Swaps[0]ContextSwitches[6]
+UserTime[3.76]SystemTime[0.41]ElapsedTime[4.15]MajorPageFaults[0]MaxResidentSetSize[1240656]Swaps[0]ContextSwitches[5]
 ]range_out
-domain_values['clangxx', 'bcon12_horizontal', 10, -1, 3]domain_values
+domain_values['gcc4_8', 'bcon12_horizontal', 15, -1, 5, 1]domain_values
 range_out[
-UserTime[0.46]SystemTime[0.04]ElapsedTime[0.49]MajorPageFaults[0]MaxResidentSetSize[117424]Swaps[0]ContextSwitches[3]
+UserTime[1.82]SystemTime[0.13]ElapsedTime[1.93]MajorPageFaults[0]MaxResidentSetSize[271136]Swaps[0]ContextSwitches[5]
+]range_out
+domain_values['gcc4_8', 'bcon12_vertical', 15, 10, 4, 0]domain_values
+range_out[
+UserTime[0.68]SystemTime[0.08]ElapsedTime[0.74]MajorPageFaults[0]MaxResidentSetSize[190688]Swaps[0]ContextSwitches[5]
+]range_out
+domain_values['gcc4_8', 'bcon12_vertical', 15, 10, 4, 1]domain_values
+range_out[
+UserTime[0.78]SystemTime[0.04]ElapsedTime[0.81]MajorPageFaults[0]MaxResidentSetSize[187776]Swaps[0]ContextSwitches[5]
+]range_out
+domain_values['gcc4_8', 'bcon12_vertical', 15, 10, 5, 0]domain_values
+range_out[
+UserTime[1.41]SystemTime[0.08]ElapsedTime[1.49]MajorPageFaults[0]MaxResidentSetSize[418768]Swaps[0]ContextSwitches[8]
+]range_out
+domain_values['gcc4_8', 'bcon12_vertical', 15, 10, 5, 1]domain_values
+range_out[
+UserTime[0.98]SystemTime[0.12]ElapsedTime[1.11]MajorPageFaults[8]MaxResidentSetSize[208464]Swaps[0]ContextSwitches[5]
+]range_out
+domain_values['clangxx', 'bcon12_horizontal', 15, -1, 4, 0]domain_values
+range_out[
+UserTime[0.44]SystemTime[0.05]ElapsedTime[0.48]MajorPageFaults[0]MaxResidentSetSize[119440]Swaps[0]ContextSwitches[3]
+]range_out
+domain_values['clangxx', 'bcon12_horizontal', 15, -1, 4, 1]domain_values
+range_out[
+UserTime[0.65]SystemTime[0.04]ElapsedTime[0.68]MajorPageFaults[0]MaxResidentSetSize[144160]Swaps[0]ContextSwitches[3]
+]range_out
+domain_values['clangxx', 'bcon12_horizontal', 15, -1, 5, 0]domain_values
+range_out[
+UserTime[0.61]SystemTime[0.07]ElapsedTime[0.67]MajorPageFaults[0]MaxResidentSetSize[131520]Swaps[0]ContextSwitches[3]
+]range_out
+domain_values['clangxx', 'bcon12_horizontal', 15, -1, 5, 1]domain_values
+range_out[
+UserTime[1.27]SystemTime[0.09]ElapsedTime[1.35]MajorPageFaults[0]MaxResidentSetSize[168912]Swaps[0]ContextSwitches[3]
+]range_out
+domain_values['clangxx', 'bcon12_vertical', 15, 10, 4, 0]domain_values
+range_out[
+UserTime[5.89]SystemTime[0.05]ElapsedTime[5.93]MajorPageFaults[0]MaxResidentSetSize[125728]Swaps[0]ContextSwitches[3]
+]range_out
+domain_values['clangxx', 'bcon12_vertical', 15, 10, 4, 1]domain_values
+range_out[
+UserTime[6.78]SystemTime[0.04]ElapsedTime[6.81]MajorPageFaults[0]MaxResidentSetSize[133920]Swaps[0]ContextSwitches[3]
+]range_out
+domain_values['clangxx', 'bcon12_vertical', 15, 10, 5, 0]domain_values
+range_out[
+UserTime[93.41]SystemTime[0.30]ElapsedTime[93.70]MajorPageFaults[0]MaxResidentSetSize[180112]Swaps[0]ContextSwitches[3]
+]range_out
+domain_values['clangxx', 'bcon12_vertical', 15, 10, 5, 1]domain_values
+range_out[
+UserTime[90.21]SystemTime[0.42]ElapsedTime[90.62]MajorPageFaults[0]MaxResidentSetSize[173712]Swaps[0]ContextSwitches[3]
 ]range_out

Modified: sandbox/variadic_templates/sandbox/slim/test/tuple_benchmark_domain.py
==============================================================================
--- sandbox/variadic_templates/sandbox/slim/test/tuple_benchmark_domain.py (original)
+++ sandbox/variadic_templates/sandbox/slim/test/tuple_benchmark_domain.py 2012-11-30 12:45:44 EST (Fri, 30 Nov 2012)
@@ -73,6 +73,21 @@
     else:
       return [2]
 
+class templated_ctor_flag(object):
+ "TUPLE_TEMPLATED_CTOR macro values(only used in tree_builder benchmark)"
+ def __init__(self, start=0, finish=1):
+ self.start=max(0,start)
+ self.finish=min(finish,1)
+ def __call__(self,xs):
+ if True:
+ return range(
+ self.start
+ , self.finish+1
+ , 1
+ )
+ else:
+ return [0,1]
+
 if __name__ == '__main__':
   tuple_max_size=8
   tuple_min_size=4
@@ -83,6 +98,7 @@
     , sizes(range(tuple_min_size,tuple_max_size+1,tuple_del_size))
     , last(tuple_min_size,tuple_del_size)
     , unroll_max()
+ , templated_ctor_flag()
     ])
   for element in domain():
       print(element)

Modified: sandbox/variadic_templates/sandbox/slim/test/tuple_benchmark_filt.py
==============================================================================
--- sandbox/variadic_templates/sandbox/slim/test/tuple_benchmark_filt.py (original)
+++ sandbox/variadic_templates/sandbox/slim/test/tuple_benchmark_filt.py 2012-11-30 12:45:44 EST (Fri, 30 Nov 2012)
@@ -28,7 +28,8 @@
       : ( d_lst[d_ndx.compiler] == 'gcc4_8'
           or d_lst[d_ndx.compiler] == 'clangxx'
           )
- and d_lst[d_ndx.TUPLE_SIZE] == 10
+ and d_lst[d_ndx.TUPLE_TEMPLATED_CTOR] == 0
+ and d_lst[d_ndx.TREE_DEPTH] == 5
     , domain_range_values
     )
   print(":filt_dr=")

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-11-30 12:45:44 EST (Fri, 30 Nov 2012)
@@ -3,17 +3,39 @@
 Run compilers on programs while recording resources usage.
 """
 from __future__ import print_function
-from compiler_map import COMPILER_MAP
-from tuple_benchmark_tags import TAG_TUPLE
 import sys
-from datetime import datetime
 import subprocess
 
 from tuple_benchmark_domain import *
+from compiler_map import COMPILER_MAP
+from tuple_benchmark_tags import TAG_TUPLE
 import command_guage
 import tuple_benchmark_filenames
 import boost_root
 
+BOOST_ROOT_PATH=boost_root.path()
+
+IMPL_MAP_INC={}#implementation key -> -I include flags to compiler
+IMPL_MAP_INC["horizontal"]=\
+ ""\
+ #
+IMPL_MAP_INC["vertical"]=\
+ " -I"+BOOST_ROOT_PATH\
+ #
+IMPL_MAP_INC["bcon12_horizontal"]=\
+ " -I"+BOOST_ROOT_PATH\
+ #
+IMPL_MAP_INC["bcon12_vertical"]=\
+ " -I"+BOOST_ROOT_PATH\
+ #
+IMPL_MAP_INC["compstor"]=\
+ " -I"+BOOST_ROOT_PATH\
+ + " -I"+BOOST_ROOT_PATH+"/sandbox/rw/variadic_templates"\
+ #
+IMPL_MAP_INC["std"]=\
+ ""\
+ #
+
 def main(argv):
   """
   Inputs:
@@ -43,46 +65,24 @@
     guage_spec=argv[iarg:]
   src_filename=tuple_benchmark_filenames.src_filename(benchmark_suffix)
   #print("src_filename=",src_filename)
- boost_root_path=boost_root.path()
- impl_map_inc={}#implementation key -> -I include flags to compiler
- if False:
- impl_map_inc["horizontal"]=\
- ""\
- #
- if False:
- impl_map_inc["vertical"]=\
- " -I"+boost_root_path\
- #
- if True:
- impl_map_inc["bcon12_horizontal"]=\
- ""\
- #
- if False:
- impl_map_inc["bcon12_vertical"]=\
- " -I"+boost_root_path\
- #
- if False:
- impl_map_inc["compstor"]=\
- " -I"+boost_root_path\
- + " -I"+boost_root_path+"/sandbox/rw/variadic_templates"\
- #
- if False:
- impl_map_inc["std"]=\
- ""\
- #
- tuple_min_size=10
- tuple_max_size=10
- tuple_del_size=5
+ #[Define Domains.
+ compiler_domain=['gcc4_8','clangxx']
+ impl_domain=['bcon12_horizontal','bcon12_vertical']
+ tuple_size_domain_min=15
+ tuple_size_domain_max=15
+ tuple_size_domain_del=5
   name_domain=[
- [ 'compiler', compilers(COMPILER_MAP.keys())]
- , [ 'TUPLE_IMPL', impls(impl_map_inc.keys())]
- , [ 'TUPLE_SIZE', sizes(range(tuple_min_size,tuple_max_size+1,tuple_del_size))]
+ [ 'compiler', compilers(compiler_domain)]
+ , [ 'TUPLE_IMPL', impls(impl_domain)]
+ , [ 'TUPLE_SIZE', sizes(range(tuple_size_domain_min,tuple_size_domain_max+1,tuple_size_domain_del))]
     , [ 'TUPLE_UNROLL_MAX', unroll_max()]
     ]
   if benchmark_suffix == "mini" :
- name_domain.append( [ 'LAST_LESS', last(4,tuple_del_size)])
+ name_domain.append( [ 'LAST_LESS', last(4,tuple_size_domain_del)])
   else:
- name_domain.append( [ 'TREE_DEPTH', tree_depth(2,3,1)])
+ name_domain.append( [ 'TREE_DEPTH', tree_depth(4,5,1)])
+ name_domain.append( [ 'TUPLE_TEMPLATED_CTOR', templated_ctor_flag(0,1)])
+ #]Define Domains.
   domains=product_dep(
     map(lambda t: t[1], name_domain)
     )
@@ -140,7 +140,7 @@
         " -c "\
         + compiler_flags+" "\
         + compiler_macros+" "\
- + impl_map_inc[macro_vals[0]]+" "\
+ + IMPL_MAP_INC[macro_vals[0]]+" "\
         + src_filename\
         #
       print(TAG_TUPLE.range_out+"[",file=run_fileobj)


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