mirror of
https://github.com/boostorg/odeint.git
synced 2025-05-11 21:44:03 +00:00
some perf comments
This commit is contained in:
parent
6e41b57ba1
commit
589bdc45c0
@ -38,14 +38,14 @@ namespace odeint {
|
|||||||
template< class StateType , class Enabler = void >
|
template< class StateType , class Enabler = void >
|
||||||
struct algebra_dispatcher_sfinae
|
struct algebra_dispatcher_sfinae
|
||||||
{
|
{
|
||||||
// range_algebra is the standard algebra^
|
// range_algebra is the standard algebra
|
||||||
typedef range_algebra algebra_type;
|
typedef range_algebra algebra_type;
|
||||||
};
|
};
|
||||||
|
|
||||||
template< class StateType >
|
template< class StateType >
|
||||||
struct algebra_dispatcher : algebra_dispatcher_sfinae< StateType > { };
|
struct algebra_dispatcher : algebra_dispatcher_sfinae< StateType > { };
|
||||||
|
|
||||||
//specialize for array
|
// specialize for array
|
||||||
template< class T , size_t N >
|
template< class T , size_t N >
|
||||||
struct algebra_dispatcher< boost::array< T , N > >
|
struct algebra_dispatcher< boost::array< T , N > >
|
||||||
{
|
{
|
||||||
|
@ -13,6 +13,7 @@ program main
|
|||||||
integer :: time_end
|
integer :: time_end
|
||||||
integer :: count_rate
|
integer :: count_rate
|
||||||
real(dp) :: time
|
real(dp) :: time
|
||||||
|
real(dp) :: min_time = 100.0
|
||||||
|
|
||||||
do k = 1, nb_loops
|
do k = 1, nb_loops
|
||||||
x = [ 8.5_dp, 3.1_dp, 1.2_dp ]
|
x = [ 8.5_dp, 3.1_dp, 1.2_dp ]
|
||||||
@ -20,8 +21,10 @@ program main
|
|||||||
call rk4sys(n, t, x, h, nstep)
|
call rk4sys(n, t, x, h, nstep)
|
||||||
call system_clock(time_end, count_rate)
|
call system_clock(time_end, count_rate)
|
||||||
time = real(time_end - time_begin, dp) / real(count_rate, dp)
|
time = real(time_end - time_begin, dp) / real(count_rate, dp)
|
||||||
|
min_time = min(time, min_time)
|
||||||
write (*,*) time, x(1)
|
write (*,*) time, x(1)
|
||||||
end do
|
end do
|
||||||
|
write (*,*) "Minimal Runtime:", min_time
|
||||||
contains
|
contains
|
||||||
subroutine xpsys(x,f)
|
subroutine xpsys(x,f)
|
||||||
real(dp), dimension(1:3), intent(in) :: x
|
real(dp), dimension(1:3), intent(in) :: x
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* odeint_rk4_lorenz_def_alg.cpp
|
* odeint_rk4_array
|
||||||
*
|
*
|
||||||
* Copyright 2011 Mario Mulansky
|
* Copyright 2011 Mario Mulansky
|
||||||
* Copyright 2012 Karsten Ahnert
|
* Copyright 2012 Karsten Ahnert
|
||||||
@ -9,6 +9,7 @@
|
|||||||
* copy at http://www.boost.org/LICENSE_1_0.txt)
|
* copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
#include <boost/timer.hpp>
|
#include <boost/timer.hpp>
|
||||||
#include <boost/array.hpp>
|
#include <boost/array.hpp>
|
||||||
@ -24,9 +25,14 @@ typedef boost::timer timer_type;
|
|||||||
typedef boost::array< double , 3 > state_type;
|
typedef boost::array< double , 3 > state_type;
|
||||||
|
|
||||||
using namespace boost::numeric::odeint;
|
using namespace boost::numeric::odeint;
|
||||||
|
|
||||||
//typedef boost::numeric::odeint::runge_kutta4_classic< state_type > rk4_odeint_type;
|
//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 ,
|
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;
|
const int loops = 21;
|
||||||
@ -38,6 +44,8 @@ int main()
|
|||||||
{
|
{
|
||||||
double min_time = 1E6; // something big
|
double min_time = 1E6; // something big
|
||||||
rk4_odeint_type stepper;
|
rk4_odeint_type stepper;
|
||||||
|
std::clog.precision(16);
|
||||||
|
std::cout.precision(16);
|
||||||
for( int n=0; n<loops; n++ )
|
for( int n=0; n<loops; n++ )
|
||||||
{
|
{
|
||||||
state_type x = {{ 8.5, 3.1, 1.2 }};
|
state_type x = {{ 8.5, 3.1, 1.2 }};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user