Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r71918 - in sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/fusion_runge_kutta: . performance
From: mario.mulansky_at_[hidden]
Date: 2011-05-13 11:43:25


Author: mariomulansky
Date: 2011-05-13 11:43:23 EDT (Fri, 13 May 2011)
New Revision: 71918
URL: http://svn.boost.org/trac/boost/changeset/71918

Log:
better msvc performance
Added:
   sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/fusion_runge_kutta/performance/lorenz_gsl.hpp (contents, props changed)
Text files modified:
   sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/fusion_runge_kutta/fusion_algebra.hpp | 62 ++++++++++++++++++++-------------------
   sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/fusion_runge_kutta/performance/generic_rk4_lorenz.cpp | 2
   sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/fusion_runge_kutta/performance/gsl_rk4_lorenz.cpp | 2
   sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/fusion_runge_kutta/performance/gsl_rk54ck.cpp | 2
   sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/fusion_runge_kutta/performance/gsl_rk54ck_lorenz.cpp | 2
   sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/fusion_runge_kutta/performance/lorenz.hpp | 21 +++----------
   6 files changed, 41 insertions(+), 50 deletions(-)

Modified: sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/fusion_runge_kutta/fusion_algebra.hpp
==============================================================================
--- sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/fusion_runge_kutta/fusion_algebra.hpp (original)
+++ sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/fusion_runge_kutta/fusion_algebra.hpp 2011-05-13 11:43:23 EDT (Fri, 13 May 2011)
@@ -50,8 +50,10 @@
 /** hand-wise implementation for performance improvement for n = 1..4 **/
 
 /* !!!!!!! Actually, this is factor 3 slower with intel compiler, so we don'y use it !!!!!
- * Update: Current implementation increases performance on msvc 9.0 by about 30%, so it is in use again....
- *
+ * Update: It increases performance on msvc 9.0 by about 30%, so it is activated for MSVC
+ */
+
+#ifdef BOOST_MSVC
 
 template<>
 struct fusion_algebra< 1 >
@@ -63,8 +65,8 @@
     {
         for( size_t i=0 ; i<dim ; ++i )
         {
- x_tmp[i] = x[i];
- x_tmp[i] += a[0]*dt*k_vector[0][i];
+ x_tmp[i] = x[i]
+ + a[0]*dt*k_vector[0][i];
         }
     }
 
@@ -82,9 +84,9 @@
     {
         for( size_t i=0 ; i<dim ; ++i )
         {
- x_tmp[i] = x[i];
- x_tmp[i] += a[0]*dt*k_vector[0][i];
- x_tmp[i] += a[1]*dt*k_vector[1][i];
+ x_tmp[i] = x[i]
+ + a[0]*dt*k_vector[0][i]
+ + a[1]*dt*k_vector[1][i];
         }
     }
 
@@ -102,10 +104,10 @@
     {
         for( size_t i=0 ; i<dim ; ++i )
         {
- x_tmp[i] = x[i];
- x_tmp[i] += a[0]*dt*k_vector[0][i];
- x_tmp[i] += a[1]*dt*k_vector[1][i];
- x_tmp[i] += a[2]*dt*k_vector[2][i];
+ x_tmp[i] = x[i]
+ + a[0]*dt*k_vector[0][i]
+ + a[1]*dt*k_vector[1][i]
+ + a[2]*dt*k_vector[2][i];
         }
     }
 
@@ -122,11 +124,11 @@
     {
         for( size_t i=0 ; i<dim ; ++i )
         {
- x_tmp[i] = x[i];
- x_tmp[i] += a[0]*dt*k_vector[0][i];
- x_tmp[i] += a[1]*dt*k_vector[1][i];
- x_tmp[i] += a[2]*dt*k_vector[2][i];
- x_tmp[i] += a[3]*dt*k_vector[3][i];
+ x_tmp[i] = x[i]
+ + a[0]*dt*k_vector[0][i]
+ + a[1]*dt*k_vector[1][i]
+ + a[2]*dt*k_vector[2][i]
+ + a[3]*dt*k_vector[3][i];
         }
     }
 
@@ -143,12 +145,12 @@
     {
         for( size_t i=0 ; i<dim ; ++i )
         {
- x_tmp[i] = x[i];
- x_tmp[i] += a[0]*dt*k_vector[0][i];
- x_tmp[i] += a[1]*dt*k_vector[1][i];
- x_tmp[i] += a[2]*dt*k_vector[2][i];
- x_tmp[i] += a[3]*dt*k_vector[3][i];
- x_tmp[i] += a[4]*dt*k_vector[4][i];
+ x_tmp[i] = x[i]
+ + a[0]*dt*k_vector[0][i]
+ + a[1]*dt*k_vector[1][i]
+ + a[2]*dt*k_vector[2][i]
+ + a[3]*dt*k_vector[3][i]
+ + a[4]*dt*k_vector[4][i];
         }
     }
 
@@ -165,13 +167,13 @@
     {
         for( size_t i=0 ; i<dim ; ++i )
         {
- x_tmp[i] = x[i];
- x_tmp[i] += a[0]*dt*k_vector[0][i];
- x_tmp[i] += a[1]*dt*k_vector[1][i];
- x_tmp[i] += a[2]*dt*k_vector[2][i];
- x_tmp[i] += a[3]*dt*k_vector[3][i];
- x_tmp[i] += a[4]*dt*k_vector[4][i];
- x_tmp[i] += a[5]*dt*k_vector[5][i];
+ x_tmp[i] = x[i]
+ + a[0]*dt*k_vector[0][i]
+ + a[1]*dt*k_vector[1][i]
+ + a[2]*dt*k_vector[2][i]
+ + a[3]*dt*k_vector[3][i]
+ + a[4]*dt*k_vector[4][i]
+ + a[5]*dt*k_vector[5][i];
         }
     }
 
@@ -189,7 +191,7 @@
     }
 
 };
-*/
 
+#endif /* BOOST_MSVC */
 
 #endif /* FUSION_ALGEBRA_HPP_ */

Modified: sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/fusion_runge_kutta/performance/generic_rk4_lorenz.cpp
==============================================================================
--- sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/fusion_runge_kutta/performance/generic_rk4_lorenz.cpp (original)
+++ sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/fusion_runge_kutta/performance/generic_rk4_lorenz.cpp 2011-05-13 11:43:23 EDT (Fri, 13 May 2011)
@@ -39,7 +39,7 @@
 
     inline void do_step( const double dt )
     {
- m_stepper.do_step( lorenz() , m_x , m_t , dt );
+ m_stepper.do_step( lorenz(), m_x , m_t , dt );
     }
 
     double state( const size_t i ) const

Modified: sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/fusion_runge_kutta/performance/gsl_rk4_lorenz.cpp
==============================================================================
--- sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/fusion_runge_kutta/performance/gsl_rk4_lorenz.cpp (original)
+++ sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/fusion_runge_kutta/performance/gsl_rk4_lorenz.cpp 2011-05-13 11:43:23 EDT (Fri, 13 May 2011)
@@ -9,7 +9,7 @@
 
 #include "rk_performance_test_case.hpp"
 
-#include "lorenz.hpp"
+#include "lorenz_gsl.hpp"
 
 const size_t dim = 3;
 

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-13 11:43:23 EDT (Fri, 13 May 2011)
@@ -14,7 +14,7 @@
 #include <gsl/gsl_matrix.h>
 #include <gsl/gsl_odeiv.h>
 
-#include "lorenz.hpp"
+#include "lorenz_gsl.hpp"
 
 #define tab "\t"
 

Modified: sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/fusion_runge_kutta/performance/gsl_rk54ck_lorenz.cpp
==============================================================================
--- sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/fusion_runge_kutta/performance/gsl_rk54ck_lorenz.cpp (original)
+++ sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/fusion_runge_kutta/performance/gsl_rk54ck_lorenz.cpp 2011-05-13 11:43:23 EDT (Fri, 13 May 2011)
@@ -9,7 +9,7 @@
 
 #include "rk_performance_test_case.hpp"
 
-#include "lorenz.hpp"
+#include "lorenz_gsl.hpp"
 
 const size_t dim = 3;
 

Modified: sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/fusion_runge_kutta/performance/lorenz.hpp
==============================================================================
--- sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/fusion_runge_kutta/performance/lorenz.hpp (original)
+++ sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/fusion_runge_kutta/performance/lorenz.hpp 2011-05-13 11:43:23 EDT (Fri, 13 May 2011)
@@ -8,6 +8,8 @@
 #ifndef LORENZ_HPP_
 #define LORENZ_HPP_
 
+#include <boost/array.hpp>
+
 struct lorenz
 {
     template< class state_type >
@@ -23,7 +25,9 @@
 };
 
 
-template< class state_type >
+typedef boost::array< double , 3 > state_type;
+
+
 inline void lorenz_func( const state_type &x , state_type &dxdt , const double t )
 {
     const double sigma = 10.0;
@@ -34,19 +38,4 @@
     dxdt[2] = x[0]*x[1] - b * x[2];
 }
 
-#include <gsl/gsl_matrix.h>
-
-int lorenz_gsl( const double t , const double y[] , double f[] , void *params)
-{
- const double sigma = 10.0;
- const double R = 28.0;
- const double b = 8.0 / 3.0;
-
- f[0] = sigma * ( y[1] - y[0] );
- f[1] = R * y[0] - y[1] - y[0] * y[2];
- f[2] = y[0]*y[1] - b * y[2];
- return GSL_SUCCESS;
-}
-
-
 #endif /* LORENZ_HPP_ */

Added: sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/fusion_runge_kutta/performance/lorenz_gsl.hpp
==============================================================================
--- (empty file)
+++ sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/fusion_runge_kutta/performance/lorenz_gsl.hpp 2011-05-13 11:43:23 EDT (Fri, 13 May 2011)
@@ -0,0 +1,25 @@
+/*
+ * lorenz_gsl.hpp
+ *
+ * Created on: May 12, 2011
+ * Author: mario
+ */
+
+#ifndef LORENZ_GSL_HPP_
+#define LORENZ_GSL_HPP_
+
+#include <gsl/gsl_matrix.h>
+
+int lorenz_gsl( const double t , const double y[] , double f[] , void *params)
+{
+ const double sigma = 10.0;
+ const double R = 28.0;
+ const double b = 8.0 / 3.0;
+
+ f[0] = sigma * ( y[1] - y[0] );
+ f[1] = R * y[0] - y[1] - y[0] * y[2];
+ f[2] = y[0]*y[1] - b * y[2];
+ return GSL_SUCCESS;
+}
+
+#endif
\ 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