|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r51595 - sandbox/reference_closure
From: dave_at_[hidden]
Date: 2009-03-03 22:38:06
Author: dave
Date: 2009-03-03 22:38:05 EST (Tue, 03 Mar 2009)
New Revision: 51595
URL: http://svn.boost.org/trac/boost/changeset/51595
Log:
Separate TU for parallel library to eliminate the possibility of constant folding on function pointers
Added:
sandbox/reference_closure/main.cc (contents, props changed)
sandbox/reference_closure/parallel_lib.cc (contents, props changed)
Removed:
sandbox/reference_closure/trivial_function.cc
sandbox/reference_closure/trivial_main.h
sandbox/reference_closure/trivial_nested.cc
Text files modified:
sandbox/reference_closure/benchmark.sh | 22 ++++++++++++++--------
sandbox/reference_closure/timings.txt | 14 ++++++++++++++
sandbox/reference_closure/trivial_closure.h | 7 ++++++-
sandbox/reference_closure/trivial_initiator.h | 3 +++
4 files changed, 37 insertions(+), 9 deletions(-)
Modified: sandbox/reference_closure/benchmark.sh
==============================================================================
--- sandbox/reference_closure/benchmark.sh (original)
+++ sandbox/reference_closure/benchmark.sh 2009-03-03 22:38:05 EST (Tue, 03 Mar 2009)
@@ -2,16 +2,22 @@
set -e
CC=g++
-echo compile trivial_nested
-$CC -O2 -DREFERENCE_CLOSURE trivial_nested.cc -o trivial_nested
-echo compile trivial_function
-$CC -O2 -DSTD_FUNCTION trivial_function.cc -o trivial_function
+set -x
+$CC -O2 -DREFERENCE_CLOSURE parallel_lib.cc -c -o parallel_lib_refclosure.o
+$CC -O2 -DREFERENCE_CLOSURE main.cc -c -o main_refclosure.o
+$CC main_refclosure.o parallel_lib_refclosure.o -o refclosure
+
+$CC -O2 -DSTD_FUNCTION parallel_lib.cc -c -o parallel_lib_stdfunction.o
+$CC -O2 -DSTD_FUNCTION main.cc -c -o main_stdfunction.o
+$CC main_stdfunction.o parallel_lib_stdfunction.o -o stdfunction
+
+set +x
echo
-echo -n execute trivial_nested
-time ./trivial_nested
+echo -n execute refclosure
+time ./refclosure
echo
-echo -n execute trivial_function
-time ./trivial_function
+echo -n execute stdfunction
+time ./stdfunction
Added: sandbox/reference_closure/main.cc
==============================================================================
--- (empty file)
+++ sandbox/reference_closure/main.cc 2009-03-03 22:38:05 EST (Tue, 03 Mar 2009)
@@ -0,0 +1,7 @@
+#include "trivial_initiator.h"
+
+int main() {
+ for ( int i = 0; i < 1000*1000*100; i++ )
+ initiator();
+ return 0;
+}
Added: sandbox/reference_closure/parallel_lib.cc
==============================================================================
--- (empty file)
+++ sandbox/reference_closure/parallel_lib.cc 2009-03-03 22:38:05 EST (Tue, 03 Mar 2009)
@@ -0,0 +1,4 @@
+#include "callback_type.h"
+
+void executer( callback_type arg ) { arg(); }
+void passer( callback_type arg ) { executer( arg ); }
Modified: sandbox/reference_closure/timings.txt
==============================================================================
--- sandbox/reference_closure/timings.txt (original)
+++ sandbox/reference_closure/timings.txt 2009-03-03 22:38:05 EST (Tue, 03 Mar 2009)
@@ -40,3 +40,17 @@
t(std::function<>) / t(reference_closure): 4.1
+=== Separate Translation Unit for Parallel Lib ===
+
+execute refclosure
+real 0m1.267s
+user 0m1.243s
+sys 0m0.005s
+
+execute stdfunction
+real 0m5.153s
+user 0m5.103s
+sys 0m0.014s
+
+t(std::function<>) / t(reference_closure): 4.1
+
Modified: sandbox/reference_closure/trivial_closure.h
==============================================================================
--- sandbox/reference_closure/trivial_closure.h (original)
+++ sandbox/reference_closure/trivial_closure.h 2009-03-03 22:38:05 EST (Tue, 03 Mar 2009)
@@ -1,3 +1,6 @@
+#ifndef TRIVIAL_CLOSURE2_DWA200933_H
+# define TRIVIAL_CLOSURE2_DWA200933_H
+
struct frame { };
inline void work( frame* )
@@ -6,7 +9,7 @@
#if REFERENCE_CLOSURE
-void nested( frame* f ) { work(f); }
+inline void nested( frame* f ) { work(f); }
struct closure {
void (*func)( frame* );
@@ -37,3 +40,5 @@
}
#endif
+
+#endif // TRIVIAL_CLOSURE2_DWA200933_H
Deleted: sandbox/reference_closure/trivial_function.cc
==============================================================================
--- sandbox/reference_closure/trivial_function.cc 2009-03-03 22:38:05 EST (Tue, 03 Mar 2009)
+++ (empty file)
@@ -1,7 +0,0 @@
-#include <tr1/functional>
-using std::tr1::function;
-void executer( function<void()> arg ) { arg(); }
-void passer( function<void()> arg ) { executer( arg ); }
-#include "trivial_closure.h"
-#include "trivial_initiator.h"
-#include "trivial_main.h"
Modified: sandbox/reference_closure/trivial_initiator.h
==============================================================================
--- sandbox/reference_closure/trivial_initiator.h (original)
+++ sandbox/reference_closure/trivial_initiator.h 2009-03-03 22:38:05 EST (Tue, 03 Mar 2009)
@@ -1,3 +1,6 @@
+#include "trivial_closure.h"
+#include "parallel_lib.h"
+
void initiator() {
frame mine;
Deleted: sandbox/reference_closure/trivial_main.h
==============================================================================
--- sandbox/reference_closure/trivial_main.h 2009-03-03 22:38:05 EST (Tue, 03 Mar 2009)
+++ (empty file)
@@ -1,5 +0,0 @@
-int main() {
- for ( int i = 0; i < 1000*1000*100; i++ )
- initiator();
- return 0;
-}
Deleted: sandbox/reference_closure/trivial_nested.cc
==============================================================================
--- sandbox/reference_closure/trivial_nested.cc 2009-03-03 22:38:05 EST (Tue, 03 Mar 2009)
+++ (empty file)
@@ -1,5 +0,0 @@
-#include "trivial_closure.h"
-void executer( closure arg ) { arg(); }
-void passer( closure arg ) { executer( arg ); }
-#include "trivial_initiator.h"
-#include "trivial_main.h"
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