|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r81053 - sandbox/variadic_templates/sandbox/slim/test
From: cppljevans_at_[hidden]
Date: 2012-10-24 11:20:39
Author: cppljevans
Date: 2012-10-24 11:20:37 EDT (Wed, 24 Oct 2012)
New Revision: 81053
URL: http://svn.boost.org/trac/boost/changeset/81053
Log:
Replace Makefile with nested fors with
python program using crossproduct domain
generator (tuple_benchmark_domain.py).
Also, shorter version of benchmark with
implementation's refactored into .hpp files
( tuple_impl_*.hpp)
Added:
sandbox/variadic_templates/sandbox/slim/test/tuple.benchmark.mini.cpp (contents, props changed)
sandbox/variadic_templates/sandbox/slim/test/tuple_benchmark_domain.py (contents, props changed)
sandbox/variadic_templates/sandbox/slim/test/tuple_benchmark_run.py (contents, props changed)
sandbox/variadic_templates/sandbox/slim/test/tuple_impl_horizontal.hpp (contents, props changed)
sandbox/variadic_templates/sandbox/slim/test/tuple_impl_std.hpp (contents, props changed)
sandbox/variadic_templates/sandbox/slim/test/tuple_impl_vertical.hpp (contents, props changed)
Removed:
sandbox/variadic_templates/sandbox/slim/test/compiler_values.txt
sandbox/variadic_templates/sandbox/slim/test/tuple.benchmark.cpp
sandbox/variadic_templates/sandbox/slim/test/tuple.benchmark.time.clangxx.txt
sandbox/variadic_templates/sandbox/slim/test/tuple.benchmark.time.gcc4_8n.txt
sandbox/variadic_templates/sandbox/slim/test/tuple_test_impl_macros.hpp
Text files modified:
sandbox/variadic_templates/sandbox/slim/test/Makefile | 131 +++++++++++++++++++++++++++++----------
1 files changed, 95 insertions(+), 36 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-10-24 11:20:37 EDT (Wed, 24 Oct 2012)
@@ -1,77 +1,132 @@
MAIN=test
-MAIN=tuple.benchmark
+BENCHMARK=mini
+MAIN=tuple.benchmark.$(BENCHMARK)
+MEASURE=time
+THISFILE=Makefile
+PYTHON=python3.1
DIR.root := $(shell dirup_dir_file.pl $(PWD) root.imk)
+include $(DIR.root)/root.imk
+#include compiler_macros.imk
HOW=gcc4_8n
-HOW=clangxx
+HOW=clangxx_rel
HOWS=gcc4_8n clangxx
-include $(DIR.root)/root.imk
-
SLIM_DIR=../slim/include
-INCS:= -I$(SLIM_DIR) $(INCS)
+#INCS:= -I$(SLIM_DIR) $(INCS)
+
+BFLAGS=-DTUPLE_SIZE=4 -DLAST_LESS=2 -DTUPLE_IMPL=tuple_impl_compstor.hpp -DTUPLE_CHUNK=4
+BFNAME:=$(shell ./flags2filename.pl -S $(BFLAGS))
+PROF_BASE=$(MAIN).$(HOW).$(BFNAME)
+COMPILER.clangxx_ins-rt=$(PATH.llvm.top)/llvm/projects/compiler-rt
+
+.PHONY: bfname
+bfname:
+ ./flags2filename.pl $(BFLAGS)
+
+.PHONY: compiler_help
+compiler_help:
+ #$(COMPILER.$(HOW)) --help-hidden
+ $(COMPILER.$(HOW)) --help|grep -e ' -time\| -print-stat'
+
+compiler.hashes3.out: $(MAIN).cpp
+ $(COMPILE.$(HOW)) -S -### $(BFLAGS) $(MAIN).cpp 2> $@
+
+compiler.hashes3.cmd: compiler.hashes3.out
+ #1) get just the compiler command line (tail -1 compiler.hashes3.out).
+ #2) strip the double quote marks from the command line (s/\"//g).
+ #3) send result to target (>$@)
+ perl -e 'my $$args=join(" ",@ARGV);$$args=~s/\"//g;print $$args' `tail -1 compiler.hashes3`>$@
+
+gmon.out: compiler.hashes3.cmd
+ @echo $<"="
+ @cat $<
+ @echo ""
+ $(SHELL) compiler.hashes3.cmd
+
+gprof.out: gmon.out
+ gprof $(COMPILER.$(HOW)) > gprof.out
+
+.PHONY: mv_gmon_gprof
+mv_gmon_gprof: gprof.out
+ mv gmon.out $(PROF_BASE).gmon.out
+ mv gprof.out $(PROF_BASE).gprof.out
+
+$(PROF_BASE).gprof.out: mv_gmon_gprof
+
+.PHONY: gprof_main
+gprof_main:$(PROF_BASE).gprof.out
+
+.PHONY: gprof2dot
+gprof2dot:
+ gprof2dot.py $(PROF_BASE).gprof.out|dot -Tgif -o $(PROF_BASE).gprof.gif
+
+.PHONY: gdb.commands
+gdb.commands:
+ @echo "#gdb commands:" > $@
+ @echo cd $(PWD) >> $@
+ @echo file $(COMPILER.clangxx_dbg) >> $@
+ @echo set args $(COMPILER.clangxx_dbg.libcxx) -c $(COMPILE.clangxx.flags.all) -c $(MAIN).cpp >> $@
+
+.PHONY: compiler_help_driver
+compiler_help_driver: compiler_help compiler_driver
+
+.PHONY: main.o
+main.o : $(MAIN).cpp
+ $(COMPILE.$(HOW)) -c -std=c++11 $(BFLAGS) $(INCS) $<
.PHONY: tuple.benchmark.report
-tuple.benchmark.report: tuple.benchmark.time.$(HOW)
+tuple.benchmark.report: $(MAIN).$(HOW).$(MEASURE)
echo "DATE:" `date` >$@
- python time-report_tbl.py $(HOW) < $< >> $@
+ $(PYTHON) time-report_tbl.py $(HOW) < $< >> $@
-.PHONY: tuple.benchmark.time.how
-tuple.benchmark.time.how: tuple.benchmark.time.$(HOW)
+.PHONY: tuple.benchmark.measure
+tuple.benchmark.measure: $(MAIN).$(HOW).$(MEASURE).txt
TIME_FORMAT="user:%U\nsystem:%S\nelapsed:%e"
-TUPLE_MAX_SIZE=16
+TUPLE_MAX_SIZE=4
TUPLE_MIN_SIZE=4
TUPLE_DEL_SIZE=4
TUPLE_SIZES=$(TUPLE_MAX_SIZE)
+TUPLE_IMPLS=\
+ tuple_impl_horizontal.hpp\
+ tuple_impl_vertical.hpp\
+ #
-tuple.benchmark.time.$(HOW).txt: tuple.benchmark.cpp
+.PHONY: $(MAIN).$(HOW).$(MEASURE).txt
+$(MAIN).$(HOW).$(MEASURE).txt: $(MAIN).cpp
-rm $@
- echo -n "COMPILER_VERSION:" >>$@ ; \
+ echo -n "COMPILER:" >>$@ ; \
echo $(HOW) >>$@ ; \
for VALU_AT in -DVALU_AT ; do \
echo "VALU_AT:"$$VALU_AT >>$@ ; \
- for TUPLE_TEST_IMPL in 0 1 ; do \
- echo "TUPLE_TEST_IMPL:"$$TUPLE_TEST_IMPL >>$@ ; \
+ for TUPLE_IMPL in $(TUPLE_IMPLS) ; do \
+ echo "TUPLE_IMPL:"$$TUPLE_IMPL >>$@ ; \
for TUPLE_SIZE in $(TUPLE_SIZES) ; do \
echo "TUPLE_SIZE:"$$TUPLE_SIZE >>$@ ; \
for LAST_LESS in `python ./first_to_last_ints.py $(TUPLE_MIN_SIZE) $(TUPLE_DEL_SIZE) $$TUPLE_SIZE ` ; do \
echo "LAST_LESS:"$$LAST_LESS >>$@ ; \
- time --format $(TIME_FORMAT) $(COMPILE.$(HOW)) \
+ $(MEASURE) --format $(TIME_FORMAT) $(COMPILE.$(HOW)) \
$(INCS) \
- -DTUPLE_TEST_IMPL=$$TUPLE_TEST_IMPL \
+ -DTUPLE_IMPL=$$TUPLE_IMPL \
-DTUPLE_SIZE=$$TUPLE_SIZE \
-DLAST_LESS=$$LAST_LESS \
- $$VALU_AT tuple.benchmark.cpp 2>>$@ ; \
+ $$VALU_AT \
+ $(MAIN).cpp 2>>$@ ; \
done \
done \
done \
done \
#
-.PHONY: tuple.benchmark.time
-tuple.benchmark.time:
+.PHONY: tuple.benchmark.$(MEASURE)
+tuple.benchmark.$(MEASURE):
for COMPILE_HOW in $(HOWS) ; do \
- make -Wtuple.benchmark.cpp HOW=$$COMPILE_HOW tuple.benchmark.time.$$COMPILE_HOW ; \
+ make -W$(MAIN).cpp HOW=$$COMPILE_HOW $(MAIN).$$COMPILE_HOW.$(MEASURE).txt ; \
done
-.PHONY: compiler_value.txt
-compiler_value.txt:
- echo $(HOW)":" >>compiler_values.txt
- echo -n " * version=" >>compiler_values.txt
- $(COMPILE.$(HOW)) --version >>compiler_values.txt
- echo " * command="$(COMPILE.$(HOW)) >>compiler_values.txt
-
-.PHONY: compiler_values.txt
-compiler_values.txt:
- echo "INCS:"$(INCS) >$@
- for COMPILE_HOW in $(HOWS) ; do \
- make compiler_value.txt HOW=$$COMPILE_HOW ; \
- done \
- #
-
.PHONY: nest_loop
nest_loop:
for TUPLE_SIZE in $(TUPLE_SIZES) ; do \
@@ -84,4 +139,8 @@
.PHONY: echo
echo:
- echo $(COMPILE)
+ @echo "SHELL="$(SHELL)
+
+.PHONY: python
+python:
+ $(PYTHON) tuple_benchmark_run.py
Deleted: sandbox/variadic_templates/sandbox/slim/test/compiler_values.txt
==============================================================================
--- sandbox/variadic_templates/sandbox/slim/test/compiler_values.txt 2012-10-24 11:20:37 EDT (Wed, 24 Oct 2012)
+++ (empty file)
@@ -1,13 +0,0 @@
-INCS:-I../slim/include -I/home/evansl/prog_dev/boost-svn/ro/boost_1_49_0
-gcc4_8n:
- * version=g++ (GCC) 4.8.0 20120624 (experimental)
-Copyright (C) 2012 Free Software Foundation, Inc.
-This is free software; see the source for copying conditions. There is NO
-warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-
- * command=/home/evansl/download/gcc/4.8-20120624/install/bin/g++ -c -Wall -Wstrict-overflow -ftemplate-depth-300 -ftemplate-backtrace-limit=0 -std=gnu++11
-clangxx:
- * version=clang version 3.1 (trunk 150294)
-Target: x86_64-unknown-linux-gnu
-Thread model: posix
- * command=/home/evansl/download/llvm/svn/build/Debug+Asserts/bin/clang -c -cxx-isystem /home/evansl/download/llvm/svn/llvm/projects/libcxx/include -std=c++11
Deleted: sandbox/variadic_templates/sandbox/slim/test/tuple.benchmark.cpp
==============================================================================
--- sandbox/variadic_templates/sandbox/slim/test/tuple.benchmark.cpp 2012-10-24 11:20:37 EDT (Wed, 24 Oct 2012)
+++ (empty file)
@@ -1,212 +0,0 @@
-#include "tuple_test_impl_macros.hpp"
-
-#if !defined(TUPLE_SIZE)
- //This only used when not running several benchmarks where
- //macro values are set on command line with -DMACRO=VALUE.
- //See tuple.benchmark.mk.
- #define TUPLE_TEST_IMPL TUPLE_TEST_HORIZONTAL
- //TUPLE_TEST_IMPL selects the tuple implementation method.
- //TUPLE_TEST_VERTICAL selects the preprocessor generated
- // tuples.
- //TUPLE_TEST_HORIZONTAL selects the variadic template generated
- // tuples (using a multiple inheritance method similar to
- // that mentioned here:
- // https://groups.google.com/forum/?fromgroups=#!msg/comp.std.c++/_-6X_xZlKlA/3Fw9_QnZSWQJ
- // with subject:
- // Variadic Templates in C++0x need some additional features to come closer to fulfilling their promise
- // and date:
- // 01/12/2009
- // )
- #define TUPLE_SIZE 4
- //^size of the tuple used.
- //Also, the number of at_test calls in test_row<I,J>::exec.
- #define LAST_LESS 2
- //^determines number of instantiations of test_col and test_row.
- #define VALU_AT
- //^Decides whether value of tuple elements is retrieved
- //or some dummy value is used
- //in test_row<I,J>::at_test.
- //#define TRACE_BENCHMARK
- #ifdef TRACE_BENCHMARK
- #define USE_DEMANGLER
- #ifdef USE_DEMANGLER
- #include <boost/utility/demangled_type_name.hpp>
- #endif
- #endif
-#endif
- //#define VERT_AMORT
- //Purpose:
- // Account for the amortized cost of
- // amortized::make_indexes
- //Use something less than TUPLE_SIZE as LAST_LESS
- //if compile times become too large.
-#define LAST_RC ((LAST_LESS>TUPLE_SIZE)?TUPLE_SIZE:LAST_LESS)
-#define LAST_ROW LAST_RC
-#define LAST_COL LAST_RC
- //test_row<I,J>::exec for I=0...LAST_ROW-1, for J=0...LAST_COL-1
- //is called.
-
-/*=============================================================================
- Copyright (c) 2009 Christopher Schmidt
-
- Distributed under the Boost Software License, Version 1.0. (See accompanying
- file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
-==============================================================================*/
-
-//OriginalVersion:
-// On 2009-09-27, downloaded from attachment to:
-// http://article.gmane.org/gmane.comp.lib.boost.devel/194407
-//Purpose:
-// Timing benchmark for 2 methods of tuple implmentation.
-// The method used is dependent on macro, TUPLE_TEST_IMPL:
-// when TUPLE_TEST_IMPL == TUPLE_TEST_VERTICAL:
-// This method uses the boost preprocessor to generate
-// member variables for the tuple elements:
-// HI tI;
-// where I=0...N-1, where N is the size of the tuple.
-// when TUPLE_TEST_IMPL == TUPLE_TEST_HORIZONTAL:
-// This method uses multiple inheritance of the
-// tuple elements "paired" with a key in a
-// superclass:
-// element<int_key<I>,HI>
-// where I is as for the 'TUPLE_TEST_IMPL == TUPLE_TEST_VERTICAL' method and
-// where the member variable is:
-// HI element<int_key<I>,HI>::a;
-//
-
-#if TUPLE_TEST_IMPL == TUPLE_TEST_HORIZONTAL
- #define SLIM_TAGGED_VECTOR
-#else
-#endif
-
-//#include <slim/container/vector/detail/pp/vector_n.hpp>
-#include <slim/container/vector.hpp>
-
-template<int Value>
-struct int_value //values stored in tuple
-{
- int_value(void)
- : value(Value)
- {}
- int const value;
-};
-
-template<int I,int J, int Max, typename... Args>
-struct make_tuple:
- make_tuple<I,J,Max-1,int_value<I*TUPLE_SIZE*TUPLE_SIZE+J*TUPLE_SIZE+Max>,Args...>
-{};
-template<int I,int J, typename... Args>
-struct make_tuple<I,J,0, Args...>
-{
- typedef slim::vector<Args...> type;
-};
-
-#include <iostream>
-
-template<int I,int J=0>
-struct test_row
-{
- private:
- typedef typename make_tuple<I, J, TUPLE_SIZE>::type tuple_type;
-
- template<int K>
- static int at_test(tuple_type& t,boost::mpl::int_<K> key)
- {
- int const value=
-#ifdef VALU_AT
- #if TUPLE_TEST_IMPL == TUPLE_TEST_HORIZONTAL
- slim::detail::at_helper<K>(t)
- #else
- t.at_impl(key)
- #endif
- .value
-#else
- K
-#endif
- ;
- #ifdef TRACE_BENCHMARK
- std::cout<<"at_test:K="<<K<<"\n";
- #endif
- return value+at_test(t,boost::mpl::int_<K+1>());
- }
- static int at_test(tuple_type&,boost::mpl::int_<TUPLE_SIZE>)
- {
- #ifdef TRACE_BENCHMARK
- std::cout<<"at_test:TUPLE_SIZE="<<TUPLE_SIZE<<"\n";
- #endif
- return 0;
- }
- public:
- static int exec()
- {
- #ifdef TRACE_BENCHMARK
- std::cout<<"test_row<I="<<I<<",J="<<J<<">:\n";
- #ifdef USE_DEMANGLER
- std::cout<<"tuple_type="<<utility::demangled_type_name<tuple_type>()<<"\n";
- #endif
- #endif
- tuple_type t;
- int const value=at_test(t,boost::mpl::int_<0>());
- //The combination of the above at_test specialized function
- //and the at_test general function means the above call
- //actually calls:
- // at_test'<K>
- //for k=0...J%TUPLE_SIZE-1
- //where at_test' is just at_test without the
- //recursive call to at_test<K+1>(...).
- return value+test_row<I,J+1>::exec();
- }
-};
-template<int I>
-struct test_row<I,LAST_ROW>
-{
- static int exec()
- {
- return 0;
- }
-};
-
-//The combination of the above test_row special and the preceding general
-//templates means the call:
-// test_row<I>::exec()
-//executes:
-// test_row<I,J>::exec'()
-//for J=0...LAST_ROW
-//where exec' is exec without the recursive call to test_row<I,J+1>::exec().
-
-template<int I=0>
-struct test_col
-{
- static int exec()
- {
- int const value=test_row<I>::exec();
- return value+test_col<I+1>::exec();
- }
-};
-
-template<>
-struct test_col<LAST_COL>
-{
- static int exec()
- {
- return 0;
- }
-};
-
-int main()
-{
- std::cout<<"TUPLE_SIZE="<<TUPLE_SIZE<<"\n";
- std::cout<<"LAST_ROW="<<LAST_ROW<<"\n";
- int const value=test_col<>::exec();
- //The combination of the test_col general and special templates
- //means the above call executes:
- // test_row<I>::exec()
- //for I=0...LAST_COL
- std::cout<<"value="<<value<<"\n";
- #if defined(BOOST_NO_VARIADIC_TEMPLATES)
- std::cout<<"BOOST_NOT_VARIADIC_TEMPLATES\n";
- #else
- std::cout<<"BOOST_YES_VARIADIC_TEMPLATES\n";
- #endif
- return value==0;
-}
Added: sandbox/variadic_templates/sandbox/slim/test/tuple.benchmark.mini.cpp
==============================================================================
--- (empty file)
+++ sandbox/variadic_templates/sandbox/slim/test/tuple.benchmark.mini.cpp 2012-10-24 11:20:37 EDT (Wed, 24 Oct 2012)
@@ -0,0 +1,162 @@
+#include "macros.benchmark.pp.hpp"
+#include <boost/preprocessor/stringize.hpp>
+/*=============================================================================
+ Copyright (c) 2009 Christopher Schmidt
+
+ Distributed under the Boost Software License, Version 1.0. (See accompanying
+ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+==============================================================================*/
+
+//OriginalVersion:
+// On 2009-09-27, downloaded from attachment to:
+// http://article.gmane.org/gmane.comp.lib.boost.devel/194407
+//Purpose:
+// Timing benchmark for 2 methods of tuple implmentation.
+// The method used is dependent on macro, TUPLE_TEST_IMPL:
+// when TUPLE_TEST_IMPL == TUPLE_TEST_VERTICAL:
+// This method uses the boost preprocessor to generate
+// member variables for the tuple elements:
+// HI tI;
+// where I=0...N-1, where N is the size of the tuple.
+// when TUPLE_TEST_IMPL == TUPLE_TEST_HORIZONTAL:
+// This method uses multiple inheritance of the
+// tuple elements "paired" with a key in a
+// superclass:
+// element<int_key<I>,HI>
+// where I is as for the 'TUPLE_TEST_IMPL == TUPLE_TEST_VERTICAL' method and
+// where the member variable is:
+// HI element<int_key<I>,HI>::a;
+//
+
+template<int Index>
+struct int_key //key's (or indices) to values stored in tuple.
+{
+};
+
+#include BOOST_PP_STRINGIZE(TUPLE_IMPL)
+
+template<int Value>
+struct int_value //values stored in tuple
+{
+ int_value(void)
+ : value(Value)
+ {}
+ int const value;
+};
+
+template<int I,int J, int Max, typename... Args>
+struct make_tuple:
+ make_tuple<I,J,Max-1,int_value<I*TUPLE_SIZE*TUPLE_SIZE+J*TUPLE_SIZE+Max>,Args...>
+{};
+template<int I,int J, typename... Args>
+struct make_tuple<I,J,0, Args...>
+{
+ typedef tuple_bench<Args...> type;
+};
+
+//#define TRACE_MAIN
+#if defined(TRACE_BENCHMARK)||defined(TRACE_MAIN)
+ #include <iostream>
+#endif
+
+template<int I,int J=0>
+struct test_row
+{
+ private:
+ typedef typename make_tuple<I, J, TUPLE_SIZE>::type tuple_type;
+
+ template<int K>
+ static int at_test(tuple_type& t,int_key<K>)
+ {
+ int const value=
+#ifdef VALU_AT
+ get<K>(t).value
+#else
+ K
+#endif
+ ;
+ #ifdef TRACE_BENCHMARK
+ std::cout<<"at_test:K="<<K<<"\n";
+ #endif
+ return value+at_test(t,int_key<K+1>());
+ }
+ static int at_test(tuple_type&,int_key<TUPLE_SIZE>)
+ {
+ #ifdef TRACE_BENCHMARK
+ std::cout<<"at_test:TUPLE_SIZE="<<TUPLE_SIZE<<"\n";
+ #endif
+ return 0;
+ }
+ public:
+ static int exec()
+ {
+ #ifdef TRACE_BENCHMARK
+ std::cout<<"test_row<I="<<I<<",J="<<J<<">:\n";
+ std::cout<<"tuple_type="<<utility::demangled_type_name<tuple_type>()<<"\n";
+ #endif
+ tuple_type t;
+ int const value=at_test(t,int_key<0>());
+ //The combination of the above at_test specialized function
+ //and the at_test general function means the above call
+ //actually calls:
+ // at_test'<K>
+ //for k=0...J%TUPLE_SIZE-1
+ //where at_test' is just at_test without the
+ //recursive call to at_test<K+1>(...).
+ return value+test_row<I,J+1>::exec();
+ }
+};
+template<int I>
+struct test_row<I,LAST_ROW>
+{
+ static int exec()
+ {
+ return 0;
+ }
+};
+
+//The combination of the above test_row special and the preceding general
+//templates means the call:
+// test_row<I>::exec()
+//executes:
+// test_row<I,J>::exec'()
+//for J=0...LAST_ROW
+//where exec' is exec without the recursive call to test_row<I,J+1>::exec().
+
+template<int I=0>
+struct test_col
+{
+ static int exec()
+ {
+ int const value=test_row<I>::exec();
+ return value+test_col<I+1>::exec();
+ }
+};
+
+template<>
+struct test_col<LAST_COL>
+{
+ static int exec()
+ {
+ return 0;
+ }
+};
+
+int main()
+{
+
+ #ifdef TRACE_MAIN
+ std::cout<<"TUPLE_TEST_IMPL="<<TUPLE_TEST_IMPL<<"\n";
+ std::cout<<"TUPLE_SIZE="<<TUPLE_SIZE<<"\n";
+ std::cout<<"LAST_ROW="<<LAST_ROW<<"\n";
+ #endif
+ int const value=test_col<>::exec();
+ //The combination of the test_col general and special templates
+ //means the above call executes:
+ // test_row<I>::exec()
+ //for I=0...LAST_COL
+ #ifdef TRACE_MAIN
+ std::cout<<"value="<<value<<"\n";
+ #endif
+ return value==0;
+}
Deleted: sandbox/variadic_templates/sandbox/slim/test/tuple.benchmark.time.clangxx.txt
==============================================================================
--- sandbox/variadic_templates/sandbox/slim/test/tuple.benchmark.time.clangxx.txt 2012-10-24 11:20:37 EDT (Wed, 24 Oct 2012)
+++ (empty file)
@@ -1,38 +0,0 @@
-COMPILER_VERSION:clangxx
-VALU_AT:-DVALU_AT
-TUPLE_TEST_IMPL:0
-TUPLE_SIZE:16
-LAST_LESS:4
-user:19.56
-system:0.29
-elapsed:20.19
-LAST_LESS:8
-user:37.36
-system:0.64
-elapsed:37.99
-LAST_LESS:12
-user:67.29
-system:0.63
-elapsed:67.90
-LAST_LESS:16
-user:109.71
-system:1.35
-elapsed:111.07
-TUPLE_TEST_IMPL:1
-TUPLE_SIZE:16
-LAST_LESS:4
-user:19.84
-system:0.21
-elapsed:20.03
-LAST_LESS:8
-user:37.53
-system:0.39
-elapsed:37.90
-LAST_LESS:12
-user:67.42
-system:0.95
-elapsed:68.36
-LAST_LESS:16
-user:109.79
-system:0.82
-elapsed:110.60
Deleted: sandbox/variadic_templates/sandbox/slim/test/tuple.benchmark.time.gcc4_8n.txt
==============================================================================
--- sandbox/variadic_templates/sandbox/slim/test/tuple.benchmark.time.gcc4_8n.txt 2012-10-24 11:20:37 EDT (Wed, 24 Oct 2012)
+++ (empty file)
@@ -1,38 +0,0 @@
-COMPILER_VERSION:gcc4_8n
-VALU_AT:-DVALU_AT
-TUPLE_TEST_IMPL:0
-TUPLE_SIZE:16
-LAST_LESS:4
-user:5.01
-system:0.30
-elapsed:5.30
-LAST_LESS:8
-user:18.52
-system:0.77
-elapsed:19.30
-LAST_LESS:12
-user:73.32
-system:1.31
-elapsed:74.63
-LAST_LESS:16
-user:293.12
-system:3.09
-elapsed:296.24
-TUPLE_TEST_IMPL:1
-TUPLE_SIZE:16
-LAST_LESS:4
-user:4.50
-system:0.33
-elapsed:4.81
-LAST_LESS:8
-user:12.78
-system:0.59
-elapsed:13.35
-LAST_LESS:12
-user:32.84
-system:1.13
-elapsed:33.96
-LAST_LESS:16
-user:70.90
-system:1.86
-elapsed:72.75
Added: sandbox/variadic_templates/sandbox/slim/test/tuple_benchmark_domain.py
==============================================================================
--- (empty file)
+++ sandbox/variadic_templates/sandbox/slim/test/tuple_benchmark_domain.py 2012-10-24 11:20:37 EDT (Wed, 24 Oct 2012)
@@ -0,0 +1,72 @@
+#Purpose:
+# Provide classes for defining the "domain"
+# of the tuple benchmark. A domain is all
+# the various inputs to the benchmark.
+# For example:
+# 1) the particular compilers used to compiler the benchmark.
+# 2) the values of various macros used in the source code.
+#
+from product_dep import product_dep
+
+class compilers(object):
+ def __init__(self, names):
+ self.names=names
+ def __call__(self,xs):
+ return self.names
+
+class impls(object):
+ "tuple implementations"
+ def __init__(self, names):
+ self.names=names
+ def __call__(self,xs):
+ return self.names
+
+class sizes(object):
+ "TUPLE_SIZE macro values"
+ def __init__(self, tuple_sizes):
+ self.sizes=tuple_sizes
+ def __call__(self,xs):
+ return self.sizes
+
+class last(object):
+ "LAST_LESS macro values"
+ def __init__(self, size_start, size_step=1):
+ self.start=size_start
+ self.step=size_step
+ def __call__(self,xs):
+ return range(
+ self.start
+ , self.start+1#xs[2]+1 #xs[2] is current tuple_size
+ , self.step
+ )
+
+class chunk(object):
+ "TUPLE_CHUNK macro values(only used with vertical impl)"
+ def __init__(self, size_start=2, size_step=4):
+ self.start=size_start
+ self.step=size_step
+ def __call__(self,xs):
+ if xs[1] == 'vertical':
+ if False:
+ return range(
+ xs[2]#self.start
+ , xs[2]+1+self.step #xs[2] is current tuple_size
+ , self.step
+ )
+ else:
+ return [10]
+ return [-1]
+
+if __name__ == '__main__':
+ tuple_max_size=8
+ tuple_min_size=4
+ tuple_del_size=2
+ domain=product_dep(
+ [ compilers(["compiler1","compiler2"])
+ , impls(["impl1","vertical"])
+ , sizes(range(tuple_min_size,tuple_max_size+1,tuple_del_size))
+ , last(tuple_min_size,tuple_del_size)
+ , chunk()
+ ])
+ for element in domain():
+ print(element)
Added: sandbox/variadic_templates/sandbox/slim/test/tuple_benchmark_run.py
==============================================================================
--- (empty file)
+++ sandbox/variadic_templates/sandbox/slim/test/tuple_benchmark_run.py 2012-10-24 11:20:37 EDT (Wed, 24 Oct 2012)
@@ -0,0 +1,113 @@
+#!/usr/bin/python3.1
+from tuple_benchmark_domain import *
+import subprocess
+import collections
+
+def measure_time(compiler_exe, compiler_args, measure_out):
+ compile_cmd=compiler_exe+compiler_args
+ time_format='"user:%U system:%S elapsed:%e"'
+ measure_cmd='time --format '+time_format+' '+compile_cmd
+ print(":measure_cmd=",measure_cmd)
+ rc=subprocess.call(
+ measure_cmd
+ , shell=True
+ , stdout=measure_out
+ , stderr=subprocess.STDOUT
+ )
+ print(":rc=",rc)
+
+def measure_ftime(compiler_exe, compiler_args, measure_out):
+ measure_cmd=compiler_exe+" -ftime-report "+compiler_args
+ print(":measure_cmd=",measure_cmd)
+ rc=subprocess.call(
+ measure_cmd
+ , shell=True
+ , stdout=measure_out
+ , stderr=subprocess.STDOUT
+ )
+ print(":rc=",rc)
+
+if __name__ == '__main__':
+ tuple_min_size=10
+ tuple_max_size=20
+ tuple_del_size=10
+ compiler_map={}
+ if False:
+ compiler_map["gcc4_8"]=(
+ "/home/evansl/download/gcc/4.8-20120923/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"
+ )
+ impl_map_hpp={}#implementation key -> implementation include .hpp file.
+ impl_map_inc=collections.defaultdict(lambda:"")#implementation key -> -I include flags to compiler
+ impl_map_hpp["horizontal"]="tuple_impl_horizontal.hpp"
+ impl_map_hpp["vertical" ]="tuple_impl_vertical.hpp"
+ impl_map_hpp["std" ]="tuple_impl_std.hpp"
+ #impl_map_hpp["compstor" ]="tuple_impl_compstor.hpp"
+ boost_root="/home/evansl/prog_dev/boost-svn/ro/boost_1_49_0"
+ impl_map_inc["compstor" ]=\
+ " -I"+boost_root\
+ + " -I"+boost_root+"/sandbox/rw/variadic_templates"\
+ #
+ name_domain=[
+ [ 'compiler', compilers(compiler_map.keys())]
+ , [ 'TUPLE_IMPL', impls(impl_map_hpp.keys())]
+ , [ 'TUPLE_SIZE', sizes(range(tuple_min_size,tuple_max_size+1,tuple_del_size))]
+ , [ 'LAST_LESS', last(4,tuple_del_size)]
+ , [ 'TUPLE_CHUNK', chunk()]
+ ]
+ domain=product_dep(
+ map(lambda t: t[1], name_domain)
+ )
+ measures={
+ 'time' : measure_time
+ , 'ftime' : measure_ftime
+ }
+ measure_key='time'
+ benchmark="tuple.benchmark.mini"
+ measure_out=open(benchmark+"."+measure_key+".txt",mode='w')
+ for compiler_name in compiler_map.keys():
+ (compiler_exe,compiler_flags)=compiler_map[compiler_name]
+ print("compiler=",compiler_name,file=measure_out)
+ print("version={",file=measure_out)
+ measure_out.flush()
+ rc=subprocess.call(
+ compiler_exe+" -v"
+ , shell=True
+ , stdout=measure_out
+ , stderr=subprocess.STDOUT
+ )
+ if compiler_name == 'clangxx':
+ print("compiler_exe=",compiler_exe,file=measure_out)
+ print("}",file=measure_out)
+ print(list(map(lambda t: t[0], name_domain)),file=measure_out)
+ for element in domain():
+ print(element,file=measure_out)
+ (compiler_name, impl_name, size, last, chk)=element
+ #print(":compiler_name=",compiler_name,":impl_name=",impl_name,":size=",size,":last=",last)
+ compiler_macros=\
+ " -DTUPLE_IMPL="+impl_map_hpp[impl_name]\
+ + " -DTUPLE_SIZE="+str(size)\
+ + " -DLAST_LESS="+str(last)\
+ + " -DTUPLE_CHUNK="+str(chk)
+ #print(":compiler_macros=",compiler_macros)
+ (compiler_exe,compiler_flags)=compiler_map[compiler_name]
+ #print(":compiler_exe=",compiler_exe,":compiler_flags=",compiler_flags)
+ compiler_args=\
+ " -c "\
+ + compiler_flags+" "\
+ + compiler_macros+" "\
+ + impl_map_inc[impl_name]+" "\
+ + benchmark+".cpp"\
+ #
+ print("{",file=measure_out)
+ measure_out.flush()
+ measures[measure_key](compiler_exe, compiler_args, measure_out)
+ print("}",file=measure_out)
+
+
+
Added: sandbox/variadic_templates/sandbox/slim/test/tuple_impl_horizontal.hpp
==============================================================================
--- (empty file)
+++ sandbox/variadic_templates/sandbox/slim/test/tuple_impl_horizontal.hpp 2012-10-24 11:20:37 EDT (Wed, 24 Oct 2012)
@@ -0,0 +1,32 @@
+#ifndef TUPLE_IMPL_HORIZONTAL_INCLUDE_HPP
+#define TUPLE_IMPL_HORIZONTAL_INCLUDE_HPP
+#include "make_indexes.hpp"
+ template<typename Key, typename Value>
+ struct element
+ ;
+ template<int Key, typename Value>
+ struct element<int_key<Key>,Value>
+ {
+ Value value;
+ };
+ template<typename Keys, typename... Args>
+ struct tuple_impl
+ ;
+ template<int... Indices, typename... Args>
+ struct tuple_impl<int_indexes<Indices...>, Args...>
+ : element<int_key<Indices>, Args>...
+ {};
+
+ template<typename... Args>
+ struct tuple_bench
+ : tuple_impl<typename make_indexes<sizeof...(Args)>::type, Args...>
+ {
+ };
+
+ template<int Key, typename Value>
+ Value&
+ get(element<int_key<Key>,Value>& key_val)
+ {
+ return key_val.value;
+ }
+#endif//TUPLE_IMPL_HORIZONTAL_INCLUDE_HPP
Added: sandbox/variadic_templates/sandbox/slim/test/tuple_impl_std.hpp
==============================================================================
--- (empty file)
+++ sandbox/variadic_templates/sandbox/slim/test/tuple_impl_std.hpp 2012-10-24 11:20:37 EDT (Wed, 24 Oct 2012)
@@ -0,0 +1,4 @@
+#include <tuple>
+template<typename... T>
+using tuple_bench = std::tuple<T...>;
+
Added: sandbox/variadic_templates/sandbox/slim/test/tuple_impl_vertical.hpp
==============================================================================
--- (empty file)
+++ sandbox/variadic_templates/sandbox/slim/test/tuple_impl_vertical.hpp 2012-10-24 11:20:37 EDT (Wed, 24 Oct 2012)
@@ -0,0 +1,81 @@
+#ifndef TUPLE_IMPL_VERTICAL_INCLUDE_HPP
+#define TUPLE_IMPL_VERTICAL_INCLUDE_HPP
+ template<int Index,typename... Args>
+ struct tuple_impl;
+ template<int Index>
+ struct tuple_impl<Index>
+ {
+ void at_value(){}
+ };
+
+#if !defined(TUPLE_CHUNK)
+ #define TUPLE_CHUNK 10
+#endif
+#include <boost/preprocessor/repetition/enum_params.hpp>
+#include <boost/preprocessor/repetition/repeat_from_to.hpp>
+#define TUPLE_IMPL_TYPE_NAME H
+#define TUPLE_IMPL_MEMB_NAME h
+#define TUPLE_IMPL_MEMBER(z_IGNORE,MEMB_NUMB,data_IGNORE)\
+ BOOST_PP_CAT(TUPLE_IMPL_TYPE_NAME,MEMB_NUMB)\
+ BOOST_PP_CAT(TUPLE_IMPL_MEMB_NAME,MEMB_NUMB)\
+ ;\
+ BOOST_PP_CAT(TUPLE_IMPL_TYPE_NAME,MEMB_NUMB)&\
+ at_value\
+ ( int_key<Index+MEMB_NUMB>\
+ )\
+ {\
+ return BOOST_PP_CAT(TUPLE_IMPL_MEMB_NAME,MEMB_NUMB);\
+ }\
+ /**/
+
+#define TUPLE_IMPL_STRUCT_TAIL(z_IGNORE, ARITY, data_IGNORE) \
+ template<int Index, BOOST_PP_ENUM_PARAMS(ARITY, typename TUPLE_IMPL_TYPE_NAME)> \
+ struct tuple_impl<Index, BOOST_PP_ENUM_PARAMS(ARITY, TUPLE_IMPL_TYPE_NAME)> \
+ { \
+ BOOST_PP_REPEAT(ARITY,TUPLE_IMPL_MEMBER,~) \
+ }; \
+ /**/
+
+ BOOST_PP_REPEAT_FROM_TO(1,TUPLE_CHUNK,TUPLE_IMPL_STRUCT_TAIL,~)
+
+ template<int Index, BOOST_PP_ENUM_PARAMS(TUPLE_CHUNK, typename TUPLE_IMPL_TYPE_NAME), typename... Others>
+ struct tuple_impl<Index, BOOST_PP_ENUM_PARAMS(TUPLE_CHUNK, TUPLE_IMPL_TYPE_NAME), Others...>
+ : tuple_impl<Index+TUPLE_CHUNK, Others...>
+ {
+ typedef tuple_impl<Index+TUPLE_CHUNK,Others...> base;
+ using base::at_value;
+
+ BOOST_PP_REPEAT(TUPLE_CHUNK,TUPLE_IMPL_MEMBER,~)
+ };
+
+#undef TUPLE_IMPL_TYPE_NAME
+#undef TUPLE_IMPL_MEMB_NAME
+#undef TUPLE_IMPL_MEMBER
+#undef TUPLE_IMPL_STRUCT_TAIL
+
+#ifdef VERT_AMORT
+ #include "make_indexes.hpp"
+#endif
+
+ template<typename... Args>
+ struct tuple_bench
+ : tuple_impl<0,Args...>
+#ifdef VERT_AMORT
+ , make_indexes<sizeof...(Args)>::type
+ //This is actually useless for the purpose of VERTICAL tuple.
+ //The real purpose is to cause this VERTICAL tuple to incur
+ //the same make_indexes overhead as the HORIZONTAL tuple.
+ //The justification for this is that the cost of
+ //make_indexes should be amortized over the *assumed*
+ //many instances of the same make_indexes used in all
+ //HORIZONTAL tuples with same size.
+#endif
+ {};
+
+ template< int Index, typename Tuple>
+ auto
+ get(Tuple& tuple) -> decltype(tuple.at_value(int_key<Index>()))
+ {
+ return tuple.at_value(int_key<Index>());
+ }
+#endif//TUPLE_IMPL_VERTICAL_INCLUDE_HPP
Deleted: sandbox/variadic_templates/sandbox/slim/test/tuple_test_impl_macros.hpp
==============================================================================
--- sandbox/variadic_templates/sandbox/slim/test/tuple_test_impl_macros.hpp 2012-10-24 11:20:37 EDT (Wed, 24 Oct 2012)
+++ (empty file)
@@ -1,7 +0,0 @@
-#ifndef TUPLE_TEST_IMPL_MACROS_HPP_INCLUDED
-#define TUPLE_TEST_IMPL_MACROS_HPP_INCLUDED
-//Purpose:
-// Define PP macros used to number tuple implementations.
-#define TUPLE_TEST_HORIZONTAL 0
-#define TUPLE_TEST_VERTICAL (TUPLE_TEST_HORIZONTAL+1)
-#endif
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