Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r71661 - sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/fusion_runge_kutta/performance
From: mario.mulansky_at_[hidden]
Date: 2011-05-02 06:49:16


Author: mariomulansky
Date: 2011-05-02 06:49:13 EDT (Mon, 02 May 2011)
New Revision: 71661
URL: http://svn.boost.org/trac/boost/changeset/71661

Log:
defining func lorenz as inline decreases runtime by 50% when using gcc (I thought compiler would see this by itself) - rerunning performance tests...
Added:
   sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/fusion_runge_kutta/performance/perf_tests.py (contents, props changed)
Text files modified:
   sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/fusion_runge_kutta/performance/generic_rk4.cpp | 8 ++++----
   sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/fusion_runge_kutta/performance/generic_rk54ck.cpp | 10 ++++++----
   sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/fusion_runge_kutta/performance/gsl_rk4.cpp | 8 +++++---
   sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/fusion_runge_kutta/performance/gsl_rk54ck.cpp | 6 ++++--
   sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/fusion_runge_kutta/performance/nr_rk4.cpp | 8 +++++---
   sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/fusion_runge_kutta/performance/odeint_rk4.cpp | 8 ++++----
   sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/fusion_runge_kutta/performance/odeint_rk54ck.cpp | 6 +++---
   sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/fusion_runge_kutta/performance/results.dat | 3 +++
   sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/fusion_runge_kutta/performance/rt_generic_rk4.cpp | 10 ++++++----
   9 files changed, 40 insertions(+), 27 deletions(-)

Modified: sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/fusion_runge_kutta/performance/generic_rk4.cpp
==============================================================================
--- sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/fusion_runge_kutta/performance/generic_rk4.cpp (original)
+++ sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/fusion_runge_kutta/performance/generic_rk4.cpp 2011-05-02 06:49:13 EDT (Mon, 02 May 2011)
@@ -40,7 +40,7 @@
 typedef explicit_rk< state_type , 4 > rk4_fusion_type;
 
 
-void lorenz( const state_type &x , state_type &dxdt , double t )
+inline void lorenz( const state_type &x , state_type &dxdt , const double t )
 {
     const double sigma = 10.0;
     const double R = 28.0;
@@ -51,7 +51,7 @@
 }
 
 
-
+const size_t loops = 20;
 
 int main( int argc , char **argv )
 {
@@ -77,7 +77,7 @@
 
     srand( 12312354 );
 
- while( true )
+ for( size_t n=0 ; n<loops ; ++n )
     {
         state_type x = {{ 10.0 * rand()/RAND_MAX , 10.0 * rand()/RAND_MAX , 10.0 * rand()/RAND_MAX }};
         //state_type x = {{ 10.0 , 1.0 , 5.0 }};
@@ -92,6 +92,6 @@
         clog.width( 5 );
         clog << acc << " " << x[0] << endl;
     }
-
+ cout << acc << endl;
     return 0;
 }

Modified: sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/fusion_runge_kutta/performance/generic_rk54ck.cpp
==============================================================================
--- sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/fusion_runge_kutta/performance/generic_rk54ck.cpp (original)
+++ sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/fusion_runge_kutta/performance/generic_rk54ck.cpp 2011-05-02 06:49:13 EDT (Mon, 02 May 2011)
@@ -38,9 +38,10 @@
 
 typedef boost::array< double , 3 > state_type;
 typedef explicit_error_rk< state_type , 6 > rk54ck_fusion_type;
+//typedef explicit_rk< state_type , 6 > rk54ck_fusion_type;
 
 
-void lorenz( const state_type &x , state_type &dxdt , double t )
+inline void lorenz( const state_type &x , state_type &dxdt , const double t )
 {
     const double sigma = 10.0;
     const double R = 28.0;
@@ -51,7 +52,7 @@
 }
 
 
-
+const size_t loops = 20;
 
 int main( int argc , char **argv )
 {
@@ -73,6 +74,7 @@
     const coef_c_type c = {{ 0.0 , 0.2 , 0.3 , 0.6 , 1.0 , 7.0/8 }};
 
     rk54ck_fusion_type rk54ck( a , b , b2 , c );
+ //rk54ck_fusion_type rk54ck( a , b , c );
 
     const size_t num_of_steps = 20000000;
     const double dt = 1E-4;
@@ -82,7 +84,7 @@
 
     srand( 12312354 );
 
- while( true )
+ for( size_t n=0 ; n<loops ; ++n )
     {
         state_type x = {{ 10.0 * rand()/RAND_MAX , 10.0 * rand()/RAND_MAX , 10.0 * rand()/RAND_MAX }};
         state_type x_err;
@@ -97,6 +99,6 @@
         clog.width( 20 );
         clog << acc << " " << x[0] << tab << " " << x_err[0] << endl;
     }
-
+ cout << acc << endl;
     return 0;
 }

Modified: sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/fusion_runge_kutta/performance/gsl_rk4.cpp
==============================================================================
--- sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/fusion_runge_kutta/performance/gsl_rk4.cpp (original)
+++ sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/fusion_runge_kutta/performance/gsl_rk4.cpp 2011-05-02 06:49:13 EDT (Mon, 02 May 2011)
@@ -33,7 +33,7 @@
 typedef boost::timer timer_type;
 
 
-int lorenz_gsl( double t , const double y[] , double f[] , void *params)
+int lorenz_gsl( const double t , const double y[] , double f[] , void *params)
 {
     const double sigma = 10.0;
     const double R = 28.0;
@@ -46,6 +46,8 @@
 }
 
 
+const size_t loops = 20;
+
 int main()
 {
     const size_t num_of_steps = 20000000 / 3 ; // gsl rk4 routine makes error control by
@@ -60,7 +62,7 @@
     gsl_odeiv_step *s = gsl_odeiv_step_alloc( gsl_odeiv_step_rk4 , 3);
     gsl_odeiv_system sys = { lorenz_gsl , 0 , 3 , 0 };
 
- while( true )
+ for( size_t n=0 ; n<loops ; ++n )
     {
         double x[3] = { 10.0 * rand()/RAND_MAX ,
                          10.0 * rand()/RAND_MAX ,
@@ -78,7 +80,7 @@
         clog.width( 5 );
         clog << acc << " " << x[0] << endl;
     }
-
+ cout << acc << endl;
     return 0;
 
 }

Modified: sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/fusion_runge_kutta/performance/gsl_rk54ck.cpp
==============================================================================
--- sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/fusion_runge_kutta/performance/gsl_rk54ck.cpp (original)
+++ sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/fusion_runge_kutta/performance/gsl_rk54ck.cpp 2011-05-02 06:49:13 EDT (Mon, 02 May 2011)
@@ -46,6 +46,8 @@
 }
 
 
+const size_t loops = 20;
+
 int main()
 {
     const size_t num_of_steps = 20000000; // gsl rk4 routine makes error control by
@@ -60,7 +62,7 @@
     gsl_odeiv_step *s = gsl_odeiv_step_alloc( gsl_odeiv_step_rkck , 3);
     gsl_odeiv_system sys = { lorenz_gsl , 0 , 3 , 0 };
 
- while( true )
+ for( size_t n=0 ; n<loops ; ++n )
     {
         double x[3] = { 10.0 * rand()/RAND_MAX ,
                          10.0 * rand()/RAND_MAX ,
@@ -78,7 +80,7 @@
         clog.width( 20 );
         clog << acc << " " << x[0] << tab << " " << x_err[0] << endl;
     }
-
+ cout << acc << endl;
     return 0;
 
 }

Modified: sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/fusion_runge_kutta/performance/nr_rk4.cpp
==============================================================================
--- sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/fusion_runge_kutta/performance/nr_rk4.cpp (original)
+++ sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/fusion_runge_kutta/performance/nr_rk4.cpp 2011-05-02 06:49:13 EDT (Mon, 02 May 2011)
@@ -36,7 +36,7 @@
 
 typedef boost::array< double , 3 > state_type;
 
-void lorenz( const state_type &x , state_type &dxdt , double t )
+inline void lorenz( const state_type &x , state_type &dxdt , const double t )
 {
     const double sigma = 10.0;
     const double R = 28.0;
@@ -76,6 +76,8 @@
 }
 
 
+const size_t loops = 20;
+
 int main( int argc , char **argv )
 {
     const size_t num_of_steps = 20000000;
@@ -86,7 +88,7 @@
 
     srand( 12312354 );
 
- while( true )
+ for( size_t n=0 ; n<loops ; ++n )
     {
         state_type x = {{ 10.0 * rand()/RAND_MAX ,
                           10.0 * rand()/RAND_MAX ,
@@ -102,6 +104,6 @@
         clog.width( 5 );
         clog << acc << " " << x[0] << endl;
     }
-
+ cout << acc << endl;
     return 0;
 }

Modified: sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/fusion_runge_kutta/performance/odeint_rk4.cpp
==============================================================================
--- sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/fusion_runge_kutta/performance/odeint_rk4.cpp (original)
+++ sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/fusion_runge_kutta/performance/odeint_rk4.cpp 2011-05-02 06:49:13 EDT (Mon, 02 May 2011)
@@ -41,7 +41,7 @@
 // boost::numeric::odeint::array_algebra > rk4_odeint_type;
 
 
-void lorenz( const state_type &x , state_type &dxdt , double t )
+inline void lorenz( const state_type &x , state_type &dxdt , const double t )
 {
     const double sigma = 10.0;
     const double R = 28.0;
@@ -52,7 +52,7 @@
 }
 
 
-
+const size_t loops = 20;
 
 int main( int argc , char **argv )
 {
@@ -66,7 +66,7 @@
 
     srand( 12312354 );
 
- while( true )
+ for( size_t n=0 ; n<loops ; ++n )
     {
         state_type x = {{ 10.0 * rand()/RAND_MAX ,
                           10.0 * rand()/RAND_MAX ,
@@ -82,6 +82,6 @@
         clog.width( 5 );
         clog << acc << " " << x[0] << endl;
     }
-
+ cout << acc << endl;
     return 0;
 }

Modified: sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/fusion_runge_kutta/performance/odeint_rk54ck.cpp
==============================================================================
--- sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/fusion_runge_kutta/performance/odeint_rk54ck.cpp (original)
+++ sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/fusion_runge_kutta/performance/odeint_rk54ck.cpp 2011-05-02 06:49:13 EDT (Mon, 02 May 2011)
@@ -52,7 +52,7 @@
 }
 
 
-
+const size_t loops = 20;
 
 int main( int argc , char **argv )
 {
@@ -66,7 +66,7 @@
 
     srand( 12312354 );
 
- while( true )
+ for( size_t n=0 ; n<loops ; ++n )
     {
         state_type x = {{ 10.0 * rand()/RAND_MAX ,
                           10.0 * rand()/RAND_MAX ,
@@ -83,6 +83,6 @@
         clog.width( 20 );
         clog << acc << " " << x[0] << tab << " " << x_err[0] << endl;
     }
-
+ cout << acc << endl;
     return 0;
 }

Added: sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/fusion_runge_kutta/performance/perf_tests.py
==============================================================================
--- (empty file)
+++ sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/fusion_runge_kutta/performance/perf_tests.py 2011-05-02 06:49:13 EDT (Mon, 02 May 2011)
@@ -0,0 +1,23 @@
+from os import popen
+from os.path import isfile
+
+bin_path = "bin/gcc-4.4/release/"
+#bin_path = "bin/intel-linux/release/"
+
+bins = [ "odeint_rk4" , "generic_rk4" , "nr_rk4" , "gsl_rk4" , "rt_generic_rk4" ,
+ "odeint_rk54ck" , "generic_rk54ck" , "gsl_rk54ck" ]
+results = []
+
+for bin in bins:
+ if isfile( bin_path + bin ):
+ print "Running" , bin
+ res = popen( bin_path+bin ).read()
+ print bin , res
+ results.append( res )
+ else:
+ results.append( " -- " )
+
+print "Results from" , bin_path
+
+for i in range(len(bins)):
+ print bins[i] , results[i]

Modified: sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/fusion_runge_kutta/performance/results.dat
==============================================================================
--- sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/fusion_runge_kutta/performance/results.dat (original)
+++ sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/fusion_runge_kutta/performance/results.dat 2011-05-02 06:49:13 EDT (Mon, 02 May 2011)
@@ -8,6 +8,8 @@
 icc 11.1 | 1.11 | 0.98 | 1.19 | 1.28 | 1.99 | Xeon X5650 @ 2.67 GHz
 gcc 4.4.1 | 1.19 | 1.22 | 1.24 | 1.97 | | Core2Quad Q6600 @ 2.40GHz
 msvc 9.0 | 5.84 | 6.30 | 5.55 | ---- | 12.7 | Via Nano @ 1.60 GHz
+gcc 4.4.1 | 0.59 | 0.56 | 0.64 | 1.61 | 1.85 | PhenomII X4 945 @ 3 GHz
+icc 11.1 | 1.15 | 1.09 | 0.74 | 1.62 | 2.18 | PhenomII X4 945 @ 3 GHz
 
 
 Results for Runge-Kutta 54 Cash Karp
@@ -20,3 +22,4 @@
 icc 11.1 | 1.90 | 2.44 | | 2.16 | Xeon X5650 @ 2.67 GHz
 gcc 4.4.1 | | | | | Core2Quad Q6600 @ 2.40GHz
 msvc 9.0 | | | | ---- | Via Nano @ 1.60 GHz
+gcc 4.4.1 | 1.11 | 1.15 | | 2.63 | PhenomII X4 945 @ 3 GHz
\ No newline at end of file

Modified: sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/fusion_runge_kutta/performance/rt_generic_rk4.cpp
==============================================================================
--- sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/fusion_runge_kutta/performance/rt_generic_rk4.cpp (original)
+++ sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/fusion_runge_kutta/performance/rt_generic_rk4.cpp 2011-05-02 06:49:13 EDT (Mon, 02 May 2011)
@@ -87,7 +87,7 @@
         state_type *m_F;
 };
 
-void lorenz( const state_type &x , state_type &dxdt , double t )
+inline void lorenz( const state_type &x , state_type &dxdt , const double t )
 {
     const double sigma = 10.0;
     const double R = 28.0;
@@ -101,6 +101,8 @@
 
 const size_t stage_count = 4;
 
+const size_t loops = 20;
+
 int main( int argc , char **argv )
 {
         rk_stepper_type::coeff_a_type a( stage_count-1 );
@@ -124,7 +126,7 @@
 
     srand( 12312354 );
 
- while( true )
+ for( size_t n=0 ; n<loops ; ++n )
     {
         state_type x = {{ 10.0 * rand()/RAND_MAX , 10.0 * rand()/RAND_MAX , 10.0 * rand()/RAND_MAX }};
         //state_type x = {{ 10.0 , 1.0 , 5.0 }};
@@ -139,6 +141,6 @@
         clog.width( 5 );
         clog << acc << " " << x[0] << endl;
     }
-
+ cout << acc << endl;
     return 0;
-}
\ No newline at end of file
+}


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