|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r78179 - in trunk/libs/context: doc performance
From: oliver.kowalke_at_[hidden]
Date: 2012-04-24 08:36:56
Author: olli
Date: 2012-04-24 08:36:55 EDT (Tue, 24 Apr 2012)
New Revision: 78179
URL: http://svn.boost.org/trac/boost/changeset/78179
Log:
context: documentation update, performance test with boost.function
Text files modified:
trunk/libs/context/doc/performance.qbk | 12 ++++++++----
trunk/libs/context/doc/rationale.qbk | 17 +++++------------
trunk/libs/context/performance/performance.cpp | 27 +++++++++++++++++++++++++++
3 files changed, 40 insertions(+), 16 deletions(-)
Modified: trunk/libs/context/doc/performance.qbk
==============================================================================
--- trunk/libs/context/doc/performance.qbk (original)
+++ trunk/libs/context/doc/performance.qbk 2012-04-24 08:36:55 EDT (Tue, 24 Apr 2012)
@@ -15,19 +15,23 @@
'variant=release cxxflags=-DBOOST_DISABLE_ASSERTS'.
The numbers in the table are the number of cycles per iteration, based upon an
-average computed over 1000 iterations.
+average computed over 256 iterations.
[table Perfomance of context switch
- [[Platform] [ucontext_t] [fcontext_t]]
+ [[Platform] [ucontext_t] [fcontext_t with fpu] [fcontext_t without fpu] [boost::function]]
[
[AMD Athlon 64 DualCore 4400+ (32bit Linux)]
- [1771 cycles]
- [146 cycles]
+ [846 cycles]
+ [65 cycles]
+ [46 cycles]
+ [43 cycles]
]
[
[Intel Core2 Quad (64bit Linux)]
[1739 cycles]
[117 cycles]
+ [117 cycles]
+ [117 cycles]
]
]
Modified: trunk/libs/context/doc/rationale.qbk
==============================================================================
--- trunk/libs/context/doc/rationale.qbk (original)
+++ trunk/libs/context/doc/rationale.qbk 2012-04-24 08:36:55 EDT (Tue, 24 Apr 2012)
@@ -35,6 +35,11 @@
[note Context switches do not preserve the signal mask on UNIX systems.]
+Because the assembler code uses the byte layout of __fcontext__ to access
+its members __fcontext_t must be a POD. This requires that __fcontext__ has only a
+default constructor, no visibility keywords (e.g. private, public, protected), no
+virtual methods and all members and base clases are PODs too.
+
[section Other APIs ]
@@ -103,9 +108,6 @@
[footnote [@boost:/libs/context/doc/pdf/calling-conventions.pdf 'Calling Conventions',
Agner Fog]].
-Conclusion: because caller as well as callee preserve FpCsr and MxCsr
-__jump_fcontext__ is not required to preserve FpCsr and MxCsr.
-
[heading x86_64]
@@ -123,9 +125,6 @@
[footnote [@http://http://msdn.microsoft.com/en-us/library/ms235300.aspx MSDN article
'FpCsr']].
-Conclusion: because caller as well as callee preserve FpCsr and MxCsr
-__jump_fcontext__ are not required to preserve FpCsr and MxCsr.
-
"The MMX and floating-point stack registers (MM0-MM7/ST0-ST7) are preserved across
context switches. There is no explicit calling convention for these registers."
[footnote [@http://msdn.microsoft.com/en-us/library/a32tsf7t%28VS.80%29.aspx MSDN article
@@ -135,9 +134,6 @@
[footnote [@boost:/libs/context/doc/pdf/calling-conventions.pdf 'Calling Conventions',
Agner Fog]].
-Conclusion: because no explicit calling convetion exists and MS compiler do not use those
-registers, they will not be preserved.
-
"XMM6-XMM15 must be preserved"
[footnote [@http://msdn.microsoft.com/en-us/library/9z1stfyw%28v=vs.100%29.aspx MSDN
article 'Register Usage']]
@@ -151,9 +147,6 @@
[footnote [@boost:/libs/context/doc/pdf/x86_64-sysv.pdf SysV ABI AMD64 Architecture
Processor Supplement Draft Version 0.99.4, 3.2.1]].
-Conclusion: FpCsr and MxCsr must be preserved.
-
-
[endsect]
Modified: trunk/libs/context/performance/performance.cpp
==============================================================================
--- trunk/libs/context/performance/performance.cpp (original)
+++ trunk/libs/context/performance/performance.cpp 2012-04-24 08:36:55 EDT (Tue, 24 Apr 2012)
@@ -13,6 +13,7 @@
#include <boost/assert.hpp>
#include <boost/bind.hpp>
+#include <boost/function.hpp>
#include <boost/config.hpp>
#include <boost/context/all.hpp>
#include <boost/preprocessor/repetition/repeat_from_to.hpp>
@@ -30,6 +31,9 @@
bool preserve_fpu = true;
+#define CALL_FUNCTION(z,n,unused) \
+ fn();
+
#define CALL_UCONTEXT(z,n,unused) \
::swapcontext( & ucm, & uc);
@@ -41,6 +45,9 @@
#endif
ctx::fcontext_t fc, fcm;
+static void f3()
+{ }
+
#ifndef BOOST_WINDOWS
static void f2()
{
@@ -55,6 +62,24 @@
ctx::jump_fcontext( & fc, & fcm, 7, preserve_fpu);
}
+cycle_t test_function( cycle_t ov)
+{
+ boost::function< void() > fn( boost::bind( f3) );
+ // cache warum-up
+BOOST_PP_REPEAT_FROM_TO( 0, BOOST_PP_LIMIT_MAG, CALL_FUNCTION, ~)
+
+ cycle_t start( cycles() );
+BOOST_PP_REPEAT_FROM_TO( 0, BOOST_PP_LIMIT_MAG, CALL_FUNCTION, ~)
+ cycle_t total( cycles() - start);
+
+ // we have two jumps and two measuremt-overheads
+ total -= ov; // overhead of measurement
+ total /= BOOST_PP_LIMIT_MAG; // per call
+ total /= 2; // 2x jump_to c1->c2 && c2->c1
+
+ return total;
+}
+
#ifndef BOOST_WINDOWS
cycle_t test_ucontext( cycle_t ov)
{
@@ -142,6 +167,8 @@
res = test_ucontext( ov);
std::cout << "ucontext: average of " << res << " cycles per switch" << std::endl;
#endif
+ res = test_function( ov);
+ std::cout << "boost::function: average of " << res << " cycles per switch" << std::endl;
return EXIT_SUCCESS;
}
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