|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r71961 - sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/fusion_runge_kutta/performance
From: mario.mulansky_at_[hidden]
Date: 2011-05-15 15:17:04
Author: mariomulansky
Date: 2011-05-15 15:17:03 EDT (Sun, 15 May 2011)
New Revision: 71961
URL: http://svn.boost.org/trac/boost/changeset/71961
Log:
+ phase lattice performance
Added:
sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/fusion_runge_kutta/performance/generic_rk4_phase_lattice.cpp (contents, props changed)
sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/fusion_runge_kutta/performance/nr_rk4_phase_lattice.cpp (contents, props changed)
sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/fusion_runge_kutta/performance/odeint_rk4_phase_lattice.cpp (contents, props changed)
sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/fusion_runge_kutta/performance/phase_lattice.hpp (contents, props changed)
sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/fusion_runge_kutta/performance/rt_generic_rk4_phase_lattice.cpp (contents, props changed)
Text files modified:
sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/fusion_runge_kutta/performance/Jamfile | 19 ++++++++++++++++++-
1 files changed, 18 insertions(+), 1 deletions(-)
Modified: sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/fusion_runge_kutta/performance/Jamfile
==============================================================================
--- sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/fusion_runge_kutta/performance/Jamfile (original)
+++ sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/fusion_runge_kutta/performance/Jamfile 2011-05-15 15:17:03 EDT (Sun, 15 May 2011)
@@ -106,4 +106,21 @@
exe gsl_rk54ck_lorenz
: gsl_rk54ck_lorenz.cpp libgsl libgslcblas
- ;
\ No newline at end of file
+ ;
+
+exe generic_rk4_phase_lattice
+ : generic_rk4_phase_lattice.cpp
+ : <toolset>intel:<cxxflags>-inline-forceinline
+ ;
+
+exe odeint_rk4_phase_lattice
+ : odeint_rk4_phase_lattice.cpp
+ ;
+
+exe nr_rk4_phase_lattice
+ : nr_rk4_phase_lattice.cpp
+ ;
+
+exe rt_generic_rk4_phase_lattice
+ : rt_generic_rk4_phase_lattice.cpp
+ ;
\ No newline at end of file
Added: sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/fusion_runge_kutta/performance/generic_rk4_phase_lattice.cpp
==============================================================================
--- (empty file)
+++ sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/fusion_runge_kutta/performance/generic_rk4_phase_lattice.cpp 2011-05-15 15:17:03 EDT (Sun, 15 May 2011)
@@ -0,0 +1,71 @@
+/*
+ * generic_rk4_phase_lattice.cpp
+ *
+ * Created on: May 15, 2011
+ * Author: mario
+ */
+
+#include <boost/array.hpp>
+
+#include "../fusion_explicit_rk_new.hpp"
+
+#include "rk_performance_test_case.hpp"
+
+#include "phase_lattice.hpp"
+
+const size_t N = 1024;
+
+typedef boost::array< double , N > state_type;
+typedef explicit_rk< state_type , 4 > rk4_fusion_type;
+
+typedef rk4_fusion_type::coef_a_type coef_a_type;
+typedef rk4_fusion_type::coef_b_type coef_b_type;
+typedef rk4_fusion_type::coef_c_type coef_c_type;
+
+const boost::array< double , 1 > a1 = {{ 0.5 }};
+const boost::array< double , 2 > a2 = {{ 0.0 , 0.5 }};
+const boost::array< double , 3 > a3 = {{ 0.0 , 0.0 , 1.0 }};
+
+const coef_a_type a = fusion::make_vector( a1 , a2 , a3 );
+const coef_b_type b = {{ 1.0/6 , 1.0/3 , 1.0/3 , 1.0/6 }};
+const coef_c_type c = {{ 0.0 , 0.5 , 0.5 , 1.0 }};
+
+class fusion_wrapper
+{
+
+public:
+
+ fusion_wrapper() : m_stepper( a , b , c )
+ { }
+
+ void reset_init_cond()
+ {
+ for( size_t i = 0 ; i<N ; ++i )
+ m_x[i] = 2.0*3.1415927*rand() / RAND_MAX;
+ m_t = 0.0;
+ }
+
+ inline void do_step( const double dt )
+ {
+ m_stepper.do_step( phase_lattice<N>(), m_x , m_t , dt );
+ }
+
+ double state( const size_t i ) const
+ { return m_x[i]; }
+
+private:
+ state_type m_x;
+ double m_t;
+ rk4_fusion_type m_stepper;
+};
+
+
+
+int main()
+{
+ srand( 12312354 );
+
+ fusion_wrapper stepper;
+
+ run( stepper , 1000 , 1E-2 );
+}
Added: sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/fusion_runge_kutta/performance/nr_rk4_phase_lattice.cpp
==============================================================================
--- (empty file)
+++ sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/fusion_runge_kutta/performance/nr_rk4_phase_lattice.cpp 2011-05-15 15:17:03 EDT (Sun, 15 May 2011)
@@ -0,0 +1,80 @@
+/*
+ * nr_rk4_phase_lattice.cpp
+ *
+ * Created on: May 15, 2011
+ * Author: mario
+ */
+
+#include <boost/array.hpp>
+
+#include "rk_performance_test_case.hpp"
+
+#include "phase_lattice.hpp"
+
+const size_t dim = 1024;
+
+typedef boost::array< double , dim > state_type;
+
+
+template< class System , typename T , size_t dim >
+void rk4_step( const System sys , boost::array< T , dim > &x , const double t , const double dt )
+{ // fast rk4 implementation adapted from the book 'Numerical Recipes'
+ size_t i;
+ const double hh = dt*0.5;
+ const double h6 = dt/6.0;
+ const double th = t+hh;
+ boost::array< T , dim > dydx , dym , dyt , yt;
+
+ sys( x , dydx , t );
+
+ for( i=0 ; i<dim ; i++ )
+ yt[i] = x[i] + hh*dydx[i];
+
+ sys( yt , dyt , th );
+ for( i=0 ; i<dim ; i++ )
+ yt[i] = x[i] + hh*dyt[i];
+
+ sys( yt , dym , th );
+ for( i=0 ; i<dim ; i++ ) {
+ yt[i] = x[i] + dt*dym[i];
+ dym[i] += dyt[i];
+ }
+ sys( yt , dyt , t+dt );
+ for( i=0 ; i<dim ; i++ )
+ x[i] += h6*( dydx[i] + dyt[i] + 2.0*dym[i] );
+}
+
+
+class nr_wrapper
+{
+public:
+ void reset_init_cond()
+ {
+ for( size_t i = 0 ; i<dim ; ++i )
+ m_x[i] = 2.0*3.1415927*rand() / RAND_MAX;
+ m_t = 0.0;
+ }
+
+ inline void do_step( const double dt )
+ {
+ rk4_step( phase_lattice<dim>() , m_x , m_t , dt );
+ }
+
+ double state( const size_t i ) const
+ { return m_x[i]; }
+
+private:
+ state_type m_x;
+ double m_t;
+};
+
+
+
+int main()
+{
+ srand( 12312354 );
+
+ nr_wrapper stepper;
+
+ run( stepper , 1000 , 1E-2 );
+}
Added: sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/fusion_runge_kutta/performance/odeint_rk4_phase_lattice.cpp
==============================================================================
--- (empty file)
+++ sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/fusion_runge_kutta/performance/odeint_rk4_phase_lattice.cpp 2011-05-15 15:17:03 EDT (Sun, 15 May 2011)
@@ -0,0 +1,60 @@
+/*
+ * odeint_rk4_phase_lattice.cpp
+ *
+ * Created on: May 15, 2011
+ * Author: mario
+ */
+
+#include <cmath>
+
+#include <boost/array.hpp>
+
+#include <boost/numeric/odeint/stepper/explicit_rk4.hpp>
+#include <boost/numeric/odeint/algebra/array_algebra.hpp>
+
+#include "rk_performance_test_case.hpp"
+
+#include "phase_lattice.hpp"
+
+const size_t N = 1024;
+
+typedef boost::array< double , N > state_type;
+typedef boost::numeric::odeint::explicit_rk4< state_type , double , state_type , double ,
+ boost::numeric::odeint::array_algebra > rk4_odeint_type;
+
+
+class odeint_wrapper
+{
+public:
+ void reset_init_cond()
+ {
+ for( size_t i = 0 ; i<N ; ++i )
+ m_x[i] = 2.0*3.1415927*rand() / RAND_MAX;
+ m_t = 0.0;
+ }
+
+ inline void do_step( const double dt )
+ {
+ m_stepper.do_step( phase_lattice<N>() , m_x , m_t , dt );
+ //m_t += dt;
+ }
+
+ double state( const size_t i ) const
+ { return m_x[i]; }
+
+private:
+ state_type m_x;
+ double m_t;
+ rk4_odeint_type m_stepper;
+};
+
+
+
+int main()
+{
+ srand( 12312354 );
+
+ odeint_wrapper stepper;
+
+ run( stepper , 1000 , 1E-2 );
+}
Added: sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/fusion_runge_kutta/performance/phase_lattice.hpp
==============================================================================
--- (empty file)
+++ sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/fusion_runge_kutta/performance/phase_lattice.hpp 2011-05-15 15:17:03 EDT (Sun, 15 May 2011)
@@ -0,0 +1,33 @@
+/*
+*/
+
+#include <cmath>
+
+#include <boost/array.hpp>
+
+template< size_t N >
+struct phase_lattice
+{
+ typedef double value_type;
+ typedef boost::array< value_type , N > state_type;
+
+ value_type m_epsilon;
+ state_type m_omega;
+
+ phase_lattice() : m_epsilon( 6.0/(N*N) ) // should be < 8/N^2 to see phase locking
+ {
+ for( size_t i=1 ; i<N-1 ; ++i )
+ m_omega[i] = m_epsilon*(N-i);
+ }
+
+ void inline operator()( const state_type &x , state_type &dxdt , const double t ) const
+ {
+ dxdt[0] = m_omega[0] + sin( x[1] - x[0] );
+
+ for( size_t i=1 ; i<N-1 ; ++i )
+ dxdt[i] = m_omega[i] + sin( x[i] - x[i-1] ) + sin( x[i+1] - x[i] );
+
+ dxdt[N-1] = m_omega[N-1] + sin( x[N-1] - x[N-2] );
+ }
+
+};
\ No newline at end of file
Added: sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/fusion_runge_kutta/performance/rt_generic_rk4_phase_lattice.cpp
==============================================================================
--- (empty file)
+++ sandbox/odeint/branches/karsten/libs/numeric/odeint/ideas/fusion_runge_kutta/performance/rt_generic_rk4_phase_lattice.cpp 2011-05-15 15:17:03 EDT (Sun, 15 May 2011)
@@ -0,0 +1,74 @@
+/*
+ * rt_generic_rk4_phase_lattice.cpp
+ *
+ * Created on: May 15, 2011
+ * Author: mario
+ */
+
+#include <boost/array.hpp>
+
+#include "../rt_explicit_rk.hpp"
+
+#include "rk_performance_test_case.hpp"
+
+#include "phase_lattice.hpp"
+
+const size_t N = 1024;
+
+typedef boost::array< double , N > state_type;
+
+typedef rt_explicit_rk< state_type > rk_stepper_type;
+
+const size_t stage_count = 4;
+
+
+class rt_generic_wrapper
+{
+public:
+
+ rt_generic_wrapper() : m_stepper( stage_count )
+ {
+ rk_stepper_type::coeff_a_type a( stage_count-1 );
+ a[0].resize(1); a[0][0] = 0.5;
+ a[1].resize(2); a[1][0] = 0.0; a[1][1] = 0.5;
+ a[2].resize(3); a[2][0] = 0.0; a[2][1] = 0.0; a[2][2] = 1.0;
+
+ rk_stepper_type::coeff_b_type b( stage_count );
+ b[0] = 1.0/6; b[1] = 1.0/3; b[2] = 1.0/3; b[3] = 1.0/6;
+
+ rk_stepper_type::coeff_c_type c( stage_count );
+ c[0] = 0.0; c[1] = 0.5; c[2] = 0.5; c[3] = 1.0;
+
+ m_stepper.set_params( a , b , c );
+ }
+
+ void reset_init_cond()
+ {
+ for( size_t i = 0 ; i<N ; ++i )
+ m_x[i] = 2.0*3.1415927*rand() / RAND_MAX;
+ m_t = 0.0;
+ }
+
+ inline void do_step( const double dt )
+ {
+ m_stepper.do_step( phase_lattice<N>() , m_x , m_t , dt );
+ //m_t += dt;
+ }
+
+ double state( const size_t i ) const
+ { return m_x[i]; }
+
+private:
+ state_type m_x;
+ double m_t;
+ rk_stepper_type m_stepper;
+};
+
+
+
+int main()
+{
+ rt_generic_wrapper stepper;
+
+ run( stepper , 1000 , 1E-2 );
+}
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