some perf comments

This commit is contained in:
Mario Mulansky 2014-10-17 11:34:37 +02:00
parent 6e41b57ba1
commit 589bdc45c0
3 changed files with 15 additions and 4 deletions

View File

@ -38,14 +38,14 @@ namespace odeint {
template< class StateType , class Enabler = void >
struct algebra_dispatcher_sfinae
{
// range_algebra is the standard algebra^
// range_algebra is the standard algebra
typedef range_algebra algebra_type;
};
template< class StateType >
struct algebra_dispatcher : algebra_dispatcher_sfinae< StateType > { };
//specialize for array
// specialize for array
template< class T , size_t N >
struct algebra_dispatcher< boost::array< T , N > >
{

View File

@ -13,6 +13,7 @@ program main
integer :: time_end
integer :: count_rate
real(dp) :: time
real(dp) :: min_time = 100.0
do k = 1, nb_loops
x = [ 8.5_dp, 3.1_dp, 1.2_dp ]
@ -20,8 +21,10 @@ program main
call rk4sys(n, t, x, h, nstep)
call system_clock(time_end, count_rate)
time = real(time_end - time_begin, dp) / real(count_rate, dp)
min_time = min(time, min_time)
write (*,*) time, x(1)
end do
write (*,*) "Minimal Runtime:", min_time
contains
subroutine xpsys(x,f)
real(dp), dimension(1:3), intent(in) :: x

View File

@ -1,5 +1,5 @@
/*
* odeint_rk4_lorenz_def_alg.cpp
* odeint_rk4_array
*
* Copyright 2011 Mario Mulansky
* Copyright 2012 Karsten Ahnert
@ -9,6 +9,7 @@
* copy at http://www.boost.org/LICENSE_1_0.txt)
*/
#include <iostream>
#include <boost/timer.hpp>
#include <boost/array.hpp>
@ -24,9 +25,14 @@ typedef boost::timer timer_type;
typedef boost::array< double , 3 > state_type;
using namespace boost::numeric::odeint;
//typedef boost::numeric::odeint::runge_kutta4_classic< state_type > rk4_odeint_type;
// use the never resizer explicitely for optimal performance with gcc,
// for the intel compiler this doesnt matter and the above definition
// gives the same performance
typedef runge_kutta4_classic< state_type , double , state_type , double ,
range_algebra, default_operations, never_resizer > rk4_odeint_type;
array_algebra, default_operations, never_resizer > rk4_odeint_type;
const int loops = 21;
@ -38,6 +44,8 @@ int main()
{
double min_time = 1E6; // something big
rk4_odeint_type stepper;
std::clog.precision(16);
std::cout.precision(16);
for( int n=0; n<loops; n++ )
{
state_type x = {{ 8.5, 3.1, 1.2 }};