2
0
mirror of https://github.com/boostorg/odeint.git synced 2026-01-26 06:42:23 +00:00

performance for default algebra

This commit is contained in:
mariomulansky
2011-05-02 13:56:19 +00:00
parent 8ce68fc0ad
commit ffd5501bc6
6 changed files with 204 additions and 27 deletions

View File

@@ -24,6 +24,10 @@ exe odeint_rk4
: odeint_rk4.cpp
;
exe odeint_rk4_def_alg
: odeint_rk4_def_alg.cpp
;
exe nr_rk4
: nr_rk4.cpp
;
@@ -46,6 +50,10 @@ exe odeint_rk54ck
: odeint_rk54ck.cpp
;
exe odeint_rk54ck_def_alg
: odeint_rk54ck_def_alg.cpp
;
exe gsl_rk54ck
: gsl_rk54ck.cpp libgsl libgslcblas
;

View File

@@ -36,9 +36,8 @@ typedef boost::timer timer_type;
typedef boost::array< double , 3 > state_type;
typedef boost::numeric::odeint::explicit_rk4< state_type > rk4_odeint_type;
//typedef boost::numeric::odeint::explicit_rk4< state_type , double , state_type , double ,
// boost::numeric::odeint::array_algebra > rk4_odeint_type;
typedef boost::numeric::odeint::explicit_rk4< state_type , double , state_type , double ,
boost::numeric::odeint::array_algebra > rk4_odeint_type;
inline void lorenz( const state_type &x , state_type &dxdt , const double t )

View File

@@ -0,0 +1,84 @@
/*
* odeint_rk4.cpp
*
* Created on: Apr 28, 2011
* Author: mario
*/
#include <iostream>
#include <fstream>
#include <boost/array.hpp>
#include <boost/numeric/odeint/stepper/explicit_rk4.hpp>
#include <boost/numeric/odeint/algebra/array_algebra.hpp>
#include <boost/accumulators/accumulators.hpp>
#include <boost/accumulators/statistics.hpp>
#include <boost/timer.hpp>
#define tab "\t"
using namespace std;
using namespace boost::accumulators;
typedef accumulator_set<
double , stats< tag::mean , tag::variance >
> accumulator_type;
ostream& operator<<( ostream& out , accumulator_type &acc )
{
out << boost::accumulators::mean( acc ) << tab;
// out << boost::accumulators::variance( acc ) << tab;
return out;
}
typedef boost::timer timer_type;
typedef boost::array< double , 3 > state_type;
typedef boost::numeric::odeint::explicit_rk4< state_type > rk4_odeint_type;
inline void lorenz( const state_type &x , state_type &dxdt , const double t )
{
const double sigma = 10.0;
const double R = 28.0;
const double b = 8.0 / 3.0;
dxdt[0] = sigma * ( x[1] - x[0] );
dxdt[1] = R * x[0] - x[1] - x[0] * x[2];
dxdt[2] = x[0]*x[1] - b * x[2];
}
const size_t loops = 20;
int main( int argc , char **argv )
{
rk4_odeint_type rk4_odeint;
const size_t num_of_steps = 20000000;
const double dt = 1E-10;
accumulator_type acc;
timer_type timer;
srand( 12312354 );
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 }};
double t = 0.0;
timer.restart();
for( size_t i=0 ; i<num_of_steps ; ++i, t+=dt )
rk4_odeint.do_step( lorenz , x , t , dt );
acc( timer.elapsed() );
clog.precision( 3 );
clog.width( 5 );
clog << acc << " " << x[0] << endl;
}
cout << acc << endl;
return 0;
}

View File

@@ -0,0 +1,86 @@
/*
* odeint_rk54ck.cpp
*
* Created on: Apr 29, 2011
* Author: mario
*/
#include <iostream>
#include <fstream>
#include <boost/array.hpp>
#include <boost/numeric/odeint/stepper/explicit_error_rk54_ck.hpp>
#include <boost/numeric/odeint/algebra/array_algebra.hpp>
#include <boost/accumulators/accumulators.hpp>
#include <boost/accumulators/statistics.hpp>
#include <boost/timer.hpp>
#define tab "\t"
using namespace std;
using namespace boost::accumulators;
typedef accumulator_set<
double , stats< tag::mean , tag::variance >
> accumulator_type;
ostream& operator<<( ostream& out , accumulator_type &acc )
{
out << boost::accumulators::mean( acc ) << tab;
// out << boost::accumulators::variance( acc ) << tab;
return out;
}
typedef boost::timer timer_type;
typedef boost::array< double , 3 > state_type;
typedef boost::numeric::odeint::explicit_error_rk54_ck< state_type > rk54_ck_odeint_type;
inline void lorenz( const state_type &x , state_type &dxdt , const double t )
{
const double sigma = 10.0;
const double R = 28.0;
const double b = 8.0 / 3.0;
dxdt[0] = sigma * ( x[1] - x[0] );
dxdt[1] = R * x[0] - x[1] - x[0] * x[2];
dxdt[2] = x[0]*x[1] - b * x[2];
}
const size_t loops = 20;
int main( int argc , char **argv )
{
rk54_ck_odeint_type rk54_ck_odeint;
const size_t num_of_steps = 20000000;
const double dt = 1E-4;
accumulator_type acc;
timer_type timer;
srand( 12312354 );
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;
double t = 0.0;
timer.restart();
for( size_t i=0 ; i<num_of_steps ; ++i, t+=dt )
rk54_ck_odeint.do_step( lorenz , x , t , dt , x_err );
acc( timer.elapsed() );
clog.precision( 15 );
clog.width( 20 );
clog << acc << " " << x[0] << tab << " " << x_err[0] << endl;
}
cout << acc << endl;
return 0;
}

View File

@@ -1,11 +1,11 @@
from os import popen
from os.path import isfile
#bin_path = "bin/gcc-4.4/release/"
bin_path = "bin/intel-linux/release/"
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" ]
bins = [ "odeint_rk4" , "odeint_rk4_def_alg" , "generic_rk4" , "nr_rk4" , "gsl_rk4" , "rt_generic_rk4" ,
"odeint_rk54ck" , "odeint_rk54ck_def_alg" , "generic_rk54ck" , "gsl_rk54ck" ]
results = []
print "Performance tests for " , bin_path

View File

@@ -1,26 +1,26 @@
Results for Runge-Kutta 4 with different implementations and compilers
| odeint | generic | nr | gsl | rt gen |
-------------------------------------------------------------------------
gcc 4.5.0 | 0.78 | 0.76 | 0.80 | 1.07 | 1.08 | Corei7 870 @ 2.93 GHz
gcc 4.3.2 | 0.84 | 0.64 | 0.96 | 1.52 | 1.85 | Core2Quad Q9550 @ 2.83 GHz
icc 12.0.2 | 0.81 | 0.85 | 1.03 | 1.07 | 1.61 | Corei7 870 @ 2.93 GHz
icc 11.1 | 0.98 | 1.03 | 0.64 | 1.35 | 1.99 | Xeon X5650 @ 2.67 GHz
gcc 4.4.1 | 1.19 | 1.22 | 1.24 | 1.97 | | Core2Quad Q6600 @ 2.40GHz (to be repeated)
msvc 9.0 | 5.84 | 6.30 | 5.55 | ---- | 12.7 | Via Nano @ 1.60 GHz (to be repeated)
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
| odeint | def alg | generic | nr | gsl | rt gen |
-------------------------------------------------------------------------------------
gcc 4.5.0 | 0.78 | | 0.76 | 0.80 | 1.07 | 1.08 | Corei7 870 @ 2.93 GHz
gcc 4.3.2 | 0.84 | | 0.64 | 0.96 | 1.52 | 1.85 | Core2Quad Q9550 @ 2.83 GHz
icc 12.0.2 | 0.81 | | 0.85 | 1.03 | 1.07 | 1.61 | Corei7 870 @ 2.93 GHz
icc 11.1 | 0.98 | | 1.03 | 0.64 | 1.35 | 1.99 | Xeon X5650 @ 2.67 GHz
gcc 4.4.1 | 1.19 | | 1.22 | 1.24 | 1.97 | | Core2Quad Q6600 @ 2.40GHz (to be repeated)
msvc 9.0 | 6.91 | | 7.28 | 5.59 | ---- | 13.2 | Via Nano @ 1.60 GHz
gcc 4.4.1 | 0.59 | 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
| odeint | generic | nr | gsl |
-------------------------------------------------------------
gcc 4.5.0 | 0.80 | 1.28 | | 1.80 | Corei7 870 @ 2.93 GHz
gcc 4.3.2 | 1.41 | 1.27 | | 3.80 | Core2Quad Q9550 @ 2.83 GHz
icc 12.0.2 | 1.41 | 2.03 | | 1.86 | Corei7 870 @ 2.93 GHz
icc 11.1 | 1.90 | 2.40 | | 2.20 | 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
icc 11.1 | 1.83 | 2.42 | | 2.67 | PhenomII X4 945 @ 3 GHz
| odeint | def alg | generic | nr | gsl |
-------------------------------------------------------------------------
gcc 4.5.0 | 0.80 | | 1.28 | | 1.80 | Corei7 870 @ 2.93 GHz
gcc 4.3.2 | 1.41 | | 1.27 | | 3.80 | Core2Quad Q9550 @ 2.83 GHz
icc 12.0.2 | 1.41 | | 2.03 | | 1.86 | Corei7 870 @ 2.93 GHz
icc 11.1 | 1.90 | | 2.40 | | 2.20 | Xeon X5650 @ 2.67 GHz
gcc 4.4.1 | | | | | | Core2Quad Q6600 @ 2.40GHz
msvc 9.0 | 12.8 | | 15.4 | | ---- | Via Nano @ 1.60 GHz
gcc 4.4.1 | 1.06 | 1.05 | 1.15 | | 2.63 | PhenomII X4 945 @ 3 GHz
icc 11.1 | 1.83 | | 2.42 | | 2.67 | PhenomII X4 945 @ 3 GHz