From b16d11e59d14950844e663fb83af87348100d4fa Mon Sep 17 00:00:00 2001 From: mariomulansky Date: Sun, 13 Jul 2014 19:11:36 +0200 Subject: [PATCH 01/70] activate osx build --- .travis.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.travis.yml b/.travis.yml index 3c2accee..05c008ae 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,9 @@ language: cpp +os: + - linux + - osx + compiler: - gcc - clang From c81753b19aebe533f2d4d4ba96681520ce58851e Mon Sep 17 00:00:00 2001 From: mariomulansky Date: Sun, 13 Jul 2014 19:24:43 +0200 Subject: [PATCH 02/70] activate osx build2 --- .travis.yml | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 05c008ae..bccb5e5e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,9 +8,9 @@ compiler: - gcc - clang -env: - - CXXSTD='' - - CXXSTD='cxxflags="-std=c++0x"' +# env: +# - CXXSTD='' +# - CXXSTD='cxxflags="-std=c++0x"' before_install: - wget http://sourceforge.net/projects/boost/files/boost/1.55.0/boost_1_55_0.tar.bz2/download -O /tmp/boost.tar.bz2 @@ -29,3 +29,7 @@ script: - $BOOST_ROOT/b2 toolset=$CC$GCCVER $CXXSTD # build in c++11 mode only with gcc # - if [ "$CXX" = "g++" ]; then $BOOST_ROOT/b2 -a toolset=$CC$GCCVER cxxflags="-std=c++0x"; fi + +os: + - linux + - osx From 2442912b5aecc15f42eadf14707f81af7f59e0a1 Mon Sep 17 00:00:00 2001 From: mariomulansky Date: Sun, 13 Jul 2014 19:27:11 +0200 Subject: [PATCH 03/70] activate osx build2 --- .travis.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index bccb5e5e..e94b131d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,9 +1,5 @@ language: cpp -os: - - linux - - osx - compiler: - gcc - clang From 6ac91534a056c06b88960a1134a969636916ca63 Mon Sep 17 00:00:00 2001 From: mariomulansky Date: Sun, 13 Jul 2014 19:29:49 +0200 Subject: [PATCH 04/70] only osx --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index e94b131d..8df57a32 100644 --- a/.travis.yml +++ b/.travis.yml @@ -27,5 +27,5 @@ script: # - if [ "$CXX" = "g++" ]; then $BOOST_ROOT/b2 -a toolset=$CC$GCCVER cxxflags="-std=c++0x"; fi os: - - linux +# - linux - osx From 3d1a4d379d596f28fea5c1dc8b7c0d2a17f0c7b6 Mon Sep 17 00:00:00 2001 From: mariomulansky Date: Sun, 13 Jul 2014 19:32:01 +0200 Subject: [PATCH 05/70] only osx --- .travis.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 8df57a32..0fa9cf50 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,5 @@ language: cpp - +os: osx compiler: - gcc - clang @@ -26,6 +26,3 @@ script: # build in c++11 mode only with gcc # - if [ "$CXX" = "g++" ]; then $BOOST_ROOT/b2 -a toolset=$CC$GCCVER cxxflags="-std=c++0x"; fi -os: -# - linux - - osx From 5f1b1c6ffbe20d1b426ce8bf61f77f4ac8bb61e6 Mon Sep 17 00:00:00 2001 From: mariomulansky Date: Sun, 13 Jul 2014 19:40:40 +0200 Subject: [PATCH 06/70] linux+osx runs --- .travis.yml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 0fa9cf50..85933b31 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,12 +1,14 @@ language: cpp -os: osx +os: + - linux + - osx compiler: - gcc - clang -# env: -# - CXXSTD='' -# - CXXSTD='cxxflags="-std=c++0x"' +env: + - CXXSTD='' + - CXXSTD='cxxflags="-std=c++0x"' before_install: - wget http://sourceforge.net/projects/boost/files/boost/1.55.0/boost_1_55_0.tar.bz2/download -O /tmp/boost.tar.bz2 From cbd2959c54426d4c5aa709593b38396ccb5c759b Mon Sep 17 00:00:00 2001 From: mariomulansky Date: Mon, 14 Jul 2014 10:22:18 +0200 Subject: [PATCH 07/70] disable c++11 builds in travis --- .travis.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 85933b31..d7ed5900 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,9 +6,9 @@ compiler: - gcc - clang -env: - - CXXSTD='' - - CXXSTD='cxxflags="-std=c++0x"' +# env: +# - CXXSTD='' +# - CXXSTD='cxxflags="-std=c++0x"' before_install: - wget http://sourceforge.net/projects/boost/files/boost/1.55.0/boost_1_55_0.tar.bz2/download -O /tmp/boost.tar.bz2 @@ -21,7 +21,7 @@ before_install: - cd $BOOST_ROOT - ./bootstrap.sh - cd $TRAVIS_BUILD_DIR - + - $CXX --version script: - $BOOST_ROOT/b2 toolset=$CC$GCCVER $CXXSTD From fb8894c42c9a4ff20a53769e2b823de4b6bc64a9 Mon Sep 17 00:00:00 2001 From: mariomulansky Date: Mon, 14 Jul 2014 10:45:28 +0200 Subject: [PATCH 08/70] fix osx compilation --- .travis.yml | 5 +++-- examples/molecular_dynamics_cells.cpp | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index d7ed5900..8adcb265 100644 --- a/.travis.yml +++ b/.travis.yml @@ -21,10 +21,11 @@ before_install: - cd $BOOST_ROOT - ./bootstrap.sh - cd $TRAVIS_BUILD_DIR - - $CXX --version + - if [ "$TRAVIS_OS_NAME" = "osx" ] && [ "$CC" = "gcc" ]; then export CC=gcc-4.8; fi + - $CC --version script: - - $BOOST_ROOT/b2 toolset=$CC$GCCVER $CXXSTD + - $BOOST_ROOT/b2 toolset=$CC $CXXSTD # build in c++11 mode only with gcc # - if [ "$CXX" = "g++" ]; then $BOOST_ROOT/b2 -a toolset=$CC$GCCVER cxxflags="-std=c++0x"; fi diff --git a/examples/molecular_dynamics_cells.cpp b/examples/molecular_dynamics_cells.cpp index 699b1397..d746ca8b 100644 --- a/examples/molecular_dynamics_cells.cpp +++ b/examples/molecular_dynamics_cells.cpp @@ -22,6 +22,7 @@ #include #include #include +#include #include #include From 59282c85551168b7cba721ed17f9aecdf227b558 Mon Sep 17 00:00:00 2001 From: mariomulansky Date: Mon, 14 Jul 2014 11:00:46 +0200 Subject: [PATCH 09/70] enable c++11, disable gcc on osx in travis --- .travis.yml | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 8adcb265..59e5470f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,9 +6,15 @@ compiler: - gcc - clang -# env: -# - CXXSTD='' -# - CXXSTD='cxxflags="-std=c++0x"' +env: + - CXXSTD='' + - CXXSTD='cxxflags="-std=c++0x"' + +# For now disable gcc on osx as g++4.8 is not yet available +matrix: + exclude: + - os: osx + compiler: gcc before_install: - wget http://sourceforge.net/projects/boost/files/boost/1.55.0/boost_1_55_0.tar.bz2/download -O /tmp/boost.tar.bz2 From b3a658184261905e33b123c4892c6e4ec69dbd5f Mon Sep 17 00:00:00 2001 From: mariomulansky Date: Thu, 31 Jul 2014 16:08:34 +0200 Subject: [PATCH 10/70] fixes #135 --- include/boost/numeric/odeint/external/thrust/thrust_resize.hpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/boost/numeric/odeint/external/thrust/thrust_resize.hpp b/include/boost/numeric/odeint/external/thrust/thrust_resize.hpp index 8f1b181e..41927650 100644 --- a/include/boost/numeric/odeint/external/thrust/thrust_resize.hpp +++ b/include/boost/numeric/odeint/external/thrust/thrust_resize.hpp @@ -22,6 +22,8 @@ #include #include +#include +#include #include namespace boost { From bf7b9f64c9f370ca3efd073585f6c357c1f7e876 Mon Sep 17 00:00:00 2001 From: mariomulansky Date: Thu, 31 Jul 2014 22:53:52 +0200 Subject: [PATCH 11/70] added macros for thrust resizing, addressing #136 --- examples/thrust/Makefile | 2 +- .../odeint/external/thrust/thrust_resize.hpp | 144 +++++++++--------- include/boost/numeric/odeint/util/resize.hpp | 4 +- test_external/thrust/Makefile | 2 +- 4 files changed, 72 insertions(+), 80 deletions(-) diff --git a/examples/thrust/Makefile b/examples/thrust/Makefile index 570a0667..2c47503c 100644 --- a/examples/thrust/Makefile +++ b/examples/thrust/Makefile @@ -16,7 +16,7 @@ CXX = g++ NVCC = $(CUDA_ROOT)/bin/nvcc # NVCC = g++ -INCLUDES += -I$(BOOST_ROOT) -I$(THRUST_ROOT) -I$(CUDA_ROOT)/include -I../../../../.. +INCLUDES += -I../../include/ -I$(BOOST_ROOT) -I$(CUDA_ROOT)/include NVCCFLAGS = -O3 $(INCLUDES) -arch $(ARCH) --compiler-bindir=/opt/gcc4.6.2/bin/ -Xcompiler -fopenmp -DTHRUST_DEVICE_BACKEND=THRUST_DEVICE_BACKEND_OMP # NVCCFLAGS = -O3 $(INCLUDES) -arch $(ARCH) --compiler-bindir=/usr/bin/g++-4.3 -Xcompiler -fopenmp -DTHRUST_DEVICE_BACKEND=THRUST_DEVICE_BACKEND_OMP diff --git a/include/boost/numeric/odeint/external/thrust/thrust_resize.hpp b/include/boost/numeric/odeint/external/thrust/thrust_resize.hpp index 41927650..953c3287 100644 --- a/include/boost/numeric/odeint/external/thrust/thrust_resize.hpp +++ b/include/boost/numeric/odeint/external/thrust/thrust_resize.hpp @@ -23,94 +23,86 @@ #include #include -#include +#include #include namespace boost { namespace numeric { namespace odeint { -template< class T > -struct is_resizeable< thrust::device_vector< T > > -{ - struct type : public boost::true_type { }; - const static bool value = type::value; +#define ODEINT_THRUST_VECTOR_IS_RESIZEABLE( THRUST_VECTOR ) \ +template< class T , class A > \ +struct is_resizeable< THRUST_VECTOR > \ +{ \ + struct type : public boost::true_type { }; \ + const static bool value = type::value; \ +}; \ + +#define ODEINT_TRHUST_VECTOR_RESIZE_IMPL( THRUST_VECTOR ) \ +template< class T, class A > \ +struct resize_impl< THRUST_VECTOR , THRUST_VECTOR > \ +{ \ + static void resize( THRUST_VECTOR &x , \ + const THRUST_VECTOR &y ) \ + { \ + x.resize( y.size() ); \ + } \ +}; \ + +#define ODEINT_THRUST_SAME_SIZE_IMPL( THRUST_VECTOR ) \ +template< class T , class A > \ +struct same_size_impl< THRUST_VECTOR , THRUST_VECTOR > \ +{ \ + static bool same_size( const THRUST_VECTOR &x , \ + const THRUST_VECTOR &y ) \ + { \ + return x.size() == y.size(); \ + } \ }; -template< class T > -struct same_size_impl< thrust::device_vector< T > , thrust::device_vector< T > > -{ - static bool same_size( const thrust::device_vector< T > &x , const thrust::device_vector< T > &y ) - { - return x.size() == y.size(); - } -}; - -template< class T > -struct resize_impl< thrust::device_vector< T > , thrust::device_vector< T > > -{ - static void resize( thrust::device_vector< T > &x , const thrust::device_vector< T > &y ) - { - x.resize( y.size() ); - } -}; +#define ODEINT_THRUST_COPY_IMPL( THRUST_VECTOR ) \ +template< class Container1 , class T , class A > \ +struct copy_impl< Container1 , THRUST_VECTOR > \ +{ \ + static void copy( const Container1 &from , THRUST_VECTOR &to ) \ + { \ + thrust::copy( boost::begin( from ) , boost::end( from ) , \ + boost::begin( to ) ); \ + } \ +}; \ + \ +template< class T , class A , class Container2 > \ +struct copy_impl< THRUST_VECTOR , Container2 > \ +{ \ + static void copy( const THRUST_VECTOR &from , Container2 &to ) \ + { \ + thrust::copy( boost::begin( from ) , boost::end( from ) , \ + boost::begin( to ) ); \ + } \ +}; \ + \ +template< class T , class A > \ +struct copy_impl< THRUST_VECTOR , THRUST_VECTOR > \ +{ \ + static void copy( const THRUST_VECTOR &from , \ + THRUST_VECTOR &to ) \ + { \ + thrust::copy( boost::begin( from ) , boost::end( from ) , \ + boost::begin( to ) ); \ + } \ +}; \ -template< class T > -struct is_resizeable< thrust::host_vector< T > > -{ - struct type : public boost::true_type { }; - const static bool value = type::value; -}; - -template< class T > -struct same_size_impl< thrust::host_vector< T > , thrust::host_vector< T > > -{ - static bool same_size( const thrust::host_vector< T > &x , const thrust::host_vector< T > &y ) - { - return x.size() == y.size(); - } -}; - -template< class T > -struct resize_impl< thrust::host_vector< T > , thrust::host_vector< T > > -{ - static void resize( thrust::host_vector< T > &x , const thrust::host_vector< T > &y ) - { - x.resize( y.size() ); - } -}; - - - -template< class Container1, class Value > -struct copy_impl< Container1 , thrust::device_vector< Value > > -{ - static void copy( const Container1 &from , thrust::device_vector< Value > &to ) - { - thrust::copy( boost::begin( from ) , boost::end( from ) , boost::begin( to ) ); - } -}; - -template< class Value , class Container2 > -struct copy_impl< thrust::device_vector< Value > , Container2 > -{ - static void copy( const thrust::device_vector< Value > &from , Container2 &to ) - { - thrust::copy( boost::begin( from ) , boost::end( from ) , boost::begin( to ) ); - } -}; - -template< class Value > -struct copy_impl< thrust::device_vector< Value > , thrust::device_vector< Value > > -{ - static void copy( const thrust::device_vector< Value > &from , thrust::device_vector< Value > &to ) - { - thrust::copy( boost::begin( from ) , boost::end( from ) , boost::begin( to ) ); - } -}; +ODEINT_THRUST_VECTOR_IS_RESIZEABLE( thrust::device_vector ) +ODEINT_TRHUST_VECTOR_RESIZE_IMPL( thrust::device_vector ) +ODEINT_THRUST_SAME_SIZE_IMPL( thrust::device_vector ) +ODEINT_THRUST_COPY_IMPL( thrust::device_vector ) +ODEINT_THRUST_VECTOR_IS_RESIZEABLE( thrust::host_vector ) +ODEINT_TRHUST_VECTOR_RESIZE_IMPL( thrust::host_vector ) +ODEINT_THRUST_SAME_SIZE_IMPL( thrust::host_vector ) +ODEINT_THRUST_COPY_IMPL( thrust::host_vector ) } // odeint diff --git a/include/boost/numeric/odeint/util/resize.hpp b/include/boost/numeric/odeint/util/resize.hpp index db2ce208..75e9eff4 100644 --- a/include/boost/numeric/odeint/util/resize.hpp +++ b/include/boost/numeric/odeint/util/resize.hpp @@ -33,8 +33,8 @@ namespace boost { namespace numeric { namespace odeint { - - + + template< class StateOut , class StateIn , class Enabler = void > struct resize_impl_sfinae { diff --git a/test_external/thrust/Makefile b/test_external/thrust/Makefile index 5d7b7d38..cd6527ba 100644 --- a/test_external/thrust/Makefile +++ b/test_external/thrust/Makefile @@ -13,7 +13,7 @@ CC = gcc CXX = gcc NVCC = $(CUDA_ROOT)/bin/nvcc -INCLUDES += -I$(BOOST_ROOT) -I$(THRUST_ROOT) -I$(CUDA_ROOT)/include -I../../../../.. +INCLUDES += -I../../include/ -I$(BOOST_ROOT) -I$(THRUST_ROOT) -I$(CUDA_ROOT)/include NVCCFLAGS = -O3 $(INCLUDES) --compiler-bindir=/opt/gcc4.6.2/bin/ From ab613676d95ea53516abc8e210803872561bab89 Mon Sep 17 00:00:00 2001 From: mariomulansky Date: Thu, 31 Jul 2014 23:03:50 +0200 Subject: [PATCH 12/70] fix double include --- include/boost/numeric/odeint/external/thrust/thrust_resize.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/boost/numeric/odeint/external/thrust/thrust_resize.hpp b/include/boost/numeric/odeint/external/thrust/thrust_resize.hpp index 953c3287..341a38a4 100644 --- a/include/boost/numeric/odeint/external/thrust/thrust_resize.hpp +++ b/include/boost/numeric/odeint/external/thrust/thrust_resize.hpp @@ -23,7 +23,7 @@ #include #include -#include +#include #include namespace boost { From ca69d012bb64eb14784125e5de6060b7bb60fa00 Mon Sep 17 00:00:00 2001 From: slayoo Date: Fri, 1 Aug 2014 14:36:56 +0200 Subject: [PATCH 13/70] adding thrust resizing macros for thrust::cpp::vector, thrust::omp::vector, thrust::tbb::vector and thrust::cuda::vector (addressing #136) --- .../odeint/external/thrust/thrust_resize.hpp | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/include/boost/numeric/odeint/external/thrust/thrust_resize.hpp b/include/boost/numeric/odeint/external/thrust/thrust_resize.hpp index 341a38a4..29be7857 100644 --- a/include/boost/numeric/odeint/external/thrust/thrust_resize.hpp +++ b/include/boost/numeric/odeint/external/thrust/thrust_resize.hpp @@ -109,5 +109,42 @@ ODEINT_THRUST_COPY_IMPL( thrust::host_vector ) } // numeric } // boost +#include +#if THRUST_VERSION >= 100600 +# include + namespace boost { namespace numeric { namespace odeint { + ODEINT_THRUST_VECTOR_IS_RESIZEABLE( thrust::cpp::vector ) + ODEINT_TRHUST_VECTOR_RESIZE_IMPL( thrust::cpp::vector ) + ODEINT_THRUST_SAME_SIZE_IMPL( thrust::cpp::vector ) + ODEINT_THRUST_COPY_IMPL( thrust::cpp::vector ) + };};}; +# if defined(_OPENMP) +# include + namespace boost { namespace numeric { namespace odeint { + ODEINT_THRUST_VECTOR_IS_RESIZEABLE( thrust::omp::vector ) + ODEINT_TRHUST_VECTOR_RESIZE_IMPL( thrust::omp::vector ) + ODEINT_THRUST_SAME_SIZE_IMPL( thrust::omp::vector ) + ODEINT_THRUST_COPY_IMPL( thrust::omp::vector ) + };};}; +# endif +# if defined(TBB_VERSION_MAJOR) +# include + namespace boost { namespace numeric { namespace odeint { + ODEINT_THRUST_VECTOR_IS_RESIZEABLE( thrust::tbb::vector ) + ODEINT_TRHUST_VECTOR_RESIZE_IMPL( thrust::tbb::vector ) + ODEINT_THRUST_SAME_SIZE_IMPL( thrust::tbb::vector ) + ODEINT_THRUST_COPY_IMPL( thrust::tbb::vector ) + };};}; +# endif +# if defined(__CUDACC__) +# include + namespace boost { namespace numeric { namespace odeint { + ODEINT_THRUST_VECTOR_IS_RESIZEABLE( thrust::cuda::vector ) + ODEINT_TRHUST_VECTOR_RESIZE_IMPL( thrust::cuda::vector ) + ODEINT_THRUST_SAME_SIZE_IMPL( thrust::cuda::vector ) + ODEINT_THRUST_COPY_IMPL( thrust::cuda::vector ) + };};}; +# endif +#endif #endif // BOOST_NUMERIC_ODEINT_EXTERNAL_THRUST_THRUST_RESIZE_HPP_INCLUDED From 286b87a872e986fa94cfe734c81323b563b93227 Mon Sep 17 00:00:00 2001 From: mariomulansky Date: Fri, 1 Aug 2014 19:26:03 +0200 Subject: [PATCH 14/70] some cosmetics and more dispatcher specializations --- .../thrust/thrust_algebra_dispatcher.hpp | 55 +++++++++++++ .../odeint/external/thrust/thrust_resize.hpp | 81 +++++++++++-------- 2 files changed, 101 insertions(+), 35 deletions(-) diff --git a/include/boost/numeric/odeint/external/thrust/thrust_algebra_dispatcher.hpp b/include/boost/numeric/odeint/external/thrust/thrust_algebra_dispatcher.hpp index 5deba2cb..09613463 100644 --- a/include/boost/numeric/odeint/external/thrust/thrust_algebra_dispatcher.hpp +++ b/include/boost/numeric/odeint/external/thrust/thrust_algebra_dispatcher.hpp @@ -24,6 +24,7 @@ #include #include +// specializations for the standard thrust containers namespace boost { namespace numeric { @@ -48,5 +49,59 @@ struct algebra_dispatcher< thrust::device_vector< T , A > > } // namespace boost +// add support for thrust backend vectors, if available + +#include + +#if THRUST_VERSION >= 100600 + +// specialization for thrust cpp vector +#include +namespace boost { namespace numeric { namespace odeint { + template< class T , class A > + struct algebra_dispatcher< thrust::cpp::vector< T , A > > + { + typedef thrust_algebra algebra_type; + }; +} } } + +// specialization for thrust omp vector +#ifdef _OPENMP +#include +namespace boost { namespace numeric { namespace odeint { + template< class T , class A > + struct algebra_dispatcher< thrust::omp::vector< T , A > > + { + typedef thrust_algebra algebra_type; + }; +} } } +#endif // _OPENMP + +// specialization for thrust tbb vector +#ifdef TBB_VERSION_MAJOR +#include +namespace boost { namespace numeric { namespace odeint { + template< class T , class A > + struct algebra_dispatcher< thrust::tbb::vector< T , A > > + { + typedef thrust_algebra algebra_type; + }; +} } } +#endif // TBB_VERSION_MAJOR + +// specialization for thrust cuda vector +#ifdef __CUDACC__ +#include +namespace boost { namespace numeric { namespace odeint { + template< class T , class A > + struct algebra_dispatcher< thrust::cuda::vector< T , A > > + { + typedef thrust_algebra algebra_type; + }; +} } } +#endif // __CUDACC__ + +#endif // THRUST_VERSION >= 100600 + #endif // BOOST_NUMERIC_ODEINT_EXTERNAL_THRUST_THRUST_ALGEBRA_DISPATCHER_HPP_DEFINED diff --git a/include/boost/numeric/odeint/external/thrust/thrust_resize.hpp b/include/boost/numeric/odeint/external/thrust/thrust_resize.hpp index 29be7857..dc87ae2c 100644 --- a/include/boost/numeric/odeint/external/thrust/thrust_resize.hpp +++ b/include/boost/numeric/odeint/external/thrust/thrust_resize.hpp @@ -30,6 +30,8 @@ namespace boost { namespace numeric { namespace odeint { +// some macros that define the necessary utilities + #define ODEINT_THRUST_VECTOR_IS_RESIZEABLE( THRUST_VECTOR ) \ template< class T , class A > \ struct is_resizeable< THRUST_VECTOR > \ @@ -92,6 +94,7 @@ struct copy_impl< THRUST_VECTOR , THRUST_VECTOR > \ } \ }; \ +// add support for the standard thrust containers ODEINT_THRUST_VECTOR_IS_RESIZEABLE( thrust::device_vector ) ODEINT_TRHUST_VECTOR_RESIZE_IMPL( thrust::device_vector ) @@ -109,42 +112,50 @@ ODEINT_THRUST_COPY_IMPL( thrust::host_vector ) } // numeric } // boost +// add support for thrust backend vectors, if available + #include + #if THRUST_VERSION >= 100600 -# include - namespace boost { namespace numeric { namespace odeint { - ODEINT_THRUST_VECTOR_IS_RESIZEABLE( thrust::cpp::vector ) - ODEINT_TRHUST_VECTOR_RESIZE_IMPL( thrust::cpp::vector ) - ODEINT_THRUST_SAME_SIZE_IMPL( thrust::cpp::vector ) - ODEINT_THRUST_COPY_IMPL( thrust::cpp::vector ) - };};}; -# if defined(_OPENMP) -# include - namespace boost { namespace numeric { namespace odeint { - ODEINT_THRUST_VECTOR_IS_RESIZEABLE( thrust::omp::vector ) - ODEINT_TRHUST_VECTOR_RESIZE_IMPL( thrust::omp::vector ) - ODEINT_THRUST_SAME_SIZE_IMPL( thrust::omp::vector ) - ODEINT_THRUST_COPY_IMPL( thrust::omp::vector ) - };};}; -# endif -# if defined(TBB_VERSION_MAJOR) -# include - namespace boost { namespace numeric { namespace odeint { - ODEINT_THRUST_VECTOR_IS_RESIZEABLE( thrust::tbb::vector ) - ODEINT_TRHUST_VECTOR_RESIZE_IMPL( thrust::tbb::vector ) - ODEINT_THRUST_SAME_SIZE_IMPL( thrust::tbb::vector ) - ODEINT_THRUST_COPY_IMPL( thrust::tbb::vector ) - };};}; -# endif -# if defined(__CUDACC__) -# include - namespace boost { namespace numeric { namespace odeint { - ODEINT_THRUST_VECTOR_IS_RESIZEABLE( thrust::cuda::vector ) - ODEINT_TRHUST_VECTOR_RESIZE_IMPL( thrust::cuda::vector ) - ODEINT_THRUST_SAME_SIZE_IMPL( thrust::cuda::vector ) - ODEINT_THRUST_COPY_IMPL( thrust::cuda::vector ) - };};}; -# endif -#endif + +#include +namespace boost { namespace numeric { namespace odeint { + ODEINT_THRUST_VECTOR_IS_RESIZEABLE( thrust::cpp::vector ) + ODEINT_TRHUST_VECTOR_RESIZE_IMPL( thrust::cpp::vector ) + ODEINT_THRUST_SAME_SIZE_IMPL( thrust::cpp::vector ) + ODEINT_THRUST_COPY_IMPL( thrust::cpp::vector ) +} } } + +#ifdef _OPENMP +#include +namespace boost { namespace numeric { namespace odeint { + ODEINT_THRUST_VECTOR_IS_RESIZEABLE( thrust::omp::vector ) + ODEINT_TRHUST_VECTOR_RESIZE_IMPL( thrust::omp::vector ) + ODEINT_THRUST_SAME_SIZE_IMPL( thrust::omp::vector ) + ODEINT_THRUST_COPY_IMPL( thrust::omp::vector ) +} } } +#endif // _OPENMP + +#ifdef TBB_VERSION_MAJOR +#include +namespace boost { namespace numeric { namespace odeint { + ODEINT_THRUST_VECTOR_IS_RESIZEABLE( thrust::tbb::vector ) + ODEINT_TRHUST_VECTOR_RESIZE_IMPL( thrust::tbb::vector ) + ODEINT_THRUST_SAME_SIZE_IMPL( thrust::tbb::vector ) + ODEINT_THRUST_COPY_IMPL( thrust::tbb::vector ) +} } } +#endif // TBB_VERSION_MAJOR + +#ifdef __CUDACC__ +#include +namespace boost { namespace numeric { namespace odeint { + ODEINT_THRUST_VECTOR_IS_RESIZEABLE( thrust::cuda::vector ) + ODEINT_TRHUST_VECTOR_RESIZE_IMPL( thrust::cuda::vector ) + ODEINT_THRUST_SAME_SIZE_IMPL( thrust::cuda::vector ) + ODEINT_THRUST_COPY_IMPL( thrust::cuda::vector ) +} } } +#endif // __CUDACC__ + +#endif // THRUST_VERSION >= 100600 #endif // BOOST_NUMERIC_ODEINT_EXTERNAL_THRUST_THRUST_RESIZE_HPP_INCLUDED From 9473d7f067b9c4b56862de644898b0ac99676075 Mon Sep 17 00:00:00 2001 From: mariomulansky Date: Fri, 1 Aug 2014 19:38:45 +0200 Subject: [PATCH 15/70] added thrust backend vectors to operations_dispatcher --- .../thrust/thrust_operations_dispatcher.hpp | 61 ++++++++++++++++++- 1 file changed, 58 insertions(+), 3 deletions(-) diff --git a/include/boost/numeric/odeint/external/thrust/thrust_operations_dispatcher.hpp b/include/boost/numeric/odeint/external/thrust/thrust_operations_dispatcher.hpp index 0105a4e3..e9b3a642 100644 --- a/include/boost/numeric/odeint/external/thrust/thrust_operations_dispatcher.hpp +++ b/include/boost/numeric/odeint/external/thrust/thrust_operations_dispatcher.hpp @@ -6,8 +6,8 @@ operations_dispatcher specialization for thrust [end_description] - Copyright 2013 Karsten Ahnert - Copyright 2013 Mario Mulansky + Copyright 2013-2014 Karsten Ahnert + Copyright 2013-2014 Mario Mulansky Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or @@ -24,6 +24,7 @@ #include #include +// support for the standard thrust containers namespace boost { namespace numeric { @@ -47,6 +48,60 @@ struct operations_dispatcher< thrust::device_vector< T , A > > } // namespace numeric } // namespace boost +// add support for thrust backend vectors, if available -#endif // BOOST_NUMERIC_ODEINT_EXTERNAL_THRUST_THRUST_ALGEBRA_DISPATCHER_HPP_DEFINED +#include + +#if THRUST_VERSION >= 100600 + +// specialization for thrust cpp vector +#include +namespace boost { namespace numeric { namespace odeint { + template< class T , class A > + struct operations_dispatcher< thrust::cpp::vector< T , A > > + { + typedef thrust_operations operations_type; + }; +} } } + +// specialization for thrust omp vector +#ifdef _OPENMP +#include +namespace boost { namespace numeric { namespace odeint { + template< class T , class A > + struct operations_dispatcher< thrust::omp::vector< T , A > > + { + typedef thrust_operations operations_type; + }; +} } } +#endif // _OPENMP + +// specialization for thrust tbb vector +#ifdef TBB_VERSION_MAJOR +#include +namespace boost { namespace numeric { namespace odeint { + template< class T , class A > + struct operations_dispatcher< thrust::tbb::vector< T , A > > + { + typedef thrust_operations operations_type; + }; +} } } +#endif // TBB_VERSION_MAJOR + +// specialization for thrust cuda vector +#ifdef __CUDACC__ +#include +namespace boost { namespace numeric { namespace odeint { + template< class T , class A > + struct operations_dispatcher< thrust::cuda::vector< T , A > > + { + typedef thrust_operations operations_type; + }; +} } } +#endif // __CUDACC__ + +#endif // THRUST_VERSION >= 100600 + + +#endif // BOOST_NUMERIC_ODEINT_EXTERNAL_THRUST_THRUST_OPERATIONS_DISPATCHER_HPP_DEFINED From 0ca187cd6e83ddbaa5eedaa5d0d570986f351263 Mon Sep 17 00:00:00 2001 From: mariomulansky Date: Fri, 15 Aug 2014 09:44:56 +0200 Subject: [PATCH 16/70] added unnamed namespace around placeholders addressing #138 --- include/boost/numeric/odeint/util/bind.hpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/boost/numeric/odeint/util/bind.hpp b/include/boost/numeric/odeint/util/bind.hpp index 966fd039..1201afab 100644 --- a/include/boost/numeric/odeint/util/bind.hpp +++ b/include/boost/numeric/odeint/util/bind.hpp @@ -41,9 +41,12 @@ using namespace ::std::placeholders; #else +// unnamed namespace to avoid multiple declarations (#138) +namespace { using ::boost::bind; boost::arg<1> _1; boost::arg<2> _2; +} // using ::boost::bind; // using ::_1; // using ::_2; From 87dae441efccea10526c63b6f5bfbf5712a4d009 Mon Sep 17 00:00:00 2001 From: Karsten Ahnert Date: Sat, 16 Aug 2014 14:12:08 +0200 Subject: [PATCH 17/70] removing old include from external test jamfiles, adding nounused local typedef warning, adding newline to toolset.jam.patch --- Jamroot | 4 ++-- include/boost/numeric/odeint/integrate/integrate.hpp | 9 +++++++++ test_external/eigen/Jamfile.v2 | 2 -- test_external/gmp/Jamfile.v2 | 1 - test_external/gsl/Jamfile.v2 | 1 - test_external/mkl/Jamfile.v2 | 1 - test_external/mpi/Jamfile.v2 | 1 - test_external/mtl4/Jamfile.v2 | 1 - test_external/nt2/Jamfile.v2 | 1 - test_external/vexcl/Jamfile.v2 | 1 - toolset.jam.patch | 2 +- 11 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Jamroot b/Jamroot index 09f5384e..48384e3c 100644 --- a/Jamroot +++ b/Jamroot @@ -14,8 +14,8 @@ path-constant BOOST_ROOT : [ os.environ BOOST_ROOT ] ; project : requirements include&&$(BOOST_ROOT) - gcc:"-Wall -Wno-unused-parameter -Wno-unused-variable -Wno-unknown-pragmas" - clang:"-Wall -Wextra -Wno-unused-function -Wno-unused-parameter -Wno-unknown-pragmas" + gcc:"-Wall -Wno-unused-parameter -Wno-unused-variable -Wno-unknown-pragmas -Wno-unused-local-typedefs" + clang:"-Wall -Wextra -Wno-unused-function -Wno-unused-parameter -Wno-unknown-pragmas -Wno-unused-local-typedefs" intel:"-ipo" ; diff --git a/include/boost/numeric/odeint/integrate/integrate.hpp b/include/boost/numeric/odeint/integrate/integrate.hpp index 6cb96c0f..c02278a2 100644 --- a/include/boost/numeric/odeint/integrate/integrate.hpp +++ b/include/boost/numeric/odeint/integrate/integrate.hpp @@ -48,6 +48,15 @@ integrate( System system , State &start_state , Time start_time , Time end_time return integrate_adaptive( stepper_type() , system , start_state , start_time , end_time , dt , observer ); } +template< class System , class State , class Time , class Observer , class Value > +size_t +integrate( System system , State &start_state , Time start_time , Time end_time , Time dt , Observer observer ) +{ + typedef controlled_runge_kutta< runge_kutta_dopri5< State , Value , State , Time > > stepper_type; + return integrate_adaptive( stepper_type() , system , start_state , start_time , end_time , dt , observer ); +} + + /* diff --git a/test_external/eigen/Jamfile.v2 b/test_external/eigen/Jamfile.v2 index 47b3a881..b508a0ea 100644 --- a/test_external/eigen/Jamfile.v2 +++ b/test_external/eigen/Jamfile.v2 @@ -17,10 +17,8 @@ project : requirements /boost/test//boost_unit_test_framework BOOST_ALL_NO_LIB=1 - ../../../../.. $(EIGEN_ROOT) static - clang:-Wno-unused-variable # -D_SCL_SECURE_NO_WARNINGS ; diff --git a/test_external/gmp/Jamfile.v2 b/test_external/gmp/Jamfile.v2 index e4e60328..f0e6af02 100644 --- a/test_external/gmp/Jamfile.v2 +++ b/test_external/gmp/Jamfile.v2 @@ -11,7 +11,6 @@ use-project boost : $(BOOST_ROOT) ; project gmp : requirements /boost/test//boost_unit_test_framework - ../../../../.. ; diff --git a/test_external/gsl/Jamfile.v2 b/test_external/gsl/Jamfile.v2 index 73595d30..086edf6e 100644 --- a/test_external/gsl/Jamfile.v2 +++ b/test_external/gsl/Jamfile.v2 @@ -11,7 +11,6 @@ use-project boost : $(BOOST_ROOT) ; project : requirements /boost/test//boost_unit_test_framework - ../../../../.. ; diff --git a/test_external/mkl/Jamfile.v2 b/test_external/mkl/Jamfile.v2 index 168d69c4..f585fa83 100644 --- a/test_external/mkl/Jamfile.v2 +++ b/test_external/mkl/Jamfile.v2 @@ -11,7 +11,6 @@ use-project boost : $(BOOST_ROOT) ; project : requirements /boost/test//boost_unit_test_framework - ../../../../.. ; diff --git a/test_external/mpi/Jamfile.v2 b/test_external/mpi/Jamfile.v2 index bb14ff57..0a02bccf 100644 --- a/test_external/mpi/Jamfile.v2 +++ b/test_external/mpi/Jamfile.v2 @@ -15,7 +15,6 @@ project /boost//mpi static BOOST_ALL_NO_LIB=1 - ../../../../.. ; # mpi-test name : source : req : np=1 2 3 4 7 8 13 17 diff --git a/test_external/mtl4/Jamfile.v2 b/test_external/mtl4/Jamfile.v2 index c85c97fb..3a8481ab 100644 --- a/test_external/mtl4/Jamfile.v2 +++ b/test_external/mtl4/Jamfile.v2 @@ -15,7 +15,6 @@ MTL4_INCLUDE = /home/mario/MTL4 ; project : requirements /boost/test//boost_unit_test_framework - ../../../../.. $(MTL4_INCLUDE) BOOST_ALL_NO_LIB=1 static diff --git a/test_external/nt2/Jamfile.v2 b/test_external/nt2/Jamfile.v2 index 9f9b142f..26763da6 100644 --- a/test_external/nt2/Jamfile.v2 +++ b/test_external/nt2/Jamfile.v2 @@ -26,7 +26,6 @@ project : requirements $(BOOST_ROOT)/boost/test/included/unit_test_framework.hpp BOOST_ALL_NO_LIB=1 - ../../../../.. $(NT2_ROOT_PATH)/include/ static gcc:-DBOOST_SIMD_NO_STRICT_ALIASING diff --git a/test_external/vexcl/Jamfile.v2 b/test_external/vexcl/Jamfile.v2 index dec9da63..9b76b430 100644 --- a/test_external/vexcl/Jamfile.v2 +++ b/test_external/vexcl/Jamfile.v2 @@ -17,7 +17,6 @@ project : requirements /boost/test//boost_unit_test_framework BOOST_ALL_NO_LIB=1 - ../../../../.. $(VEXCL_INCLUDE) $(OPENCL_INCLUDE) -std=c++0x diff --git a/toolset.jam.patch b/toolset.jam.patch index 50268e72..dca997d5 100644 --- a/toolset.jam.patch +++ b/toolset.jam.patch @@ -58,4 +58,4 @@ index b5defd5..a942cd9 100644 + } } else - { \ No newline at end of file + { From 55c843b5dc1a56d9b8e327cb1d129757fdac82d2 Mon Sep 17 00:00:00 2001 From: Karsten Ahnert Date: Sat, 16 Aug 2014 14:13:42 +0200 Subject: [PATCH 18/70] removing old include from external example jamfiles --- examples/mpi/Jamfile.v2 | 1 - examples/mtl/Jamfile.v2 | 1 - examples/multiprecision/Jamfile | 1 - examples/nt2/Jamfile.v2 | 1 - examples/openmp/Jamfile.v2 | 1 - examples/quadmath/Jamfile.v2 | 1 - examples/ublas/Jamfile.v2 | 1 - examples/vexcl/Jamfile.v2 | 1 - 8 files changed, 8 deletions(-) diff --git a/examples/mpi/Jamfile.v2 b/examples/mpi/Jamfile.v2 index 6aaeb0e8..d3f18eb2 100644 --- a/examples/mpi/Jamfile.v2 +++ b/examples/mpi/Jamfile.v2 @@ -7,7 +7,6 @@ project : requirements - ../../../../.. BOOST_ALL_NO_LIB=1 /boost//mpi /boost//timer diff --git a/examples/mtl/Jamfile.v2 b/examples/mtl/Jamfile.v2 index bd2ec3ca..9f4ffb0f 100644 --- a/examples/mtl/Jamfile.v2 +++ b/examples/mtl/Jamfile.v2 @@ -9,7 +9,6 @@ MTL4_INCLUDE = /home/mario/MTL4 ; project : requirements - ../../../../.. $(MTL4_INCLUDE) BOOST_ALL_NO_LIB=1 ; diff --git a/examples/multiprecision/Jamfile b/examples/multiprecision/Jamfile index dc6fee89..9708d434 100644 --- a/examples/multiprecision/Jamfile +++ b/examples/multiprecision/Jamfile @@ -7,7 +7,6 @@ project : requirements - ../../../../.. BOOST_ALL_NO_LIB=1 : ; diff --git a/examples/nt2/Jamfile.v2 b/examples/nt2/Jamfile.v2 index 539ed1b7..05847cd1 100644 --- a/examples/nt2/Jamfile.v2 +++ b/examples/nt2/Jamfile.v2 @@ -24,7 +24,6 @@ local NT2_SIMD_FLAGS = [ os.environ NT2_SIMD_FLAGS ] ; project : requirements BOOST_ALL_NO_LIB=1 - ../../../../.. $(NT2_ROOT_PATH)/include/ static gcc:-DBOOST_SIMD_NO_STRICT_ALIASING diff --git a/examples/openmp/Jamfile.v2 b/examples/openmp/Jamfile.v2 index c80aaa1b..cef4f670 100644 --- a/examples/openmp/Jamfile.v2 +++ b/examples/openmp/Jamfile.v2 @@ -10,7 +10,6 @@ import openmp : * ; project : requirements - ../../../../.. .. BOOST_ALL_NO_LIB=1 /boost//timer diff --git a/examples/quadmath/Jamfile.v2 b/examples/quadmath/Jamfile.v2 index 9b994b78..88a04632 100644 --- a/examples/quadmath/Jamfile.v2 +++ b/examples/quadmath/Jamfile.v2 @@ -7,7 +7,6 @@ project : requirements - ../../../.. BOOST_ALL_NO_LIB=1 : ; diff --git a/examples/ublas/Jamfile.v2 b/examples/ublas/Jamfile.v2 index 41f8f66f..7abff98e 100644 --- a/examples/ublas/Jamfile.v2 +++ b/examples/ublas/Jamfile.v2 @@ -7,7 +7,6 @@ project : requirements - ../../../../.. BOOST_ALL_NO_LIB=1 ; diff --git a/examples/vexcl/Jamfile.v2 b/examples/vexcl/Jamfile.v2 index b02586e7..31ab4c1d 100644 --- a/examples/vexcl/Jamfile.v2 +++ b/examples/vexcl/Jamfile.v2 @@ -23,7 +23,6 @@ lib opencl : : OpenCL ; project : requirements /boost//headers - ../../../../.. $(VEXCL_INCLUDE) $(OPENCL_INCLUDE) gcc:-std=c++0x From 9197519a2dc80edf67a906449fb4f4b938efca79 Mon Sep 17 00:00:00 2001 From: Karsten Ahnert Date: Sat, 16 Aug 2014 14:14:23 +0200 Subject: [PATCH 19/70] removing old include from example jamfile --- examples/Jamfile.v2 | 1 - test/Jamfile.v2 | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/examples/Jamfile.v2 b/examples/Jamfile.v2 index c0f80e5a..04556879 100644 --- a/examples/Jamfile.v2 +++ b/examples/Jamfile.v2 @@ -8,7 +8,6 @@ project : requirements - ../../../.. BOOST_ALL_NO_LIB=1 : ; diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index f8988662..e9b721a4 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -17,7 +17,7 @@ project BOOST_ALL_NO_LIB=1 static clang:-Wno-unused-variable -# -D_SCL_SECURE_NO_WARNINGS + # -D_SCL_SECURE_NO_WARNINGS ; test-suite "odeint" From 720a926e45f8344582227ce351c8205feaa3812a Mon Sep 17 00:00:00 2001 From: Karsten Ahnert Date: Sat, 16 Aug 2014 21:05:16 +0200 Subject: [PATCH 20/70] fixes #139 --- .../numeric/odeint/external/eigen/eigen.hpp | 27 ++++++++ .../odeint/external/eigen/eigen_algebra.hpp | 13 ++++ .../eigen/eigen_algebra_dispatcher.hpp | 49 +++++++++++++ .../numeric/odeint/integrate/integrate.hpp | 9 ++- test/dummy_odes.hpp | 14 ++++ test_external/eigen/Jamfile.v2 | 3 + test_external/eigen/fail_integrate.cpp | 47 +++++++++++++ test_external/eigen/integrate.cpp | 69 +++++++++++++++++++ 8 files changed, 230 insertions(+), 1 deletion(-) create mode 100644 include/boost/numeric/odeint/external/eigen/eigen.hpp create mode 100644 include/boost/numeric/odeint/external/eigen/eigen_algebra_dispatcher.hpp create mode 100644 test_external/eigen/fail_integrate.cpp create mode 100644 test_external/eigen/integrate.cpp diff --git a/include/boost/numeric/odeint/external/eigen/eigen.hpp b/include/boost/numeric/odeint/external/eigen/eigen.hpp new file mode 100644 index 00000000..620acae5 --- /dev/null +++ b/include/boost/numeric/odeint/external/eigen/eigen.hpp @@ -0,0 +1,27 @@ +/* + [auto_generated] + boost/numeric/odeint/external/eigen/eigen.hpp + + [begin_description] + tba. + [end_description] + + Copyright 2009-2012 Karsten Ahnert + Copyright 2009-2012 Mario Mulansky + + Distributed under the Boost Software License, Version 1.0. + (See accompanying file LICENSE_1_0.txt or + copy at http://www.boost.org/LICENSE_1_0.txt) +*/ + + +#ifndef BOOST_NUMERIC_ODEINT_EXTERNAL_EIGEN_EIGEN_HPP_INCLUDED +#define BOOST_NUMERIC_ODEINT_EXTERNAL_EIGEN_EIGEN_HPP_INCLUDED + + +#include +#include +#include + + +#endif // BOOST_NUMERIC_ODEINT_EXTERNAL_EIGEN_EIGEN_HPP_INCLUDED diff --git a/include/boost/numeric/odeint/external/eigen/eigen_algebra.hpp b/include/boost/numeric/odeint/external/eigen/eigen_algebra.hpp index 6ca2026b..b4ee5c3b 100644 --- a/include/boost/numeric/odeint/external/eigen/eigen_algebra.hpp +++ b/include/boost/numeric/odeint/external/eigen/eigen_algebra.hpp @@ -71,6 +71,19 @@ operator/(const Eigen::MatrixBase &x1, const Eigen::MatrixBase &x2) { return x1.cwiseQuotient(x2); } + +template< typename D > +inline const +typename Eigen::CwiseUnaryOp< + typename Eigen::internal::scalar_abs_op< + typename Eigen::internal::traits< D >::Scalar > , + const D > +abs( const Eigen::MatrixBase< D > &m ) { + return m.cwiseAbs(); +} + + + } // end Eigen namespace diff --git a/include/boost/numeric/odeint/external/eigen/eigen_algebra_dispatcher.hpp b/include/boost/numeric/odeint/external/eigen/eigen_algebra_dispatcher.hpp new file mode 100644 index 00000000..6c8a3a27 --- /dev/null +++ b/include/boost/numeric/odeint/external/eigen/eigen_algebra_dispatcher.hpp @@ -0,0 +1,49 @@ +/* + [auto_generated] + boost/numeric/odeint/external/eigen/eigen_algebra_dispatcher.hpp + + [begin_description] + tba. + [end_description] + + Copyright 2009-2012 Karsten Ahnert + Copyright 2009-2012 Mario Mulansky + + Distributed under the Boost Software License, Version 1.0. + (See accompanying file LICENSE_1_0.txt or + copy at http://www.boost.org/LICENSE_1_0.txt) +*/ + + +#ifndef BOOST_NUMERIC_ODEINT_EXTERNAL_EIGEN_EIGEN_ALGEBRA_DISPATCHER_HPP_INCLUDED +#define BOOST_NUMERIC_ODEINT_EXTERNAL_EIGEN_EIGEN_ALGEBRA_DISPATCHER_HPP_INCLUDED + + +namespace boost { +namespace numeric { +namespace odeint { + + +template< class Derived > +struct algebra_dispatcher_sfinae< Derived , + typename boost::enable_if< typename boost::is_base_of< Eigen::MatrixBase< Derived > , Derived >::type >::type > +{ + typedef vector_space_algebra algebra_type; +}; + + +template < class Derived > +struct algebra_dispatcher_sfinae< Derived , + typename boost::enable_if< typename boost::is_base_of< Eigen::ArrayBase< Derived > , Derived >::type >::type > +{ + typedef vector_space_algebra algebra_type; +}; + + + +} // namespace odeint +} // namespace numeric +} // namespace boost + + +#endif // BOOST_NUMERIC_ODEINT_EXTERNAL_EIGEN_EIGEN_ALGEBRA_DISPATCHER_HPP_INCLUDED diff --git a/include/boost/numeric/odeint/integrate/integrate.hpp b/include/boost/numeric/odeint/integrate/integrate.hpp index c02278a2..913f1ca1 100644 --- a/include/boost/numeric/odeint/integrate/integrate.hpp +++ b/include/boost/numeric/odeint/integrate/integrate.hpp @@ -48,7 +48,7 @@ integrate( System system , State &start_state , Time start_time , Time end_time return integrate_adaptive( stepper_type() , system , start_state , start_time , end_time , dt , observer ); } -template< class System , class State , class Time , class Observer , class Value > +template< class Value , class System , class State , class Time , class Observer > size_t integrate( System system , State &start_state , Time start_time , Time end_time , Time dt , Observer observer ) { @@ -68,6 +68,13 @@ size_t integrate( System system , State &start_state , Time start_time , Time en return integrate( system , start_state , start_time , end_time , dt , null_observer() ); } +template< class Value , class System , class State , class Time > +size_t integrate( System system , State &start_state , Time start_time , Time end_time , Time dt ) +{ + return integrate< Value >( system , start_state , start_time , end_time , dt , null_observer() ); +} + + /** * \fn integrate( System system , State &start_state , Time start_time , Time end_time , Time dt , Observer observer ) diff --git a/test/dummy_odes.hpp b/test/dummy_odes.hpp index 0797b276..7a92363f 100644 --- a/test/dummy_odes.hpp +++ b/test/dummy_odes.hpp @@ -55,6 +55,20 @@ struct constant_system_functor_fusion } }; +struct lorenz +{ + template< typename State , typename Deriv , typename Time > + void operator()( const State& x , Deriv& dxdt , const Time& t ) const + { + const Time sigma = 10.0; + const Time R = 28.0; + const Time 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] = -b * x[2] + x[0] * x[1]; + } +}; + template< class State , class Deriv , class Time > void constant_system_standard( const State &x , Deriv &dxdt , const Time t ) { diff --git a/test_external/eigen/Jamfile.v2 b/test_external/eigen/Jamfile.v2 index b508a0ea..489f67ce 100644 --- a/test_external/eigen/Jamfile.v2 +++ b/test_external/eigen/Jamfile.v2 @@ -18,6 +18,7 @@ project /boost/test//boost_unit_test_framework BOOST_ALL_NO_LIB=1 $(EIGEN_ROOT) + ../../test static # -D_SCL_SECURE_NO_WARNINGS ; @@ -29,5 +30,7 @@ test-suite "odeint" [ run resize.cpp ] [ run runge_kutta4.cpp ] [ run runge_kutta_dopri5.cpp ] + [ run integrate.cpp ] + [ compile-fail fail_integrate.cpp ] : valgrind ; diff --git a/test_external/eigen/fail_integrate.cpp b/test_external/eigen/fail_integrate.cpp new file mode 100644 index 00000000..4c71b018 --- /dev/null +++ b/test_external/eigen/fail_integrate.cpp @@ -0,0 +1,47 @@ +/* + [auto_generated] + fail_integrate.cpp + + [begin_description] + tba. + [end_description] + + Copyright 2009-2012 Karsten Ahnert + Copyright 2009-2012 Mario Mulansky + + Distributed under the Boost Software License, Version 1.0. + (See accompanying file LICENSE_1_0.txt or + copy at http://www.boost.org/LICENSE_1_0.txt) + */ + +#include +#ifdef BOOST_MSVC + #pragma warning(disable:4996) +#endif + +#define BOOST_TEST_MODULE odeint_dummy + +#include +#include + +#include + +#include "dummy_odes.hpp" + +using namespace boost::unit_test; +using namespace boost::numeric::odeint; + + +BOOST_AUTO_TEST_SUITE( eigen_fail_integrate ) + +BOOST_AUTO_TEST_CASE( test ) +{ + typedef Eigen::Matrix< double , 1 , 1 > state_type; + state_type x; + x[0] = 10.0; + double t_start = 0.0 , t_end = 1.0 , dt = 0.1; + integrate( constant_system_functor_standard() , x , t_start , t_end , dt ); +} + +BOOST_AUTO_TEST_SUITE_END() + diff --git a/test_external/eigen/integrate.cpp b/test_external/eigen/integrate.cpp new file mode 100644 index 00000000..c64496a8 --- /dev/null +++ b/test_external/eigen/integrate.cpp @@ -0,0 +1,69 @@ +/* + [auto_generated] + integrate.cpp + + [begin_description] + tba. + [end_description] + + Copyright 2009-2012 Karsten Ahnert + Copyright 2009-2012 Mario Mulansky + + Distributed under the Boost Software License, Version 1.0. + (See accompanying file LICENSE_1_0.txt or + copy at http://www.boost.org/LICENSE_1_0.txt) + */ + +#include +#ifdef BOOST_MSVC + #pragma warning(disable:4996) +#endif + +#define BOOST_TEST_MODULE odeint_eigen_integrate + +#include +#include + +#include + +#include "dummy_odes.hpp" + + +using namespace boost::unit_test; +using namespace boost::numeric::odeint; + + +BOOST_AUTO_TEST_SUITE( eigen_integrate ) + +BOOST_AUTO_TEST_CASE( test_const_sys ) +{ + typedef Eigen::Matrix< double , 1 , 1 > state_type; + state_type x; + x[0] = 10.0; + double t_start = 0.0 , t_end = 1.0 , dt = 0.1; + integrate< double >( constant_system_functor_standard() , x , t_start , t_end , dt ); + BOOST_CHECK_CLOSE( x[0] , 11.0 , 1.0e-13 ); +} + +BOOST_AUTO_TEST_CASE( test_lorenz ) +{ + typedef Eigen::Matrix< double , 3 , 1 > state_type; + state_type x; + x[0] = 10.0; + x[1] = 10.0; + x[2] = 10.0; + double t_start = 0.0 , t_end = 1000.0 , dt = 0.1; + integrate< double >( lorenz() , x , t_start , t_end , dt ); + + std::vector< double > x2( 3 ); + x2[0] = 10.0; + x2[1] = 10.0; + x2[2] = 10.0; + integrate( lorenz() , x2 , t_start , t_end , dt ); + + BOOST_CHECK_CLOSE( x[0] , x2[0] , 1.0e-13 ); + BOOST_CHECK_CLOSE( x[1] , x2[1] , 1.0e-13 ); + BOOST_CHECK_CLOSE( x[2] , x2[2] , 1.0e-13 ); +} + +BOOST_AUTO_TEST_SUITE_END() From b497ca56de10993f2ef9de2345cf61bda4bae8ec Mon Sep 17 00:00:00 2001 From: Karsten Ahnert Date: Sat, 16 Aug 2014 21:07:35 +0200 Subject: [PATCH 21/70] adding documentation for second integrate version --- include/boost/numeric/odeint/integrate/integrate.hpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/include/boost/numeric/odeint/integrate/integrate.hpp b/include/boost/numeric/odeint/integrate/integrate.hpp index 913f1ca1..446656b5 100644 --- a/include/boost/numeric/odeint/integrate/integrate.hpp +++ b/include/boost/numeric/odeint/integrate/integrate.hpp @@ -86,6 +86,9 @@ size_t integrate( System system , State &start_state , Time start_time , Time en * integration with step size control, thus dt changes during the integration. * This method uses standard error bounds of 1E-6. * After each step, the observer is called. + * + * \attention A second version of this function template exists which explicitly + * expects the value type as template parameter, i.e. integrate< double >( sys , x , t0 , t1 , dt , obs ); * * \param system The system function to solve, hence the r.h.s. of the * ordinary differential equation. @@ -108,6 +111,9 @@ size_t integrate( System system , State &start_state , Time start_time , Time en * integration with step size control, thus dt changes during the integration. * This method uses standard error bounds of 1E-6. * No observer is called. + * + * \attention A second version of this function template exists which explicitly + * expects the value type as template parameter, i.e. integrate< double >( sys , x , t0 , t1 , dt ); * * \param system The system function to solve, hence the r.h.s. of the * ordinary differential equation. From 5eebbb56d820295530f37531dcdf59c0274d687a Mon Sep 17 00:00:00 2001 From: Karsten Ahnert Date: Mon, 18 Aug 2014 21:00:12 +0200 Subject: [PATCH 22/70] fixing #140 --- include/boost/numeric/odeint/stepper/bulirsch_stoer.hpp | 5 ++--- .../numeric/odeint/stepper/bulirsch_stoer_dense_out.hpp | 3 +-- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/include/boost/numeric/odeint/stepper/bulirsch_stoer.hpp b/include/boost/numeric/odeint/stepper/bulirsch_stoer.hpp index b604f86a..1ce92341 100644 --- a/include/boost/numeric/odeint/stepper/bulirsch_stoer.hpp +++ b/include/boost/numeric/odeint/stepper/bulirsch_stoer.hpp @@ -194,7 +194,6 @@ public: static const value_type val1( 1.0 ); - typename odeint::unwrap_reference< System >::type &sys = system; if( m_resizer.adjust_size( in , detail::bind( &controlled_error_bs_type::template resize_impl< StateIn > , detail::ref( *this ) , detail::_1 ) ) ) { reset(); // system resized -> reset @@ -219,12 +218,12 @@ public: m_midpoint.set_steps( m_interval_sequence[k] ); if( k == 0 ) { - m_midpoint.do_step( sys , in , dxdt , t , out , dt ); + m_midpoint.do_step( system , in , dxdt , t , out , dt ); /* the first step, nothing more to do */ } else { - m_midpoint.do_step( sys , in , dxdt , t , m_table[k-1].m_v , dt ); + m_midpoint.do_step( system , in , dxdt , t , m_table[k-1].m_v , dt ); extrapolate( k , m_table , m_coeff , out ); // get error estimate m_algebra.for_each3( m_err.m_v , out , m_table[0].m_v , diff --git a/include/boost/numeric/odeint/stepper/bulirsch_stoer_dense_out.hpp b/include/boost/numeric/odeint/stepper/bulirsch_stoer_dense_out.hpp index c352c960..01a7d120 100644 --- a/include/boost/numeric/odeint/stepper/bulirsch_stoer_dense_out.hpp +++ b/include/boost/numeric/odeint/stepper/bulirsch_stoer_dense_out.hpp @@ -155,8 +155,6 @@ public: static const value_type val1( 1.0 ); - typename odeint::unwrap_reference< System >::type &sys = system; - bool reject( true ); time_vector h_opt( m_k_max+1 ); @@ -261,6 +259,7 @@ public: { //calculate dxdt for next step and dense output + typename odeint::unwrap_reference< System >::type &sys = system; sys( out , dxdt_new , t+dt ); //prepare dense output From bc05380cc536c975d2ad04932413798c5d2d354b Mon Sep 17 00:00:00 2001 From: Mario Mulansky Date: Fri, 19 Sep 2014 19:53:51 +0200 Subject: [PATCH 23/70] added appveyor build script --- appveyor.yml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 appveyor.yml diff --git a/appveyor.yml b/appveyor.yml new file mode 100644 index 00000000..e430b841 --- /dev/null +++ b/appveyor.yml @@ -0,0 +1,17 @@ +clone_depth: 5 +#shallow_clone: true +clone_folder: c:\projects\odeint-v2 + +branches: + only: + - master + +configuration: Release + +environment: + BOOST_ROOT: c:\Libraries\boost + BOOST_LIBRARYDIR: c:\Libraries\boost\stage\lib + BUILD_TYPE: Release + +test_script: + - $BOOST_ROOT\b2 \ No newline at end of file From 698d624792bb1228c8e451942d3db0b588e1e531 Mon Sep 17 00:00:00 2001 From: Mario Mulansky Date: Fri, 19 Sep 2014 20:14:03 +0200 Subject: [PATCH 24/70] delete appvoyer config --- appveyor.yml | 17 ----------------- 1 file changed, 17 deletions(-) delete mode 100644 appveyor.yml diff --git a/appveyor.yml b/appveyor.yml deleted file mode 100644 index e430b841..00000000 --- a/appveyor.yml +++ /dev/null @@ -1,17 +0,0 @@ -clone_depth: 5 -#shallow_clone: true -clone_folder: c:\projects\odeint-v2 - -branches: - only: - - master - -configuration: Release - -environment: - BOOST_ROOT: c:\Libraries\boost - BOOST_LIBRARYDIR: c:\Libraries\boost\stage\lib - BUILD_TYPE: Release - -test_script: - - $BOOST_ROOT\b2 \ No newline at end of file From cc6969cca52135b388333763e243ea483964d374 Mon Sep 17 00:00:00 2001 From: Mario Mulansky Date: Tue, 7 Oct 2014 13:00:20 +0200 Subject: [PATCH 25/70] fixing #141 --- examples/thrust/Makefile | 58 +++++-------------- .../odeint/external/thrust/thrust_resize.hpp | 28 ++++++++- 2 files changed, 39 insertions(+), 47 deletions(-) diff --git a/examples/thrust/Makefile b/examples/thrust/Makefile index 2c47503c..5a33bdb3 100644 --- a/examples/thrust/Makefile +++ b/examples/thrust/Makefile @@ -1,66 +1,34 @@ -# Copyright 2011-2013 Mario Mulansky +# Copyright 2011-2014 Mario Mulansky # Copyright 2011-2012 Karsten Ahnert # # Distributed under the Boost Software License, Version 1.0. # (See accompanying file LICENSE_1_0.txt or # copy at http://www.boost.org/LICENSE_1_0.txt) +# make sure BOOST_ROOT is pointing to your boost directory +# otherwise, set it here: +# BOOST_ROOT = /path/to/boost - -# CUDA_ROOT = /home/karsten/boost/cuda4.1/cuda/ +# path to the cuda installation CUDA_ROOT = /usr/local/cuda +# target architecture ARCH = sm_13 -CC = gcc -CXX = g++ NVCC = $(CUDA_ROOT)/bin/nvcc -# NVCC = g++ -INCLUDES += -I../../include/ -I$(BOOST_ROOT) -I$(CUDA_ROOT)/include +INCLUDES += -I../../include/ -I$(BOOST_ROOT) -NVCCFLAGS = -O3 $(INCLUDES) -arch $(ARCH) --compiler-bindir=/opt/gcc4.6.2/bin/ -Xcompiler -fopenmp -DTHRUST_DEVICE_BACKEND=THRUST_DEVICE_BACKEND_OMP -# NVCCFLAGS = -O3 $(INCLUDES) -arch $(ARCH) --compiler-bindir=/usr/bin/g++-4.3 -Xcompiler -fopenmp -DTHRUST_DEVICE_BACKEND=THRUST_DEVICE_BACKEND_OMP +NVCCFLAGS = -O3 $(INCLUDES) -arch $(ARCH) -# NVCCFLAGS = -O3 $(INCLUDES) -arch $(ARCH) --compiler-bindir=/usr/bin/g++-4.3 - -#--compiler-bindir=/usr/bin/g++-4.4 -#-Xcompiler -fopenmp -DTHRUST_DEVICE_BACKEND=THRUST_DEVICE_BACKEND_OMP -# NVCCFLAGS = -O3 $(INCLUDES) -arch $(ARCH) --compiler-bindir=/usr/bin/g++-4.3 -#-Xcompiler -fopenmp -DTHRUST_DEVICE_BACKEND=THRUST_DEVICE_BACKEND_OMP - - -LDLIBS = -lstdc++ -lm -lcudart -lgomp -LDFLAGS = -L$(CUDA_ROOT)/lib64 - -%.co : %.cu +%.o : %.cu $(NVCC) $(NVCCFLAGS) -c $< -o $@ +% : %.o + $(NVCC) $(NVCCFLAGS) -o $@ $< + all : phase_oscillator_chain phase_oscillator_ensemble lorenz_parameters relaxation -phase_oscillator_chain.co : phase_oscillator_chain.cu -phase_oscillator_chain : phase_oscillator_chain.co - $(CC) -o phase_oscillator_chain $(LDFLAGS) $(LDLIBS) phase_oscillator_chain.co - - - -phase_oscillator_ensemble.co : phase_oscillator_ensemble.cu -phase_oscillator_ensemble : phase_oscillator_ensemble.co - $(CC) -o phase_oscillator_ensemble $(LDFLAGS) $(LDLIBS) phase_oscillator_ensemble.co - - - -lorenz_parameters : lorenz_parameters.co - $(CC) -o lorenz_parameters $(LDFLAGS) $(LDLIBS) lorenz_parameters.co -lorenz_parameters.co : lorenz_parameters.cu - - -relaxation : relaxation.co - $(CC) -o relaxation $(LDFLAGS) $(LDLIBS) relaxation.co -relaxation.co : relaxation.cu - - - clean : - -rm *~ *.o *.co phase_oscillator_chain phase_oscillator_ensemble lorenz_parameters relaxation + -rm *~ *.o phase_oscillator_chain phase_oscillator_ensemble lorenz_parameters relaxation diff --git a/include/boost/numeric/odeint/external/thrust/thrust_resize.hpp b/include/boost/numeric/odeint/external/thrust/thrust_resize.hpp index dc87ae2c..2f7f7b23 100644 --- a/include/boost/numeric/odeint/external/thrust/thrust_resize.hpp +++ b/include/boost/numeric/odeint/external/thrust/thrust_resize.hpp @@ -6,7 +6,7 @@ Enable resizing for thrusts device and host_vector. [end_description] - Copyright 2010-2012 Mario Mulansky + Copyright 2010-2014 Mario Mulansky Copyright 2010-2011 Karsten Ahnert Distributed under the Boost Software License, Version 1.0. @@ -18,9 +18,11 @@ #ifndef BOOST_NUMERIC_ODEINT_EXTERNAL_THRUST_THRUST_RESIZE_HPP_INCLUDED #define BOOST_NUMERIC_ODEINT_EXTERNAL_THRUST_THRUST_RESIZE_HPP_INCLUDED +#include #include #include +#include #include #include @@ -50,6 +52,17 @@ struct resize_impl< THRUST_VECTOR , THRUST_VECTOR > \ x.resize( y.size() ); \ } \ }; \ +template< class T, class A, typename Range > \ +struct resize_impl< THRUST_VECTOR , Range > \ +{ \ + static void resize( THRUST_VECTOR &x , \ + const Range &y ) \ + { \ + x.resize( thrust::distance(boost::begin(y), \ + boost::end(y))); \ + } \ +}; \ + #define ODEINT_THRUST_SAME_SIZE_IMPL( THRUST_VECTOR ) \ template< class T , class A > \ @@ -60,7 +73,18 @@ struct same_size_impl< THRUST_VECTOR , THRUST_VECTOR > \ { \ return x.size() == y.size(); \ } \ -}; +}; \ +template< class T , class A, typename Range > \ +struct same_size_impl< THRUST_VECTOR , Range > \ +{ \ + static bool same_size( const THRUST_VECTOR &x , \ + const Range &y ) \ + { \ + return x.size() == thrust::distance(boost::begin(y), \ + boost::end(y)); \ + } \ +}; \ + #define ODEINT_THRUST_COPY_IMPL( THRUST_VECTOR ) \ template< class Container1 , class T , class A > \ From f496df36824b730f7e89daf1a85d5a3ce6095563 Mon Sep 17 00:00:00 2001 From: Mario Mulansky Date: Tue, 7 Oct 2014 13:07:18 +0200 Subject: [PATCH 26/70] cleaned up thrust Makefile --- test_external/thrust/Makefile | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/test_external/thrust/Makefile b/test_external/thrust/Makefile index cd6527ba..49d9cd71 100644 --- a/test_external/thrust/Makefile +++ b/test_external/thrust/Makefile @@ -1,36 +1,34 @@ -# Copyright 2010-2013 Mario Mulansky +# Copyright 2010-2014 Mario Mulansky # Copyright 2010-2012 Karsten Ahnert # # Distributed under the Boost Software License, Version 1.0. # (See accompanying file LICENSE_1_0.txt or # copy at http://www.boost.org/LICENSE_1_0.txt) +# make sure BOOST_ROOT is pointing to your boost directory +# otherwise, set it here: +# BOOST_ROOT = /path/to/boost +# path to the cuda installation +CUDA_ROOT = /usr/local/cuda +# target architecture +ARCH = sm_13 -CUDA_ROOT = /usr/local/cuda-5.0 - -CC = gcc -CXX = gcc NVCC = $(CUDA_ROOT)/bin/nvcc -INCLUDES += -I../../include/ -I$(BOOST_ROOT) -I$(THRUST_ROOT) -I$(CUDA_ROOT)/include +INCLUDES += -I../../include/ -I$(BOOST_ROOT) -NVCCFLAGS = -O3 $(INCLUDES) --compiler-bindir=/opt/gcc4.6.2/bin/ +NVCCFLAGS = -O3 $(INCLUDES) -arch $(ARCH) -LDLIBS = -lcudart -lstdc++ -LDFLAGS = -L$(CUDA_ROOT)/lib64 +%.o : %.cu + $(NVCC) $(NVCCFLAGS) -c $< -o $@ -%.co : %.cu - $(NVCC) $(NVCCFLAGS) -o $@ -c $< +% : %.o + $(NVCC) $(NVCCFLAGS) -o $@ $< all : check_thrust -check_thrust : check_thrust.co - $(CC) -o check_thrust $(LDFLAGS) $(LDLIBS) check_thrust.co -check_thrust.co : check_thrust.cu - clean : - -rm *~ *.o *.co check_thrust - + -rm *~ *.o check_thrust From b6ebc0f15603b1b52a6b795909737ea297c3569f Mon Sep 17 00:00:00 2001 From: Mario Mulansky Date: Fri, 17 Oct 2014 11:09:24 +0200 Subject: [PATCH 27/70] new performance tests --- .../odeint/stepper/runge_kutta4_classic.hpp | 11 +- performance/Jamfile.v2 | 50 +--- performance/fusion_algebra.hpp | 202 ---------------- performance/fusion_explicit_error_rk.hpp | 63 ----- performance/fusion_explicit_rk_new.hpp | 217 ------------------ performance/generic_odeint_rk4_lorenz.cpp | 84 ------- performance/gsl_rk4_lorenz.cpp | 71 ------ performance/lorenz.hpp | 13 -- performance/lorenz_gsl.hpp | 30 --- performance/mpi/Jamfile.v2 | 20 -- performance/mpi/osc_chain_1d.cpp | 112 --------- performance/mpi/osc_chain_1d_system.hpp | 88 ------- performance/mpi/osc_chain_speedup.gnu | 38 --- performance/mpi/osc_chain_speedup.sh | 24 -- performance/nr_rk4_lorenz.cpp | 84 ------- performance/nr_rk4_phase_lattice.cpp | 85 ------- performance/odeint_rk4_lorenz_array.cpp | 71 ------ performance/odeint_rk4_lorenz_range.cpp | 59 ----- performance/odeint_rk4_phase_lattice.cpp | 64 ------ performance/odeint_rk4_phase_lattice_mkl.cpp | 69 ------ performance/openmp/Jamfile.v2 | 21 -- performance/openmp/osc_chain_1d.cpp | 127 ---------- performance/openmp/osc_chain_1d_system.hpp | 98 -------- performance/openmp/osc_chain_speedup.gnu | 50 ---- performance/openmp/osc_chain_speedup.sh | 38 --- performance/performance.py | 70 ------ performance/phase_lattice.hpp | 43 ---- performance/phase_lattice_mkl.hpp | 57 ----- performance/plot_result.py | 40 ---- performance/rk4_lorenz.f | 53 ----- performance/rk_performance_test_case.hpp | 68 ------ performance/rt_algebra.hpp | 32 --- performance/rt_explicit_rk.hpp | 87 ------- performance/rt_generic_rk4_lorenz.cpp | 81 ------- performance/rt_generic_rk4_phase_lattice.cpp | 83 ------- 35 files changed, 15 insertions(+), 2388 deletions(-) delete mode 100644 performance/fusion_algebra.hpp delete mode 100644 performance/fusion_explicit_error_rk.hpp delete mode 100644 performance/fusion_explicit_rk_new.hpp delete mode 100644 performance/generic_odeint_rk4_lorenz.cpp delete mode 100644 performance/gsl_rk4_lorenz.cpp delete mode 100644 performance/lorenz_gsl.hpp delete mode 100644 performance/mpi/Jamfile.v2 delete mode 100644 performance/mpi/osc_chain_1d.cpp delete mode 100644 performance/mpi/osc_chain_1d_system.hpp delete mode 100755 performance/mpi/osc_chain_speedup.gnu delete mode 100755 performance/mpi/osc_chain_speedup.sh delete mode 100644 performance/nr_rk4_lorenz.cpp delete mode 100644 performance/nr_rk4_phase_lattice.cpp delete mode 100644 performance/odeint_rk4_lorenz_array.cpp delete mode 100644 performance/odeint_rk4_lorenz_range.cpp delete mode 100644 performance/odeint_rk4_phase_lattice.cpp delete mode 100644 performance/odeint_rk4_phase_lattice_mkl.cpp delete mode 100644 performance/openmp/Jamfile.v2 delete mode 100644 performance/openmp/osc_chain_1d.cpp delete mode 100644 performance/openmp/osc_chain_1d_system.hpp delete mode 100755 performance/openmp/osc_chain_speedup.gnu delete mode 100755 performance/openmp/osc_chain_speedup.sh delete mode 100644 performance/performance.py delete mode 100644 performance/phase_lattice.hpp delete mode 100644 performance/phase_lattice_mkl.hpp delete mode 100644 performance/plot_result.py delete mode 100644 performance/rk4_lorenz.f delete mode 100644 performance/rk_performance_test_case.hpp delete mode 100644 performance/rt_algebra.hpp delete mode 100644 performance/rt_explicit_rk.hpp delete mode 100644 performance/rt_generic_rk4_lorenz.cpp delete mode 100644 performance/rt_generic_rk4_phase_lattice.cpp diff --git a/include/boost/numeric/odeint/stepper/runge_kutta4_classic.hpp b/include/boost/numeric/odeint/stepper/runge_kutta4_classic.hpp index 2b8e70b1..32bda0bd 100644 --- a/include/boost/numeric/odeint/stepper/runge_kutta4_classic.hpp +++ b/include/boost/numeric/odeint/stepper/runge_kutta4_classic.hpp @@ -121,11 +121,20 @@ public : // dt * m_dxh = k4 sys( m_x_tmp.m_v , m_dxh.m_v , t + dt ); + //x += dt/6 * ( m_dxdt + m_dxt + val2*m_dxm ) time_type dt6 = dt / static_cast< value_type >( 6 ); time_type dt3 = dt / static_cast< value_type >( 3 ); stepper_base_type::m_algebra.for_each6( out , in , dxdt , m_dxt.m_v , m_dxm.m_v , m_dxh.m_v , - typename operations_type::template scale_sum5< value_type , time_type , time_type , time_type , time_type >( 1.0 , dt6 , dt3 , dt3 , dt6 ) ); + typename operations_type::template scale_sum5< value_type , time_type , time_type , time_type , time_type >( 1.0 , dt6 , dt3 , dt3 , dt6 ) ); + + // x += dt/6 * m_dxdt + dt/3 * m_dxt ) + // stepper_base_type::m_algebra.for_each4( out , in , dxdt , m_dxt.m_v , + // typename operations_type::template scale_sum3< value_type , time_type , time_type >( 1.0 , dt6 , dt3 ) ); + // // x += dt/3 * m_dxm + dt/6 * m_dxh ) + // stepper_base_type::m_algebra.for_each4( out , out , m_dxm.m_v , m_dxh.m_v , + // typename operations_type::template scale_sum3< value_type , time_type , time_type >( 1.0 , dt3 , dt6 ) ); + } template< class StateType > diff --git a/performance/Jamfile.v2 b/performance/Jamfile.v2 index 54b89fa3..e60e4ea1 100644 --- a/performance/Jamfile.v2 +++ b/performance/Jamfile.v2 @@ -11,6 +11,9 @@ project : requirements BOOST_ALL_NO_LIB=1 ../../../.. + -std=c++11 + gcc:-ffast-math + intel:"-fast -inline-forceinline" : default-build release ; @@ -24,49 +27,6 @@ lib libmkl_intel_thread : : mkl_intel_thread ; lib libiomp5 : : iomp5 ; lib libpthread : : pthread ; -exe odeint_rk4_lorenz_array - : odeint_rk4_lorenz_array.cpp +exe odeint_rk4_array + : odeint_rk4_array.cpp ; - -exe odeint_rk4_lorenz_range - : odeint_rk4_lorenz_range.cpp - ; - -# exe odeint_rk4_lorenz_fusion -# : odeint_rk4_lorenz_fusion.cpp -# ; - -exe generic_odeint_rk4_lorenz - : generic_odeint_rk4_lorenz.cpp - : intel:-inline-forceinline - ; - -exe nr_rk4_lorenz - : nr_rk4_lorenz.cpp - ; - -exe rt_generic_rk4_lorenz - : rt_generic_rk4_lorenz.cpp - ; - -exe gsl_rk4_lorenz - : gsl_rk4_lorenz.cpp libgslcblas libgsl - ; - -exe odeint_rk4_phase_lattice - : odeint_rk4_phase_lattice.cpp - ; - -exe odeint_rk4_phase_lattice_mkl - : odeint_rk4_phase_lattice_mkl.cpp libpthread libiomp5 libmkl_core libmkl_intel_thread libmkl - ; - -exe nr_rk4_phase_lattice - : nr_rk4_phase_lattice.cpp - ; - -exe rt_generic_rk4_phase_lattice - : rt_generic_rk4_phase_lattice.cpp - ; - - diff --git a/performance/fusion_algebra.hpp b/performance/fusion_algebra.hpp deleted file mode 100644 index 1233ce00..00000000 --- a/performance/fusion_algebra.hpp +++ /dev/null @@ -1,202 +0,0 @@ -/* - * fusion_algebra.hpp - * - * Copyright 2011 Mario Mulansky - * Copyright 2012 Karsten Ahnert - * - * Distributed under the Boost Software License, Version 1.0. - * (See accompanying file LICENSE_1_0.txt or - * copy at http://www.boost.org/LICENSE_1_0.txt) - */ - - -#ifndef FUSION_ALGEBRA_HPP_ -#define FUSION_ALGEBRA_HPP_ - -#include - -#include - - -template< size_t n > -struct fusion_algebra -{ - template< typename T , size_t dim > - inline static void foreach( boost::array< T , dim > &x_tmp , const boost::array< T , dim > &x , - const boost::array< double , n > &a , - const boost::array< T , dim > k_vector[n] , const double dt ) - { - for( size_t i=0 ; i - inline static void foreach( boost::array< T , dim > &x_tmp , - const boost::array< double , n > &a , - const boost::array< T , dim > k_vector[n] , const double dt ) - { - for( size_t i=0 ; i -struct fusion_algebra< 1 > -{ - template< typename T , size_t dim > - inline static void foreach( boost::array< T , dim > &x_tmp , const boost::array< T , dim > &x , - const boost::array< double , 1 > &a , - const boost::array< T , dim > *k_vector , const double dt ) - { - for( size_t i=0 ; i -struct fusion_algebra< 2 > -{ - - template< typename T , size_t dim > - inline static void foreach( boost::array< T , dim > &x_tmp , const boost::array< T , dim > &x , - const boost::array< double , 2 > &a , - const boost::array< T , dim > *k_vector , const double dt ) - { - for( size_t i=0 ; i -struct fusion_algebra< 3 > -{ - - template< typename T , size_t dim > - inline static void foreach( boost::array< T , dim > &x_tmp , const boost::array< T , dim > &x , - const boost::array< double , 3 > &a , - const boost::array< T , dim > *k_vector , const double dt ) - { - for( size_t i=0 ; i -struct fusion_algebra< 4 > -{ - - template< typename T , size_t dim > - inline static void foreach( boost::array< T , dim > &x_tmp , const boost::array< T , dim > &x , - const boost::array< double , 4 > &a , - const boost::array< T , dim > *k_vector , const double dt ) - { - for( size_t i=0 ; i -struct fusion_algebra< 5 > -{ - - template< typename T , size_t dim > - inline static void foreach( boost::array< T , dim > &x_tmp , const boost::array< T , dim > &x , - const boost::array< double , 5 > &a , - const boost::array< T , dim > *k_vector , const double dt ) - { - for( size_t i=0 ; i -struct fusion_algebra< 6 > -{ - - template< typename T , size_t dim > - inline static void foreach( boost::array< T , dim > &x_tmp , const boost::array< T , dim > &x , - const boost::array< double , 6 > &a , - const boost::array< T , dim > *k_vector , const double dt ) - { - for( size_t i=0 ; i - inline static void foreach(boost::array &x_tmp , - const boost::array &a , - const boost::array *k_vector , const double dt) - { - for (size_t i = 0 ; i < dim ; ++i) - { - x_tmp[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]; - } - } - -}; - -//#endif /* BOOST_MSVC */ - -#endif /* FUSION_ALGEBRA_HPP_ */ diff --git a/performance/fusion_explicit_error_rk.hpp b/performance/fusion_explicit_error_rk.hpp deleted file mode 100644 index b0085d64..00000000 --- a/performance/fusion_explicit_error_rk.hpp +++ /dev/null @@ -1,63 +0,0 @@ -/* - * fusion_explicit_error_rk.hpp - * - * Copyright 2011 Mario Mulansky - * Copyright 2012 Karsten Ahnert - * - * Distributed under the Boost Software License, Version 1.0. - * (See accompanying file LICENSE_1_0.txt or - * copy at http://www.boost.org/LICENSE_1_0.txt) - */ - - -#ifndef FUSION_EXPLICIT_ERROR_RK_HPP_ -#define FUSION_EXPLICIT_ERROR_RK_HPP_ - -#include "fusion_explicit_rk_new.hpp" -#include "fusion_algebra.hpp" - -namespace mpl = boost::mpl; -namespace fusion = boost::fusion; - -using namespace std; - -template< class StateType , size_t stage_count > -class explicit_error_rk : public explicit_rk< StateType , stage_count > -{ - -public: - - typedef explicit_rk< StateType , stage_count > base; - - typedef StateType state_type; - - typedef typename base::stage_indices stage_indices; - - typedef typename base::coef_a_type coef_a_type; - - typedef typename base::coef_b_type coef_b_type; - typedef typename base::coef_c_type coef_c_type; - - public: - - explicit_error_rk( const coef_a_type &a , - const coef_b_type &b , - const coef_b_type &b2 , - const coef_c_type &c ) - : base( a , b , c ) , m_b2( b2 ) - { } - - template< class System > - void inline do_step( System system , state_type &x , const double t , const double dt , state_type &x_err ) - { - base::do_step( system , x , t , dt ); - // compute error estimate - fusion_algebra< stage_count >::foreach( x_err , m_b2 , base::m_F , dt ); - } - -private: - - const coef_b_type m_b2; -}; - -#endif /* FUSION_EXPLICIT_ERROR_RK_HPP_ */ diff --git a/performance/fusion_explicit_rk_new.hpp b/performance/fusion_explicit_rk_new.hpp deleted file mode 100644 index d16a67b5..00000000 --- a/performance/fusion_explicit_rk_new.hpp +++ /dev/null @@ -1,217 +0,0 @@ -/* - * fusion_runge_kutta.hpp - * - * Copyright 2010-2011 Mario Mulansky - * Copyright 2010-2012 Karsten Ahnert - * - * Distributed under the Boost Software License, Version 1.0. - * (See accompanying file LICENSE_1_0.txt or - * copy at http://www.boost.org/LICENSE_1_0.txt) - */ - - -#ifndef FUSION_EXPLICIT_RK_HPP_ -#define FUSION_EXPLICIT_RK_HPP_ - -#include -#include -#include -#include -#include -#include - -#include -#include - -#include - -#include "fusion_algebra.hpp" -//#include "fusion_foreach_performance.hpp" - -namespace mpl = boost::mpl; -namespace fusion = boost::fusion; - -using namespace std; - -struct intermediate_stage {}; -struct last_stage {}; - - - -template< class T , class Constant > -struct array_wrapper -{ - typedef const typename boost::array< T , Constant::value > type; -}; - -template< class T , size_t i , class StageCategory > -struct stage -{ - T c; - boost::array< T , i > a; - typedef StageCategory category; -}; - -template< class T , size_t i> -struct stage< T , i , last_stage > -{ - T c; - boost::array< T , i > b; - typedef last_stage category; -}; - - - -template< class T , class Constant , class StageCategory > -struct stage_wrapper -{ - typedef stage< T , Constant::value , StageCategory > type; -}; - - -template< class StateType , size_t stage_count > -class explicit_rk -{ - -public: - - typedef StateType state_type; - - typedef mpl::range_c< size_t , 1 , stage_count > stage_indices; - - typedef typename fusion::result_of::as_vector - < - typename mpl::copy - < - stage_indices , - mpl::inserter - < - mpl::vector0< > , - mpl::push_back< mpl::_1 , array_wrapper< double , mpl::_2 > > - > - >::type - >::type coef_a_type; - - typedef boost::array< double , stage_count > coef_b_type; - typedef boost::array< double , stage_count > coef_c_type; - - typedef typename fusion::result_of::as_vector - < - typename mpl::push_back - < - typename mpl::copy - < - stage_indices, - mpl::inserter - < - mpl::vector0<> , - mpl::push_back< mpl::_1 , stage_wrapper< double , mpl::_2 , intermediate_stage > > - > - >::type , - stage< double , stage_count , last_stage > - >::type - >::type stage_vector_base; - - - struct stage_vector : public stage_vector_base - { - struct do_insertion - { - stage_vector_base &m_base; - const coef_a_type &m_a; - const coef_c_type &m_c; - - do_insertion( stage_vector_base &base , const coef_a_type &a , const coef_c_type &c ) - : m_base( base ) , m_a( a ) , m_c( c ) { } - - template< class Index > - void operator()( Index ) const - { - //fusion::at< Index >( m_base ) = stage< double , Index::value+1 , intermediate_stage >( m_c[ Index::value ] , fusion::at< Index >( m_a ) ); - fusion::at< Index >( m_base ).c = m_c[ Index::value ]; - fusion::at< Index >( m_base ).a = fusion::at< Index >( m_a ); - } - }; - - stage_vector( const coef_a_type &a , const coef_b_type &b , const coef_c_type &c ) - { - typedef mpl::range_c< size_t , 0 , stage_count - 1 > indices; - mpl::for_each< indices >( do_insertion( *this , a , c ) ); - //fusion::at_c< 0 >( fusion::at_c< stage_count - 1 >( *this ) ) = stage_count - 1 ; - fusion::at_c< stage_count - 1 >( *this ).c = c[ stage_count - 1 ]; - fusion::at_c< stage_count - 1 >( *this ).b = b; - } - }; - - - - template< class System > - struct calculate_stage - { - System &system; - state_type &x , &x_tmp; - state_type *F; - const double t; - const double dt; - - calculate_stage( System &_system , state_type &_x , state_type &_x_tmp , state_type *_F , - const double _t , const double _dt ) - : system( _system ) , x( _x ) , x_tmp( _x_tmp ) , F( _F ) , t( _t ) , dt( _dt ) - {} - - - template< typename T , size_t stage_number > - void inline operator()( stage< T , stage_number , intermediate_stage > const &stage ) const - //typename stage_fusion_wrapper< T , mpl::size_t< stage_number > , intermediate_stage >::type const &stage ) const - { - if( stage_number == 1 ) - system( x , F[stage_number-1] , t + stage.c * dt ); - else - system( x_tmp , F[stage_number-1] , t + stage.c * dt ); - - fusion_algebra::foreach( x_tmp , x , stage.a , F , dt); - } - - - template< typename T , size_t stage_number > - void inline operator()( stage< T , stage_number , last_stage > const &stage ) const - //void operator()( typename stage_fusion_wrapper< T , mpl::size_t< stage_number > , last_stage >::type const &stage ) const - { - if( stage_number == 1 ) - system( x , F[stage_number-1] , t + stage.c * dt ); - else - system( x_tmp , F[stage_number-1] , t + stage.c * dt ); - - fusion_algebra::foreach( x , x , stage.b , F , dt); - } - - - }; - -public: - - explicit_rk( const coef_a_type &a , - const coef_b_type &b , - const coef_c_type &c ) - : m_stages( a , b , c ) - - { } - - - template< class System > - void inline do_step( System system , state_type &x , const double t , const double dt ) - { - fusion::for_each( m_stages , calculate_stage< System >( system , x , m_x_tmp , m_F , t , dt ) ); - } - -private: - - stage_vector m_stages; - state_type m_x_tmp; - -protected: - state_type m_F[stage_count]; - -}; - -#endif /* FUSION_EXPLICIT_RK_HPP_ */ diff --git a/performance/generic_odeint_rk4_lorenz.cpp b/performance/generic_odeint_rk4_lorenz.cpp deleted file mode 100644 index 0d097564..00000000 --- a/performance/generic_odeint_rk4_lorenz.cpp +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright 2011 Mario Mulansky - * Copyright 2012 Karsten Ahnert - * - * Distributed under the Boost Software License, Version 1.0. - * (See accompanying file LICENSE_1_0.txt or - * copy at http://www.boost.org/LICENSE_1_0.txt) - */ - - -#include - -//#include -#include -#include - -#include "rk_performance_test_case.hpp" - -#include "lorenz.hpp" - -using namespace boost::numeric::odeint; - -typedef boost::array< double , 3 > state_type; - -/* -typedef explicit_generic_rk< 4 , 4 , state_type , double , state_type , double , array_algebra > rk4_type; - -typedef rk4_type::coef_a_type coef_a_type; -typedef rk4_type::coef_b_type coef_b_type; -typedef rk4_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 }}; -*/ - -typedef runge_kutta4< state_type , double , state_type , double , array_algebra > rk4_type; - - -class rk4_wrapper -{ - -public: - - rk4_wrapper() - // : m_stepper( a , b , c ) - {} - - void reset_init_cond() - { - m_x[0] = 10.0 * rand() / RAND_MAX; - m_x[1] = 10.0 * rand() / RAND_MAX; - m_x[2] = 10.0 * rand() / RAND_MAX; - m_t = 0.0; - } - - inline void do_step( const double dt ) - { - m_stepper.do_step( lorenz(), 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_type m_stepper; -}; - - - -int main() -{ - srand( 12312354 ); - - rk4_wrapper stepper; - - run( stepper ); -} diff --git a/performance/gsl_rk4_lorenz.cpp b/performance/gsl_rk4_lorenz.cpp deleted file mode 100644 index f5f13882..00000000 --- a/performance/gsl_rk4_lorenz.cpp +++ /dev/null @@ -1,71 +0,0 @@ -/* - * gsl_rk4_lorenz.cpp - * - * Copyright 2011 Mario Mulansky - * Copyright 2012 Karsten Ahnert - * - * Distributed under the Boost Software License, Version 1.0. - * (See accompanying file LICENSE_1_0.txt or - * copy at http://www.boost.org/LICENSE_1_0.txt) - */ - - -#include - -#include "rk_performance_test_case.hpp" - -#include "lorenz_gsl.hpp" - -const size_t dim = 3; - -class gsl_wrapper -{ -public: - - gsl_wrapper() - { - m_s = gsl_odeiv_step_alloc( gsl_odeiv_step_rk4 , dim); - m_sys.function = lorenz_gsl; - m_sys.jacobian = 0; - m_sys.dimension = dim; - m_sys.params = 0; - } - - void reset_init_cond() - { - m_x[0] = 10.0 * rand() / RAND_MAX; - m_x[1] = 10.0 * rand() / RAND_MAX; - m_x[2] = 10.0 * rand() / RAND_MAX; - m_t = 0.0; - } - - inline void do_step( const double dt ) - { - gsl_odeiv_step_apply ( m_s , m_t , dt , m_x , m_x_err , 0 , 0 , &m_sys ); - //m_t += dt; - } - - double state( const size_t i ) const - { return m_x[i]; } - - ~gsl_wrapper() - { - gsl_odeiv_step_free( m_s ); - } - -private: - double m_x[dim]; - double m_x_err[dim]; - double m_t; - gsl_odeiv_step *m_s; - gsl_odeiv_system m_sys; -}; - - - -int main() -{ - gsl_wrapper stepper; - - run( stepper , 20000000 / 3 , 1E-10 * 3); -} diff --git a/performance/lorenz.hpp b/performance/lorenz.hpp index 22de8136..c1ea37c9 100644 --- a/performance/lorenz.hpp +++ b/performance/lorenz.hpp @@ -30,17 +30,4 @@ struct lorenz }; -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; - 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]; -} - #endif /* LORENZ_HPP_ */ diff --git a/performance/lorenz_gsl.hpp b/performance/lorenz_gsl.hpp deleted file mode 100644 index a907aed8..00000000 --- a/performance/lorenz_gsl.hpp +++ /dev/null @@ -1,30 +0,0 @@ -/* - * lorenz_gsl.hpp - * - * Copyright 2011 Mario Mulansky - * Copyright 2012 Karsten Ahnert - * - * Distributed under the Boost Software License, Version 1.0. - * (See accompanying file LICENSE_1_0.txt or - * copy at http://www.boost.org/LICENSE_1_0.txt) - */ - - -#ifndef LORENZ_GSL_HPP_ -#define LORENZ_GSL_HPP_ - -#include - -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 diff --git a/performance/mpi/Jamfile.v2 b/performance/mpi/Jamfile.v2 deleted file mode 100644 index d80e860d..00000000 --- a/performance/mpi/Jamfile.v2 +++ /dev/null @@ -1,20 +0,0 @@ -# Copyright 2011-2013 Mario Mulansky -# Copyright 2012 Karsten Ahnert -# Copyright 2013 Pascal Germroth -# Distributed under the Boost Software License, Version 1.0. (See -# accompanying file LICENSE_1_0.txt or copy at -# http://www.boost.org/LICENSE_1_0.txt) - -import mpi ; - -project - : requirements - ../../../../.. - .. - BOOST_ALL_NO_LIB=1 - /boost//timer - /boost//mpi - /boost//program_options - ; - -exe osc_chain_1d : osc_chain_1d.cpp ; diff --git a/performance/mpi/osc_chain_1d.cpp b/performance/mpi/osc_chain_1d.cpp deleted file mode 100644 index ef2ce7db..00000000 --- a/performance/mpi/osc_chain_1d.cpp +++ /dev/null @@ -1,112 +0,0 @@ -/* Boost libs/numeric/odeint/performance/openmp/osc_chain_1d.cpp - - Copyright 2013 Karsten Ahnert - Copyright 2013 Mario Mulansky - Copyright 2013 Pascal Germroth - - stronlgy nonlinear hamiltonian lattice in 2d - - Distributed under the Boost Software License, Version 1.0. -(See accompanying file LICENSE_1_0.txt or - copy at http://www.boost.org/LICENSE_1_0.txt) - */ - -#include -#include - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include "osc_chain_1d_system.hpp" - -using namespace std; -using namespace boost::numeric::odeint; -using namespace boost::accumulators; -using namespace boost::program_options; - -using boost::timer::cpu_timer; - -const double p_kappa = 3.3; -const double p_lambda = 4.7; - -int main( int argc , char* argv[] ) -{ - boost::mpi::environment env(argc, argv); - boost::mpi::communicator world; - - size_t N, steps, repeat; - bool dump; - options_description desc("Options"); - desc.add_options() - ("help,h", "show this help") - ("length", value(&N)->default_value(1024), "length of chain") - ("steps", value(&steps)->default_value(100), "simulation steps") - ("repeat", value(&repeat)->default_value(25), "repeat runs") - ("dump", bool_switch(&dump), "dump final state to stderr (on node 0)") - ; - variables_map vm; - store(command_line_parser(argc, argv).options(desc).run(), vm); - notify(vm); - if(vm.count("help")) - { - if(world.rank() == 0) - cerr << desc << endl; - return EXIT_FAILURE; - } - cout << "length\tsteps\tthreads\ttime" << endl; - - accumulator_set< double, stats > acc_time; - - vector p( N ), q( N, 0 ); - if(world.rank() == 0) { - boost::random::uniform_real_distribution distribution; - boost::random::mt19937 engine( 0 ); - generate( p.begin() , p.end() , boost::bind( distribution , engine ) ); - } - - typedef vector inner_state_type; - typedef mpi_state< inner_state_type > state_type; - typedef symplectic_rkn_sb3a_mclachlan< - state_type , state_type , double - > stepper_type; - state_type p_split( world ), q_split( world ); - split(p, p_split); - split(q, q_split); - - for(size_t n_run = 0 ; n_run != repeat ; n_run++) { - cpu_timer timer; - world.barrier(); - integrate_n_steps( stepper_type() , osc_chain( p_kappa , p_lambda ) , - make_pair( boost::ref(q_split) , boost::ref(p_split) ) , - 0.0 , 0.01 , steps ); - world.barrier(); - if(world.rank() == 0) { - double run_time = static_cast(timer.elapsed().wall) * 1.0e-9; - acc_time(run_time); - cout << N << '\t' << steps << '\t' << world.size() << '\t' << run_time << endl; - } - } - - if(dump) { - unsplit(p_split, p); - if(world.rank() == 0) { - copy(p.begin(), p.end(), ostream_iterator(cerr, "\t")); - cerr << endl; - } - } - - if(world.rank() == 0) - cout << "# mean=" << mean(acc_time) - << " median=" << median(acc_time) << endl; - - return 0; -} - diff --git a/performance/mpi/osc_chain_1d_system.hpp b/performance/mpi/osc_chain_1d_system.hpp deleted file mode 100644 index 69720845..00000000 --- a/performance/mpi/osc_chain_1d_system.hpp +++ /dev/null @@ -1,88 +0,0 @@ -/* Boost libs/numeric/odeint/performance/openmp/osc_chain_1d_system.hpp - - Copyright 2013 Karsten Ahnert - Copyright 2013 Mario Mulansky - Copyright 2013 Pascal Germroth - - stronlgy nonlinear hamiltonian lattice - - Distributed under the Boost Software License, Version 1.0. -(See accompanying file LICENSE_1_0.txt or - copy at http://www.boost.org/LICENSE_1_0.txt) - */ - -#ifndef SYSTEM_HPP -#define SYSTEM_HPP - -#include -#include -#include - -#include -#include - -namespace checked_math { - inline double pow( double x , double y ) - { - if( x==0.0 ) - // 0**y = 0, don't care for y = 0 or NaN - return 0.0; - using std::pow; - using std::abs; - return pow( abs(x) , y ); - } -} - -double signed_pow( double x , double k ) -{ - using boost::math::sign; - return checked_math::pow( x , k ) * sign(x); -} - -struct osc_chain { - const double m_kap, m_lam; - osc_chain( const double kap , const double lam ) - : m_kap( kap ) , m_lam( lam ) { } - - void operator()( const boost::numeric::odeint::mpi_state< std::vector > &q , - boost::numeric::odeint::mpi_state< std::vector > &dpdt ) const - { - const bool have_left = q.world.rank() > 0; - const bool have_right = q.world.rank() + 1 < q.world.size(); - double q_left = 0, q_right = 0; - boost::mpi::request r_left, r_right; - if(have_left) - { - q.world.isend(q.world.rank() - 1, 0, q().front()); - r_left = q.world.irecv(q.world.rank() - 1, 0, q_left); - } - if(have_right) - { - q.world.isend(q.world.rank() + 1, 0, q().back()); - r_right = q.world.irecv(q.world.rank() + 1, 0, q_right); - } - - double coupling_lr = 0; - if(have_left) - { - r_left.wait(); - coupling_lr = signed_pow( q_left - q()[0] , m_lam-1 ); - } - const size_t N = q().size(); - for(size_t i = 0 ; i < N-1 ; ++i) - { - dpdt()[i] = -signed_pow( q()[i] , m_kap-1 ) + coupling_lr; - coupling_lr = signed_pow( q()[i] - q()[i+1] , m_lam-1 ); - dpdt()[i] -= coupling_lr; - } - dpdt()[N-1] = -signed_pow( q()[N-1] , m_kap-1 ) + coupling_lr; - if(have_right) - { - r_right.wait(); - dpdt()[N-1] -= signed_pow( q()[N-1] - q_right , m_lam-1 ); - } - } - //] -}; - -#endif diff --git a/performance/mpi/osc_chain_speedup.gnu b/performance/mpi/osc_chain_speedup.gnu deleted file mode 100755 index 7f387725..00000000 --- a/performance/mpi/osc_chain_speedup.gnu +++ /dev/null @@ -1,38 +0,0 @@ -#!/usr/bin/env gnuplot - -set terminal pngcairo size 1000,1000 -set output "osc_chain_speedup.png" - -set multiplot layout 2,2 - -set key left - -set xrange [1:16] -set x2range [1:16] -set x2tics 8 format "" -set grid x2tics -set yrange [0:8] - -set title "short: speedup" -plot \ - "osc_chain_speedup-short.dat" i 0 u "block":"mul" w lp t "MPI" , \ - (x < 4 ? x : 4) lc 0 lt 0 t "target" - -unset key - -set title "long: speedup" -plot \ - "osc_chain_speedup-long.dat" i 0 u "block":"mul" w lp, \ - (x < 4 ? x : 4) lc 0 lt 0 - -set yrange [0:*] - -set title "short: time[s]" -plot \ - "osc_chain_speedup-short.dat" i 0 u "block":"med" w lp - -set title "long: time[s]" -plot \ - "osc_chain_speedup-long.dat" i 0 u "block":"med" w lp - -unset multiplot diff --git a/performance/mpi/osc_chain_speedup.sh b/performance/mpi/osc_chain_speedup.sh deleted file mode 100755 index 7a0ff789..00000000 --- a/performance/mpi/osc_chain_speedup.sh +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/bash - -bench="bin/clang-linux-3.2/release/threading-multi/osc_chain_1d" - -repeat=5 -maxnodes=16 - -function run { - n=$1 - steps=$2 - for ((nodes=1 ; nodes < $maxnodes ; nodes++)) ; do - # swap stderr & stdout - mpirun -np $nodes $bench $n $steps $repeat 3>&1 1>&2 2>&3 - done -} - -function run_all { - printf "n\tsteps\tnodes\ttime\n" - run 256 1024 - run 4096 1024 - run 4194304 1 -} - -run_all | tee osc_chain_speedup.dat diff --git a/performance/nr_rk4_lorenz.cpp b/performance/nr_rk4_lorenz.cpp deleted file mode 100644 index 36be91df..00000000 --- a/performance/nr_rk4_lorenz.cpp +++ /dev/null @@ -1,84 +0,0 @@ -/* - * nr_rk4_lorenz.cpp - * - * Copyright 2011 Mario Mulansky - * Copyright 2012 Karsten Ahnert - * - * Distributed under the Boost Software License, Version 1.0. - * (See accompanying file LICENSE_1_0.txt or - * copy at http://www.boost.org/LICENSE_1_0.txt) - */ - - -#include - -#include "rk_performance_test_case.hpp" - -#include "lorenz.hpp" - -const size_t dim = 3; - -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 - -#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() , 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 , 10000 , 1E-6 ); -} diff --git a/performance/odeint_rk4_lorenz_array.cpp b/performance/odeint_rk4_lorenz_array.cpp deleted file mode 100644 index 5d73a4d6..00000000 --- a/performance/odeint_rk4_lorenz_array.cpp +++ /dev/null @@ -1,71 +0,0 @@ -/* - * odeint_rk4_lorenz.cpp - * - * Copyright 2011-2012 Mario Mulansky - * Copyright 2012 Karsten Ahnert - * - * Distributed under the Boost Software License, Version 1.0. - * (See accompanying file LICENSE_1_0.txt or - * copy at http://www.boost.org/LICENSE_1_0.txt) - */ - - -#include - -#include -#include -#include - -#include "rk_performance_test_case.hpp" - -#include "lorenz.hpp" - -typedef boost::array< double , 3 > state_type; -typedef boost::numeric::odeint::runge_kutta4< state_type , double , state_type , double , - boost::numeric::odeint::array_algebra > rk4_odeint_type; - - -class odeint_wrapper -{ -public: - void reset_init_cond() - { - /* random */ - /* - m_x[0] = 10.0 * rand() / RAND_MAX; - m_x[1] = 10.0 * rand() / RAND_MAX; - m_x[2] = 10.0 * rand() / RAND_MAX; - */ - /* hand chosen random (cf fortran) */ - m_x[0] = 8.5; - m_x[1] = 3.1; - m_x[2] = 1.2; - - m_t = 0.0; - } - - inline void do_step( const double dt ) - { - m_stepper.do_step( lorenz() , 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 ); -} diff --git a/performance/odeint_rk4_lorenz_range.cpp b/performance/odeint_rk4_lorenz_range.cpp deleted file mode 100644 index 0e717241..00000000 --- a/performance/odeint_rk4_lorenz_range.cpp +++ /dev/null @@ -1,59 +0,0 @@ -/* - * odeint_rk4_lorenz_def_alg.cpp - * - * Copyright 2011 Mario Mulansky - * Copyright 2012 Karsten Ahnert - * - * Distributed under the Boost Software License, Version 1.0. - * (See accompanying file LICENSE_1_0.txt or - * copy at http://www.boost.org/LICENSE_1_0.txt) - */ - - -#include - -#include -#include - -#include "rk_performance_test_case.hpp" - -#include "lorenz.hpp" - -typedef boost::array< double , 3 > state_type; -typedef boost::numeric::odeint::runge_kutta4_classic< state_type > rk4_odeint_type; - - -class odeint_wrapper -{ -public: - void reset_init_cond() - { - m_x[0] = 10.0 * rand() / RAND_MAX; - m_x[1] = 10.0 * rand() / RAND_MAX; - m_x[2] = 10.0 * rand() / RAND_MAX; - m_t = 0.0; - } - - inline void do_step( const double dt ) - { - m_stepper.do_step( lorenz() , 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() -{ - odeint_wrapper stepper; - - run( stepper ); -} diff --git a/performance/odeint_rk4_phase_lattice.cpp b/performance/odeint_rk4_phase_lattice.cpp deleted file mode 100644 index 1703b5c8..00000000 --- a/performance/odeint_rk4_phase_lattice.cpp +++ /dev/null @@ -1,64 +0,0 @@ -/* - * odeint_rk4_phase_lattice.cpp - * - * Copyright 2011 Mario Mulansky - * Copyright 2012 Karsten Ahnert - * - * Distributed under the Boost Software License, Version 1.0. - * (See accompanying file LICENSE_1_0.txt or - * copy at http://www.boost.org/LICENSE_1_0.txt) - */ - - -#include - -#include - -#include -#include -#include - -#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::runge_kutta4_classic< 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() , 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 , 10000 , 1E-6 ); -} diff --git a/performance/odeint_rk4_phase_lattice_mkl.cpp b/performance/odeint_rk4_phase_lattice_mkl.cpp deleted file mode 100644 index c900c0e4..00000000 --- a/performance/odeint_rk4_phase_lattice_mkl.cpp +++ /dev/null @@ -1,69 +0,0 @@ -/* - * odeint_rk4_phase_lattice_mkl.cpp - * - * Copyright 2011 Mario Mulansky - * Copyright 2012 Karsten Ahnert - * - * Distributed under the Boost Software License, Version 1.0. - * (See accompanying file LICENSE_1_0.txt or - * copy at http://www.boost.org/LICENSE_1_0.txt) - */ - - -#include - -#include -#include -#include - - -#include "rk_performance_test_case.hpp" - -#include "phase_lattice.hpp" -#include "phase_lattice_mkl.hpp" - -const size_t N = 1024; - -typedef boost::array< double , N > state_type; -typedef boost::numeric::odeint::runge_kutta4< state_type - , double , state_type , double , - boost::numeric::odeint::vector_space_algebra , - boost::numeric::odeint::mkl_operations - > rk4_odeint_type; - - -class odeint_wrapper -{ -public: - void reset_init_cond() - { - for( size_t i = 0 ; i() , 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 , 10000 , 1E-6 ); -} diff --git a/performance/openmp/Jamfile.v2 b/performance/openmp/Jamfile.v2 deleted file mode 100644 index 098cd53f..00000000 --- a/performance/openmp/Jamfile.v2 +++ /dev/null @@ -1,21 +0,0 @@ -# Copyright 2011-2013 Mario Mulansky -# Copyright 2012 Karsten Ahnert -# Copyright 2013 Pascal Germroth -# Distributed under the Boost Software License, Version 1.0. (See -# accompanying file LICENSE_1_0.txt or copy at -# http://www.boost.org/LICENSE_1_0.txt) - -use-project /boost : $(BOOST_ROOT) ; -import openmp : * ; - -project - : requirements - ../../../../.. - .. - BOOST_ALL_NO_LIB=1 - /boost//timer - /boost//program_options - [ openmp ] - ; - -exe osc_chain_1d : osc_chain_1d.cpp ; diff --git a/performance/openmp/osc_chain_1d.cpp b/performance/openmp/osc_chain_1d.cpp deleted file mode 100644 index 8a5a2e85..00000000 --- a/performance/openmp/osc_chain_1d.cpp +++ /dev/null @@ -1,127 +0,0 @@ -/* Boost libs/numeric/odeint/performance/openmp/osc_chain_1d.cpp - - Copyright 2013 Karsten Ahnert - Copyright 2013 Pascal Germroth - Copyright 2013 Mario Mulansky - - stronlgy nonlinear hamiltonian lattice in 2d - - Distributed under the Boost Software License, Version 1.0. -(See accompanying file LICENSE_1_0.txt or - copy at http://www.boost.org/LICENSE_1_0.txt) - */ - -#include -#include - -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include "osc_chain_1d_system.hpp" - -using namespace std; -using namespace boost::numeric::odeint; -using namespace boost::accumulators; -using namespace boost::program_options; - -using boost::timer::cpu_timer; - -const double p_kappa = 3.3; -const double p_lambda = 4.7; - -int main( int argc , char* argv[] ) -{ - size_t N, blocks, steps, repeat; - bool split_range, dump; - options_description desc("Options"); - desc.add_options() - ("help,h", "show this help") - ("length", value(&N)->default_value(1024), "length of chain") - ("steps", value(&steps)->default_value(100), "simulation steps") - ("blocks", value(&blocks)->default_value(omp_get_max_threads()), "number of blocks (split) or threads (non-split)") - ("split", bool_switch(&split_range), "split range") - ("repeat", value(&repeat)->default_value(25), "repeat runs") - ("dump", bool_switch(&dump), "dump final state to stderr") - ; - variables_map vm; - store(command_line_parser(argc, argv).options(desc).run(), vm); - notify(vm); - if(vm.count("help")) - { - cerr << desc << endl; - return EXIT_FAILURE; - } - cout << "length\tsteps\tthreads\ttime" << endl; - - accumulator_set< double, stats > acc_time; - - vector p( N ), q( N, 0 ); - boost::random::uniform_real_distribution distribution; - boost::random::mt19937 engine( 0 ); - generate( p.begin() , p.end() , boost::bind( distribution , engine ) ); - - if(split_range) { - typedef openmp_state state_type; - typedef symplectic_rkn_sb3a_mclachlan< - state_type , state_type , double - > stepper_type; - state_type p_split(blocks), q_split(blocks); - split(p, p_split); - split(q, q_split); - - for(size_t n_run = 0 ; n_run != repeat ; n_run++) { - cpu_timer timer; - integrate_n_steps( stepper_type() , osc_chain( p_kappa , p_lambda ) , - make_pair( boost::ref(q_split) , boost::ref(p_split) ) , - 0.0 , 0.01 , steps ); - double run_time = static_cast(timer.elapsed().wall) * 1.0e-9; - acc_time(run_time); - cout << N << '\t' << steps << '\t' << blocks << '\t' << run_time << endl; - } - - if(dump) { - unsplit(p_split, p); - copy(p.begin(), p.end(), ostream_iterator(cerr, "\t")); - cerr << endl; - } - - } else { - typedef vector state_type; - typedef symplectic_rkn_sb3a_mclachlan< - state_type , state_type , double , - state_type , state_type , double , - openmp_range_algebra - > stepper_type; - omp_set_num_threads(blocks); - - for(size_t n_run = 0 ; n_run != repeat ; n_run++) { - cpu_timer timer; - integrate_n_steps( stepper_type() , osc_chain( p_kappa , p_lambda ) , - make_pair( boost::ref(q) , boost::ref(p) ) , - 0.0 , 0.01 , steps ); - double run_time = static_cast(timer.elapsed().wall) * 1.0e-9; - acc_time(run_time); - cout << N << '\t' << steps << '\t' << blocks << '\t' << run_time << endl; - } - - if(dump) { - copy(p.begin(), p.end(), ostream_iterator(cerr, "\t")); - cerr << endl; - } - - } - - cout << "# mean=" << mean(acc_time) - << " median=" << median(acc_time) << endl; - - return 0; -} diff --git a/performance/openmp/osc_chain_1d_system.hpp b/performance/openmp/osc_chain_1d_system.hpp deleted file mode 100644 index d9a6c222..00000000 --- a/performance/openmp/osc_chain_1d_system.hpp +++ /dev/null @@ -1,98 +0,0 @@ -/* Boost libs/numeric/odeint/performance/openmp/osc_chain_1d_system.hpp - - Copyright 2013 Karsten Ahnert - Copyright 2013 Mario Mulansky - Copyright 2013 Pascal Germroth - - stronlgy nonlinear hamiltonian lattice - - Distributed under the Boost Software License, Version 1.0. -(See accompanying file LICENSE_1_0.txt or - copy at http://www.boost.org/LICENSE_1_0.txt) - */ - -#ifndef SYSTEM_HPP -#define SYSTEM_HPP - -#include -#include -#include - -#include - -#include -#include - -namespace checked_math { - inline double pow( double x , double y ) - { - if( x==0.0 ) - // 0**y = 0, don't care for y = 0 or NaN - return 0.0; - using std::pow; - using std::abs; - return pow( abs(x) , y ); - } -} - -double signed_pow( double x , double k ) -{ - using boost::math::sign; - return checked_math::pow( x , k ) * sign(x); -} - -struct osc_chain { - - const double m_kap, m_lam; - - osc_chain( const double kap , const double lam ) - : m_kap( kap ) , m_lam( lam ) - { } - - // Simple case with openmp_range_algebra - void operator()( const std::vector &q , - std::vector &dpdt ) const - { - const size_t N = q.size(); - double coupling_lr = 0; - size_t last_i = N; - #pragma omp parallel for firstprivate(coupling_lr, last_i) lastprivate(coupling_lr) schedule(runtime) - for(size_t i = 0 ; i < N - 1 ; ++i) - { - if(i > 0 && i != last_i + 1) - coupling_lr = signed_pow( q[i-1]-q[i] , m_lam-1 ); - dpdt[i] = -signed_pow( q[i] , m_kap-1 ) + coupling_lr; - coupling_lr = signed_pow( q[i] - q[i+1] , m_lam-1 ); - dpdt[i] -= coupling_lr; - last_i = i; - } - dpdt[N-1] = -signed_pow( q[N-1] , m_kap-1 ) + coupling_lr; - } - - // Split case with openmp_algebra - void operator()( const boost::numeric::odeint::openmp_state &q , - boost::numeric::odeint::openmp_state &dpdt ) const - { - const size_t M = q.size(); - #pragma omp parallel for schedule(runtime) - for(size_t i = 0 ; i < M ; ++i) - { - const std::vector &_q = q[i]; - std::vector &_dpdt = dpdt[i]; - const size_t N = q[i].size(); - double coupling_lr = 0; - if(i > 0) coupling_lr = signed_pow( q[i-1].back() - _q[0] , m_lam-1 ); - for(size_t j = 0 ; j < N-1 ; ++j) - { - _dpdt[j] = -signed_pow( _q[j] , m_kap-1 ) + coupling_lr; - coupling_lr = signed_pow( _q[j] - _q[j+1] , m_lam-1 ); - _dpdt[j] -= coupling_lr; - } - _dpdt[N-1] = -signed_pow( _q[N-1] , m_kap-1 ) + coupling_lr; - if(i + 1 < M) _dpdt[N-1] -= signed_pow( _q[N-1] - q[i+1].front() , m_lam-1 ); - } - } - -}; - -#endif diff --git a/performance/openmp/osc_chain_speedup.gnu b/performance/openmp/osc_chain_speedup.gnu deleted file mode 100755 index 4d6bc95e..00000000 --- a/performance/openmp/osc_chain_speedup.gnu +++ /dev/null @@ -1,50 +0,0 @@ -#!/usr/bin/env gnuplot - -set terminal pngcairo size 1000,1000 -set output "osc_chain_speedup.png" - -set multiplot layout 2,2 - -set key left - -set xrange [1:64] -set x2range [1:64] -set x2tics 8 format "" -set grid x2tics -set yrange [0:8] - -set title "short: speedup" -plot \ - "osc_chain_speedup-short.dat" i 0 u "block":"gcc-s-mul" w lp t "gcc (split)" , \ - "osc_chain_speedup-short.dat" i 0 u "block":"gcc-t-mul" w lp t "gcc (simple)", \ - "osc_chain_speedup-short.dat" i 0 u "block":"icc-s-mul" w lp t "icc (split)" , \ - "osc_chain_speedup-short.dat" i 0 u "block":"icc-t-mul" w lp t "icc (simple)", \ - (x < 4 ? x : 4) lc 0 lt 0 t "target" - -unset key - -set title "long: speedup" -plot \ - "osc_chain_speedup-long.dat" i 0 u "block":"gcc-s-mul" w lp, \ - "osc_chain_speedup-long.dat" i 0 u "block":"gcc-t-mul" w lp, \ - "osc_chain_speedup-long.dat" i 0 u "block":"icc-s-mul" w lp, \ - "osc_chain_speedup-long.dat" i 0 u "block":"icc-t-mul" w lp, \ - (x < 4 ? x : 4) lc 0 lt 0 - -set yrange [0:*] - -set title "short: time[s]" -plot \ - "osc_chain_speedup-short.dat" i 0 u "block":"gcc-s-med" w lp, \ - "osc_chain_speedup-short.dat" i 0 u "block":"gcc-t-med" w lp, \ - "osc_chain_speedup-short.dat" i 0 u "block":"icc-s-med" w lp, \ - "osc_chain_speedup-short.dat" i 0 u "block":"icc-t-med" w lp - -set title "long: time[s]" -plot \ - "osc_chain_speedup-long.dat" i 0 u "block":"gcc-s-med" w lp, \ - "osc_chain_speedup-long.dat" i 0 u "block":"gcc-t-med" w lp, \ - "osc_chain_speedup-long.dat" i 0 u "block":"icc-s-med" w lp, \ - "osc_chain_speedup-long.dat" i 0 u "block":"icc-t-med" w lp - -unset multiplot diff --git a/performance/openmp/osc_chain_speedup.sh b/performance/openmp/osc_chain_speedup.sh deleted file mode 100755 index 9d4c9109..00000000 --- a/performance/openmp/osc_chain_speedup.sh +++ /dev/null @@ -1,38 +0,0 @@ -#!/bin/zsh - -export LC_NUMERIC=en_US.UTF-8 -declare -A times - -export OMP_SCHEDULE=static -export OMP_PROC_BIND=true -repeat=2 - -function run { - n=$1 - steps=$2 - printf "# n=$n steps=$steps repeat=$repeat\n" - printf '"block"' - for b in gcc icc ; do - for s in s t ; do - for t in med mul ; do - printf "\t\"$b-$s-$t\"" - done - done - done - for block in 1 2 4 8 16 32 64; do - printf '\n%d' $block - for build in gcc-4.7 intel-linux ; do - bench="bin/$build/release/osc_chain_1d" - for split in 1 0 ; do - med=$($bench $n $block $steps $repeat $split | tail -1 | awk '{print $4}') - times[$build-$split-$block]=$med - speedup=$((${times[$build-$split-1]}/$med)) - printf '\t%f\t%f' $med $speedup - done - done - done - printf '\n\n\n' -} - -run 4096 1024 | tee osc_chain_speedup-short.dat -run 524288 10 | tee osc_chain_speedup-long.dat diff --git a/performance/performance.py b/performance/performance.py deleted file mode 100644 index a51ce32b..00000000 --- a/performance/performance.py +++ /dev/null @@ -1,70 +0,0 @@ -""" - Copyright 2011 Mario Mulansky - Copyright 2012 Karsten Ahnert - - Distributed under the Boost Software License, Version 1.0. - (See accompanying file LICENSE_1_0.txt or - copy at http://www.boost.org/LICENSE_1_0.txt) -""" - - -from os import popen -from os import system -from os.path import isfile -from numpy import * -#from pylab import * - -#toolset = "gcc-4.5" -#toolset = "intel-11.1" -toolset = "msvc" -#toolset = "msvc-10.0" - -#bin_path = "bin/gcc-4.5/release/" -#bin_path = "bin/intel-linux-11.1/release/" -bin_path = "bin\\msvc-10.0\\release\\threading-multi\\" -extension = ".exe" -#extension = "" - -bins = [ "odeint_rk4_lorenz_array" , "odeint_rk4_lorenz_range" , "generic_odeint_rk4_lorenz" , "nr_rk4_lorenz" , "rt_generic_rk4_lorenz" , "gsl_rk4_lorenz" ] - -results = [] - -print "Performance tests for " , bin_path -print - -for bin in bins: - #system( "bjam toolset=" + toolset + " -a " + bin ); - if isfile( bin_path + bin + extension): - print "Running" , bin - res = popen( bin_path+bin+extension ).read() - print bin , res - results.append( res ) - else: - print "no executable found:" , bin_path + bin + extension - results.append( 0 ) - -print "Results from" , bin_path -print - -for i in range(len(bins)): - print bins[i] , results[i] - -res = array( results , dtype='float' ) -savetxt( bin_path + "rk4_lorenz.dat" , res ) - -res = 100*res[0]/res - -bar_width = 0.6 - -""" -figure(1) -title("Runge-Kutta 4 with " + toolset , fontsize=20) -bar( arange(6) , res , bar_width , color='blue' , linewidth=4 , edgecolor='blue' , ecolor='red') #, elinewidth=2, ecolor='red' ) -xlim( -0.5 , 5.5+bar_width ) -xticks( arange(6)+bar_width/2 , ('array' , 'range' , 'generic' , 'NR' , 'rt gen' , 'gsl' ) ) -ylabel('Performance in %' , fontsize=20) - -savefig( bin_path + "rk4_lorenz.png" ) - -show() -""" diff --git a/performance/phase_lattice.hpp b/performance/phase_lattice.hpp deleted file mode 100644 index 6657edee..00000000 --- a/performance/phase_lattice.hpp +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright 2011 Mario Mulansky - * Copyright 2012 Karsten Ahnert - * - * Distributed under the Boost Software License, Version 1.0. - * (See accompanying file LICENSE_1_0.txt or - * copy at http://www.boost.org/LICENSE_1_0.txt) - */ - -#include - -#include - -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 - -#include -#include -#include - -template< size_t N > -struct phase_lattice_mkl -{ - typedef double value_type; - typedef boost::array< value_type , N > state_type; - - value_type m_epsilon; - state_type m_omega; - state_type m_tmp; - - phase_lattice_mkl() : m_epsilon( 6.0/(N*N) ) // should be < 8/N^2 to see phase locking - { - for( size_t i=1 ; i -#include -#include -#include - -#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; - - -template< class Stepper > -void run( Stepper &stepper , const size_t num_of_steps = 20000000 , const double dt = 1E-10 ) -{ - const size_t loops = 20; - - accumulator_type acc; - timer_type timer; - - srand( 12312354 ); - - // transient - //stepper.reset_init_cond( ); - //for( size_t i = 0 ; i < num_of_steps ; ++i ) - // stepper.do_step( dt ); - - for( size_t n=0 ; n0 ) - { // take first run as transient - acc(timer.elapsed()); - clog.precision(8); - clog.width(10); - clog << acc << " " << stepper.state(0) << endl; - } - } - cout << acc << endl; -} diff --git a/performance/rt_algebra.hpp b/performance/rt_algebra.hpp deleted file mode 100644 index e4805aac..00000000 --- a/performance/rt_algebra.hpp +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright 2011 Mario Mulansky - * Copyright 2012 Karsten Ahnert - * - * Distributed under the Boost Software License, Version 1.0. - * (See accompanying file LICENSE_1_0.txt or - * copy at http://www.boost.org/LICENSE_1_0.txt) - */ - - -#include - -using namespace std; - -struct rt_algebra -{ - template< typename T , size_t dim > - inline static void foreach( boost::array< T , dim > & x_tmp , - const boost::array< T , dim > &x , - //const vector< double > &a , - const double* a , - const boost::array< T , dim > *k_vector , - const double dt , const size_t s ) - { - for( size_t i=0 ; i - -#include "rt_algebra.hpp" - -using namespace std; - -template< class StateType > -class rt_explicit_rk -{ -public: - typedef StateType state_type; - typedef double* const * coeff_a_type; - typedef vector< double > coeff_b_type; - typedef vector< double > coeff_c_type; - - rt_explicit_rk( size_t stage_count ) : m_s( stage_count ) - { - m_F = new state_type[ m_s ]; - } - - rt_explicit_rk( const size_t stage_count , - const coeff_a_type a , - const coeff_b_type &b , const coeff_c_type &c ) - : m_s( stage_count ) , m_a( a ) , m_b( b ) , m_c( c ) - { - m_F = new state_type[ m_s ]; - } - - ~rt_explicit_rk() - { - delete[] m_F; - } - - /* void set_params( coeff_a_type &a , coeff_b_type &b , coeff_c_type &c ) - { - m_a = a; - m_b = b; - m_c = c; - }*/ - - template< class System > - void do_step( System sys , state_type &x , const double t , const double dt ) - { - // first stage separately - sys( x , m_F[0] , t + m_c[0]*t ); - if( m_s == 1 ) - rt_algebra::foreach( x , x , &m_b[0] , m_F , dt , 1 ); - else - rt_algebra::foreach( m_x_tmp , x , m_a[0] , m_F , dt , 1 ); - - for( size_t stage = 2 ; stage <= m_s ; ++stage ) - { - sys( m_x_tmp , m_F[stage-1] , t + m_c[stage-1]*dt ); - if( stage == m_s ) - rt_algebra::foreach( x , x , &m_b[0] , m_F , dt , stage-1 ); - else - rt_algebra::foreach( m_x_tmp , x , m_a[stage-1] , m_F , dt , stage-1 ); - } - } - - -private: - const size_t m_s; - const coeff_a_type m_a; - const coeff_b_type m_b; - const coeff_c_type m_c; - - state_type m_x_tmp; - state_type *m_F; -}; - -#endif /* RT_EXPLICIT_RK_HPP_ */ diff --git a/performance/rt_generic_rk4_lorenz.cpp b/performance/rt_generic_rk4_lorenz.cpp deleted file mode 100644 index ce4e93b5..00000000 --- a/performance/rt_generic_rk4_lorenz.cpp +++ /dev/null @@ -1,81 +0,0 @@ -/* - * rt_generic_rk4_lorenz.cpp - * - * Copyright 2011 Mario Mulansky - * Copyright 2012 Karsten Ahnert - * - * Distributed under the Boost Software License, Version 1.0. - * (See accompanying file LICENSE_1_0.txt or - * copy at http://www.boost.org/LICENSE_1_0.txt) - */ - - -#include - -#include "rt_explicit_rk.hpp" - -#include "rk_performance_test_case.hpp" - -#include "lorenz.hpp" - -typedef boost::array< double , 3 > 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( const double * const * a , - const rk_stepper_type::coeff_b_type &b , - const rk_stepper_type::coeff_c_type &c ) - : m_stepper( stage_count , - (rk_stepper_type::coeff_a_type) a , b , c ) - { } - - void reset_init_cond() - { - m_x[0] = 10.0 * rand() / RAND_MAX; - m_x[1] = 10.0 * rand() / RAND_MAX; - m_x[2] = 10.0 * rand() / RAND_MAX; - m_t = 0.0; - } - - inline void do_step( const double dt ) - { - m_stepper.do_step( lorenz() , 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() -{ - - const double a_tmp[3*4/2] = { 0.5 , - 0.0 , 1.0 , - 0.0 , 0.0 , 1.0 }; - const double* const a[3] = { a_tmp , a_tmp+1 , a_tmp+3 }; - - 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; - - rt_generic_wrapper stepper( a , b , c ); - - run( stepper ); -} diff --git a/performance/rt_generic_rk4_phase_lattice.cpp b/performance/rt_generic_rk4_phase_lattice.cpp deleted file mode 100644 index 0464f691..00000000 --- a/performance/rt_generic_rk4_phase_lattice.cpp +++ /dev/null @@ -1,83 +0,0 @@ -/* - * rt_generic_rk4_lorenz.cpp - * - * Copyright 2011 Mario Mulansky - * Copyright 2012 Karsten Ahnert - * - * Distributed under the Boost Software License, Version 1.0. - * (See accompanying file LICENSE_1_0.txt or - * copy at http://www.boost.org/LICENSE_1_0.txt) - */ - - -#include - -#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( const double * const * a , - const rk_stepper_type::coeff_b_type &b , - const rk_stepper_type::coeff_c_type &c ) - : m_stepper( stage_count , - (rk_stepper_type::coeff_a_type) a , b , c ) - { } - - void reset_init_cond() - { - for( size_t i = 0 ; i() , 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() -{ - srand( 12312354 ); - - const double a_tmp[3*4/2] = { 0.5 , - 0.0 , 1.0 , - 0.0 , 0.0 , 1.0 }; - const double* const a[3] = { a_tmp , a_tmp+1 , a_tmp+3 }; - - 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; - - rt_generic_wrapper stepper( a , b , c ); - - run( stepper , 10000 , 1E-6 ); -} From 6e41b57ba1b083b71a482ba3a68fe26e5db62009 Mon Sep 17 00:00:00 2001 From: Mario Mulansky Date: Fri, 17 Oct 2014 11:11:05 +0200 Subject: [PATCH 28/70] performance test sources --- performance/Makefile | 39 ++++++++++++++++++++++ performance/fortran_lorenz.f90 | 57 ++++++++++++++++++++++++++++++++ performance/odeint_rk4_array.cpp | 55 ++++++++++++++++++++++++++++++ 3 files changed, 151 insertions(+) create mode 100644 performance/Makefile create mode 100644 performance/fortran_lorenz.f90 create mode 100644 performance/odeint_rk4_array.cpp diff --git a/performance/Makefile b/performance/Makefile new file mode 100644 index 00000000..15a2fbd9 --- /dev/null +++ b/performance/Makefile @@ -0,0 +1,39 @@ +# Copyright 2011-2014 Mario Mulansky +# Copyright 2011-2014 Karsten Ahnert +# +# Distributed under the Boost Software License, Version 1.0. +# (See accompanying file LICENSE_1_0.txt or +# copy at http://www.boost.org/LICENSE_1_0.txt) + +# make sure BOOST_ROOT is pointing to your boost directory +# otherwise, set it here: +# BOOST_ROOT = /path/to/boost + +INCLUDES += -I../../include/ -I$(BOOST_ROOT) +GCCFLAGS = -O3 -ffast-math -DNDEBUG +# disabling -ffast-math might give slightly better performance +ICCFLAGS = -fast -ip -inline-forceinline -DNDEBUG +# Possible options: -fp-model source -no-fma +GFORTFLAGS = -Ofast + +bin/gcc: + mkdir -p bin/gcc + +bin/intel: + mkdir -p bin/intel + +bin/gfort: + mkdir -p bin/gfort + +bin/gcc/odeint_rk4_array: odeint_rk4_array.cpp bin/gcc + g++ ${GCCFLAGS} ${INCLUDES} -o bin/gcc/odeint_rk4_array odeint_rk4_array.cpp + + +bin/intel/odeint_rk4_array: odeint_rk4_array.cpp bin/intel + icpc ${ICCFLAGS} ${INCLUDES} -o bin/intel/odeint_rk4_array odeint_rk4_array.cpp + + +bin/gfort/fortran_lorenz: fortran_lorenz.f90 bin/gfort + gfortran ${GFORTFLAGS} fortran_lorenz.f90 -o bin/gfort/fortran_lorenz + +all: bin/gcc/odeint_rk4_array bin/intel/odeint_rk4_array bin/gfort/fortran_lorenz diff --git a/performance/fortran_lorenz.f90 b/performance/fortran_lorenz.f90 new file mode 100644 index 00000000..c7b35687 --- /dev/null +++ b/performance/fortran_lorenz.f90 @@ -0,0 +1,57 @@ +program main + implicit none + + integer, parameter :: dp = 8 + real(dp), dimension(1:3) :: x + integer, parameter :: nstep = 20000000 + real(dp) :: t = 0.0_dp + real(dp) :: h = 1.0e-10_dp + integer, parameter :: nb_loops = 21 + integer, parameter :: n = 3 + integer :: k + integer :: time_begin + integer :: time_end + integer :: count_rate + real(dp) :: time + + do k = 1, nb_loops + x = [ 8.5_dp, 3.1_dp, 1.2_dp ] + call system_clock(time_begin, count_rate) + 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) + write (*,*) time, x(1) + end do +contains + subroutine xpsys(x,f) + real(dp), dimension(1:3), intent(in) :: x + real(dp), dimension(1:3), intent(out) :: f + f(1) = 10.0_dp * ( x(2) - x(1) ) + f(2) = 28.0_dp * x(1) - x(2) - x(1) * x(3) + f(3) = x(1) * x(2) - (8.0_dp / 3.0_dp) * x(3) + end subroutine xpsys + + subroutine rk4sys(n, t, x, h, nstep) + integer, intent(in) :: n + real(dp), intent(in) :: t + real(dp), dimension(1:n), intent(inout) :: x + real(dp), intent(in) :: h + integer, intent(in) :: nstep + ! Local variables + real(dp) :: h2 + real(dp), dimension(1:n) :: y, f1, f2, f3, f4 + integer :: i, k + + h2 = 0.5_dp * h + do k = 1, nstep + call xpsys(x, f1) + y = x + h2 * f1 + call xpsys(y, f2) + y = x + h2 * f2 + call xpsys(y, f3) + y = x + h * f3 + call xpsys(y, f4) + x = x + h * (f1 + 2.0_dp * (f2 + f3) + f4) / 6.0_dp + end do + end subroutine rk4sys +end program main diff --git a/performance/odeint_rk4_array.cpp b/performance/odeint_rk4_array.cpp new file mode 100644 index 00000000..ff9acd70 --- /dev/null +++ b/performance/odeint_rk4_array.cpp @@ -0,0 +1,55 @@ +/* + * odeint_rk4_lorenz_def_alg.cpp + * + * Copyright 2011 Mario Mulansky + * Copyright 2012 Karsten Ahnert + * + * Distributed under the Boost Software License, Version 1.0. + * (See accompanying file LICENSE_1_0.txt or + * copy at http://www.boost.org/LICENSE_1_0.txt) + */ + + +#include +#include + +#include +#include +#include + +#include "lorenz.hpp" + +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; +typedef runge_kutta4_classic< state_type , double , state_type , double , + range_algebra, default_operations, never_resizer > rk4_odeint_type; + + +const int loops = 21; +const int num_of_steps = 20000000; +const double dt = 1E-10; + + +int main() +{ + double min_time = 1E6; // something big + rk4_odeint_type stepper; + for( int n=0; n Date: Fri, 17 Oct 2014 11:34:37 +0200 Subject: [PATCH 29/70] some perf comments --- .../numeric/odeint/algebra/algebra_dispatcher.hpp | 4 ++-- performance/fortran_lorenz.f90 | 3 +++ performance/odeint_rk4_array.cpp | 12 ++++++++++-- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/include/boost/numeric/odeint/algebra/algebra_dispatcher.hpp b/include/boost/numeric/odeint/algebra/algebra_dispatcher.hpp index df5aabac..15ec0f02 100644 --- a/include/boost/numeric/odeint/algebra/algebra_dispatcher.hpp +++ b/include/boost/numeric/odeint/algebra/algebra_dispatcher.hpp @@ -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 > > { diff --git a/performance/fortran_lorenz.f90 b/performance/fortran_lorenz.f90 index c7b35687..26869973 100644 --- a/performance/fortran_lorenz.f90 +++ b/performance/fortran_lorenz.f90 @@ -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 diff --git a/performance/odeint_rk4_array.cpp b/performance/odeint_rk4_array.cpp index ff9acd70..6d60296f 100644 --- a/performance/odeint_rk4_array.cpp +++ b/performance/odeint_rk4_array.cpp @@ -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 #include #include @@ -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 Date: Thu, 23 Oct 2014 11:52:58 +0200 Subject: [PATCH 30/70] +vanilla c version --- performance/Makefile | 6 +++++- performance/c_lorenz.c | 49 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+), 1 deletion(-) create mode 100644 performance/c_lorenz.c diff --git a/performance/Makefile b/performance/Makefile index 15a2fbd9..d3391c32 100644 --- a/performance/Makefile +++ b/performance/Makefile @@ -12,7 +12,7 @@ INCLUDES += -I../../include/ -I$(BOOST_ROOT) GCCFLAGS = -O3 -ffast-math -DNDEBUG # disabling -ffast-math might give slightly better performance -ICCFLAGS = -fast -ip -inline-forceinline -DNDEBUG +ICCFLAGS = -Ofast -xHost -ip -inline-forceinline -DNDEBUG # Possible options: -fp-model source -no-fma GFORTFLAGS = -Ofast @@ -28,10 +28,14 @@ bin/gfort: bin/gcc/odeint_rk4_array: odeint_rk4_array.cpp bin/gcc g++ ${GCCFLAGS} ${INCLUDES} -o bin/gcc/odeint_rk4_array odeint_rk4_array.cpp +bin/gcc/c_lorenz: c_lorenz.c bin/gcc + gcc -std=c99 -Ofast -mtune=corei7-avx c_lorenz.c -o bin/gcc/c_lorenz bin/intel/odeint_rk4_array: odeint_rk4_array.cpp bin/intel icpc ${ICCFLAGS} ${INCLUDES} -o bin/intel/odeint_rk4_array odeint_rk4_array.cpp +bin/intel/c_lorenz: c_lorenz.c bin/intel + icc -std=c99 -Ofast -xHost -ansi-alias -o bin/intel/c_lorenz c_lorenz.c bin/gfort/fortran_lorenz: fortran_lorenz.f90 bin/gfort gfortran ${GFORTFLAGS} fortran_lorenz.f90 -o bin/gfort/fortran_lorenz diff --git a/performance/c_lorenz.c b/performance/c_lorenz.c new file mode 100644 index 00000000..153bbcff --- /dev/null +++ b/performance/c_lorenz.c @@ -0,0 +1,49 @@ +#include + +void lorenz(const double *x, double *restrict y) { + y[0] = 10.0 * (x[1] - x[0]); + y[1] = 28.0 * x[0] - x[1] - x[0] * x[2]; + y[2] = x[0] * x[1] - (8.0 / 3.0) * x[2]; +} + +int main(int argc, const char *argv[]) +{ + const int nb_steps = 20000000; + const double h = 1.0e-10; + const double h2 = 0.5 * h; + const double nb_loops = 21; + double x[3]; + double y[3]; + double f1[3]; + double f2[3]; + double f3[3]; + double f4[3]; + + + for (int j = 0; j < nb_loops; j++) { + x[0] = 8.5; + x[1] = 3.1; + x[2] = 1.2; + for (int k = 0; k < nb_steps; k++) { + lorenz(x, f1); + for (int i = 0; i < 3; i++) { + y[i] = x[i] + h2 * f1[i]; + } + lorenz(y, f2); + for (int i = 0; i < 3; i++) { + y[i] = x[i] + h2 * f2[i]; + } + lorenz(y, f3); + for (int i = 0; i < 3; i++) { + y[i] = x[i] + h * f3[i]; + } + lorenz(y, f4); + for (int i = 0; i < 3; i++) { + x[i] = x[i] + h * (f1[i] + 2 * (f2[i] + f3[i]) + f4[i]) / 6.0; + } + } + printf("Result: %f\n", x[0]); + } + + return 0; +} From 32a17b9f8ae61c6dd99ca287b3dec5eb50edf4e4 Mon Sep 17 00:00:00 2001 From: Mario Mulansky Date: Mon, 3 Nov 2014 12:49:25 +0100 Subject: [PATCH 31/70] better figure title --- performance/plot_result.py | 56 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 performance/plot_result.py diff --git a/performance/plot_result.py b/performance/plot_result.py new file mode 100644 index 00000000..efc2fb96 --- /dev/null +++ b/performance/plot_result.py @@ -0,0 +1,56 @@ +""" + Copyright 2011-2014 Mario Mulansky + Copyright 2011-2014 Karsten Ahnert + + Distributed under the Boost Software License, Version 1.0. + (See accompanying file LICENSE_1_0.txt or + copy at http://www.boost.org/LICENSE_1_0.txt) +""" + +import numpy as np +from matplotlib import pyplot as plt + +plt.rc("font", size=16) + + +def get_runtime_from_file(filename): + gcc_perf_file = open(filename, 'r') + for line in gcc_perf_file: + if "Minimal Runtime:" in line: + return float(line.split(":")[-1]) + + +t_gcc = [get_runtime_from_file("perf_workbook/odeint_rk4_array_gcc.perf"), + get_runtime_from_file("perf_ariel/odeint_rk4_array_gcc.perf"), + get_runtime_from_file("perf_lyra/odeint_rk4_array_gcc.perf")] + +t_intel = [get_runtime_from_file("perf_workbook/odeint_rk4_array_intel.perf"), + get_runtime_from_file("perf_ariel/odeint_rk4_array_intel.perf"), + get_runtime_from_file("perf_lyra/odeint_rk4_array_intel.perf")] + +t_gfort = [get_runtime_from_file("perf_workbook/odeint_rk4_array_gfort.perf"), + get_runtime_from_file("perf_ariel/odeint_rk4_array_gfort.perf"), + get_runtime_from_file("perf_lyra/odeint_rk4_array_gfort.perf")] + +ind = np.arange(3) # the x locations for the groups +width = 0.2 # the width of the bars + +fig = plt.figure() +ax = fig.add_subplot(111) +rects1 = ax.bar(ind, t_gcc, width, color='b', label="odeint gcc") +rects2 = ax.bar(ind+width, t_intel, width, color='g', label="odeint intel") +rects3 = ax.bar(ind+2*width, t_gfort, width, color='c', label="gfort") + +ax.axis([-width, 2.0+4*width, 0.0, 0.85]) +ax.set_ylabel('Runtime (s)') +ax.set_title('Performance for integrating the Lorenz system') +ax.set_xticks(ind + 1.5*width) +ax.set_xticklabels(('Core i5-3210M\n3.1 GHz', + 'Xeon E5-2690\n3.8 GHz', + 'Opteron 8431\n 2.4 GHz')) +ax.legend(loc='upper left', prop={'size': 16}) + +plt.savefig("perf.pdf") +plt.savefig("perf.png") + +plt.show() From 6cf39904a9e7f8c18b811d9fa01df62d637fe2e5 Mon Sep 17 00:00:00 2001 From: Mario Mulansky Date: Mon, 3 Nov 2014 14:13:47 +0100 Subject: [PATCH 32/70] c version now prints min time --- performance/Makefile | 2 +- performance/c_lorenz.c | 12 ++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/performance/Makefile b/performance/Makefile index d3391c32..641cb031 100644 --- a/performance/Makefile +++ b/performance/Makefile @@ -40,4 +40,4 @@ bin/intel/c_lorenz: c_lorenz.c bin/intel bin/gfort/fortran_lorenz: fortran_lorenz.f90 bin/gfort gfortran ${GFORTFLAGS} fortran_lorenz.f90 -o bin/gfort/fortran_lorenz -all: bin/gcc/odeint_rk4_array bin/intel/odeint_rk4_array bin/gfort/fortran_lorenz +all: bin/gcc/odeint_rk4_array bin/intel/odeint_rk4_array bin/gcc/c_lorenz bin/intel/c_lorenz bin/gfort/fortran_lorenz diff --git a/performance/c_lorenz.c b/performance/c_lorenz.c index 153bbcff..85aba7fd 100644 --- a/performance/c_lorenz.c +++ b/performance/c_lorenz.c @@ -1,4 +1,6 @@ #include +#include +#include void lorenz(const double *x, double *restrict y) { y[0] = 10.0 * (x[1] - x[0]); @@ -18,12 +20,15 @@ int main(int argc, const char *argv[]) double f2[3]; double f3[3]; double f4[3]; - + double min_time = 1E6; + clock_t begin, end; + double time_spent; for (int j = 0; j < nb_loops; j++) { x[0] = 8.5; x[1] = 3.1; x[2] = 1.2; + begin = clock(); for (int k = 0; k < nb_steps; k++) { lorenz(x, f1); for (int i = 0; i < 3; i++) { @@ -42,8 +47,11 @@ int main(int argc, const char *argv[]) x[i] = x[i] + h * (f1[i] + 2 * (f2[i] + f3[i]) + f4[i]) / 6.0; } } - printf("Result: %f\n", x[0]); + end = clock(); + min_time = fmin(min_time, (double)(end-begin)/CLOCKS_PER_SEC); + printf("Result: %f\t runtime: %f\n", x[0], (double)(end-begin)/CLOCKS_PER_SEC); } + printf("Minimal Runtime: %f\n", min_time); return 0; } From dcabba3a01f1005449b392a492a4c00069a95c15 Mon Sep 17 00:00:00 2001 From: Mario Mulansky Date: Mon, 10 Nov 2014 15:01:25 +0100 Subject: [PATCH 33/70] +SIMD performance test --- performance/SIMD/Makefile | 14 +++ performance/SIMD/perf_roessler.sh | 24 +++++ performance/SIMD/roessler.cpp | 117 ++++++++++++++++++++++++ performance/SIMD/roessler_simd.cpp | 138 +++++++++++++++++++++++++++++ 4 files changed, 293 insertions(+) create mode 100644 performance/SIMD/Makefile create mode 100755 performance/SIMD/perf_roessler.sh create mode 100644 performance/SIMD/roessler.cpp create mode 100644 performance/SIMD/roessler_simd.cpp diff --git a/performance/SIMD/Makefile b/performance/SIMD/Makefile new file mode 100644 index 00000000..02418514 --- /dev/null +++ b/performance/SIMD/Makefile @@ -0,0 +1,14 @@ +# Copyright 2014 Mario Mulansky +# +# Distributed under the Boost Software License, Version 1.0. +# (See accompanying file LICENSE_1_0.txt or +# copy at http://www.boost.org/LICENSE_1_0.txt) + +# make sure BOOST_ROOT is pointing to your boost directory +# otherwise, set it here: +# BOOST_ROOT = /path/to/boost +# you also need NT2s SIMD libary available set the include path here: +# SIMD_INCLUDE = /path/to/simd/include + +INCLUDES += -I../../include/ -I$(BOOST_ROOT) -I${SIMD_INCLUDE} +CXXFLAGS = -O3 -mtune=native -march=native -ffast-math -std=c++11 -DNDEBUG ${INCLUDES} diff --git a/performance/SIMD/perf_roessler.sh b/performance/SIMD/perf_roessler.sh new file mode 100755 index 00000000..530860fd --- /dev/null +++ b/performance/SIMD/perf_roessler.sh @@ -0,0 +1,24 @@ +#!/bin/bash +echo "Running on ${HOSTNAME}" + +#make -B roessler roessler_simd + +out_dir=perf_${HOSTNAME} +mkdir -p ${out_dir} + +for N in 256 1024 4096 16384 65536 262144 1048576 4194304 16777216 67108864 +do + steps=`expr 4 \* 67108864 / ${N}` + for exe in "roessler" "roessler_simd" + do + rm -f ${out_dir}/${exe}_N${N}.times + for i in {0..4} + do + likwid-pin -cS0:0 ./${exe} ${N} ${steps} >> ${out_dir}/${exe}_N${N}.times + done + for perf_ctr in "FLOPS_DP" "FLOPS_AVX" "L2" "L3" "MEM" + do + likwid-perfctr -CS0:0 -g ${perf_ctr} ./${exe} ${N} ${steps} > ${out_dir}/${exe}_${perf_ctr}_N${N}.perf + done + done +done diff --git a/performance/SIMD/roessler.cpp b/performance/SIMD/roessler.cpp new file mode 100644 index 00000000..6ba70d93 --- /dev/null +++ b/performance/SIMD/roessler.cpp @@ -0,0 +1,117 @@ +/* + * Simulation of an ensemble of Roessler attractors + * + * Copyright 2014 Mario Mulansky + * + * Distributed under the Boost Software License, Version 1.0. + * (See accompanying file LICENSE_1_0.txt or + * copy at http://www.boost.org/LICENSE_1_0.txt) + * + */ + + +#include +#include +#include + +#include +#include + +#include + +namespace odeint = boost::numeric::odeint; + +typedef boost::timer timer_type; + +typedef boost::array state_type; +typedef std::vector state_vec; + +//--------------------------------------------------------------------------- +struct roessler_system { + const double m_a, m_b, m_c; + + roessler_system(const double a, const double b, const double c) + : m_a(a), m_b(b), m_c(c) + {} + + void operator()(const state_type &x, state_type &dxdt, const double t) const + { + dxdt[0] = -x[1] - x[2]; + dxdt[1] = x[0] + m_a * x[1]; + dxdt[2] = m_b + x[2] * (x[0] - m_c); + } +}; + +//--------------------------------------------------------------------------- +int main(int argc, char *argv[]) { +if(argc<3) +{ + std::cerr << "Expected size and steps as parameter" << std::endl; + exit(1); +} +const size_t n = atoi(argv[1]); +const size_t steps = atoi(argv[2]); +//const size_t steps = 50; + +const double dt = 0.01; + +const double a = 0.2; +const double b = 1.0; +const double c = 9.0; + +// random initial conditions on the device +std::vector x(n), y(n), z(n); +std::default_random_engine generator; +std::uniform_real_distribution distribution_xy(-8.0, 8.0); +std::uniform_real_distribution distribution_z(0.0, 20.0); +auto rand_xy = std::bind(distribution_xy, std::ref(generator)); +auto rand_z = std::bind(distribution_z, std::ref(generator)); +std::generate(x.begin(), x.end(), rand_xy); +std::generate(y.begin(), y.end(), rand_xy); +std::generate(z.begin(), z.end(), rand_z); + +state_vec state(n); +for(size_t i=0; i stepper; + +roessler_system sys(a, b, c); + +timer_type timer; + +double t = 0.0; + +for (int step = 0; step < steps; step++) +{ + for(size_t i=0; i +#include +#include + +#include +#include + +#include +#include +#include +#include +#include +#include + +namespace odeint = boost::numeric::odeint; + +typedef boost::timer timer_type; + +static const size_t dim = 3; // roessler is 3D + +typedef boost::simd::pack simd_pack; +typedef boost::array state_type; +typedef std::vector state_vec; + +static const size_t pack_size = simd_pack::static_size; + +//--------------------------------------------------------------------------- +struct roessler_system { + const double m_a, m_b, m_c; + + roessler_system(const double a, const double b, const double c) + : m_a(a), m_b(b), m_c(c) + {} + + void operator()(const state_type &x, state_type &dxdt, const double t) const + { + dxdt[0] = -1.0*x[1] - x[2]; + dxdt[1] = x[0] + m_a * x[1]; + dxdt[2] = m_b + x[2] * (x[0] - m_c); + } +}; + +//--------------------------------------------------------------------------- +int main(int argc, char *argv[]) { +if(argc<3) +{ + std::cerr << "Expected size and steps as parameter" << std::endl; + exit(1); +} +const size_t n = atoi(argv[1]); +const size_t steps = atoi(argv[2]); + +const double dt = 0.01; + +const double a = 0.2; +const double b = 1.0; +const double c = 9.0; + +// random initial conditions on the device +std::vector x(n), y(n), z(n); +std::default_random_engine generator; +std::uniform_real_distribution distribution_xy(-8.0, 8.0); +std::uniform_real_distribution distribution_z(0.0, 20.0); +auto rand_xy = std::bind(distribution_xy, std::ref(generator)); +auto rand_z = std::bind(distribution_z, std::ref(generator)); +std::generate(x.begin(), x.end(), rand_xy); +std::generate(y.begin(), y.end(), rand_xy); +std::generate(z.begin(), z.end(), rand_z); + +state_vec state(n/pack_size); +for(size_t i=0; i stepper; + +roessler_system sys(a, b, c); + +timer_type timer; + +double t = 0.0; + +for(int step = 0; step < steps; step++) +{ + for(size_t i = 0; i < n/pack_size; ++i) + { + stepper.do_step(sys, state[i], t, dt); + } + t += dt; +} + +std::cout << "Integration finished, runtime for " << steps << " steps: "; +std::cout << timer.elapsed() << " s" << std::endl; + +// compute some accumulation to make sure all results have been computed +simd_pack s_pack = 0.0; +for(size_t i = 0; i < n/pack_size; ++i) +{ + s_pack += state[i][0]; +} + +double s = 0.0; +for(size_t p=0; p Date: Mon, 10 Nov 2014 18:36:39 +0100 Subject: [PATCH 34/70] test --- performance/SIMD/Makefile | 7 ++++++- performance/SIMD/roessler.cpp | 7 ++++++- performance/SIMD/roessler_simd.cpp | 12 +++++++++++- 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/performance/SIMD/Makefile b/performance/SIMD/Makefile index 02418514..970bdf75 100644 --- a/performance/SIMD/Makefile +++ b/performance/SIMD/Makefile @@ -11,4 +11,9 @@ # SIMD_INCLUDE = /path/to/simd/include INCLUDES += -I../../include/ -I$(BOOST_ROOT) -I${SIMD_INCLUDE} -CXXFLAGS = -O3 -mtune=native -march=native -ffast-math -std=c++11 -DNDEBUG ${INCLUDES} +#CXXFLAGS = -O3 -ffast-math -march=core-avx-i -std=c++0x -DNDEBUG -I${ODEINT_ROOT} -I${BOOST_ROOT} -I${SIMD_INCLUDE} +# -mtune=native -march=native + +CXXFLAGS = -Ofast -xHost -fno-alias -ip -inline-forceinline -std=c++0x -DNDEBUG ${INCLUDES} +CXX = icpc +CC = icpc diff --git a/performance/SIMD/roessler.cpp b/performance/SIMD/roessler.cpp index 6ba70d93..077488cb 100644 --- a/performance/SIMD/roessler.cpp +++ b/performance/SIMD/roessler.cpp @@ -78,8 +78,13 @@ for(size_t i=0; i(m_b) + x[2] * (x[0] - boost::simd::splat(m_c)); + // std::clog << "rhs: " << tmp << std::endl; dxdt[2] = m_b + x[2] * (x[0] - m_c); + // std::clog << "rhs: " << dxdt[2] << std::endl; } }; @@ -91,10 +97,12 @@ for(size_t i=0; i Date: Mon, 10 Nov 2014 19:00:58 +0100 Subject: [PATCH 35/70] ARCH added to Makefile --- performance/SIMD/Makefile | 11 +++++++---- performance/SIMD/perf_roessler.sh | 2 -- performance/SIMD/roessler_simd.cpp | 6 ------ 3 files changed, 7 insertions(+), 12 deletions(-) diff --git a/performance/SIMD/Makefile b/performance/SIMD/Makefile index 970bdf75..aae510a8 100644 --- a/performance/SIMD/Makefile +++ b/performance/SIMD/Makefile @@ -10,10 +10,13 @@ # you also need NT2s SIMD libary available set the include path here: # SIMD_INCLUDE = /path/to/simd/include -INCLUDES += -I../../include/ -I$(BOOST_ROOT) -I${SIMD_INCLUDE} -#CXXFLAGS = -O3 -ffast-math -march=core-avx-i -std=c++0x -DNDEBUG -I${ODEINT_ROOT} -I${BOOST_ROOT} -I${SIMD_INCLUDE} -# -mtune=native -march=native +# change this if you want to cross-compile +ARCH = Host +# ARCH = AVX +# ARCH = SSE4.2 -CXXFLAGS = -Ofast -xHost -fno-alias -ip -inline-forceinline -std=c++0x -DNDEBUG ${INCLUDES} CXX = icpc CC = icpc + +INCLUDES += -I../../include/ -I$(BOOST_ROOT) -I${SIMD_INCLUDE} +CXXFLAGS = -Ofast -x${ARCH} -fno-alias -ip -inline-forceinline -std=c++0x -DNDEBUG ${INCLUDES} diff --git a/performance/SIMD/perf_roessler.sh b/performance/SIMD/perf_roessler.sh index 530860fd..a4715042 100755 --- a/performance/SIMD/perf_roessler.sh +++ b/performance/SIMD/perf_roessler.sh @@ -1,8 +1,6 @@ #!/bin/bash echo "Running on ${HOSTNAME}" -#make -B roessler roessler_simd - out_dir=perf_${HOSTNAME} mkdir -p ${out_dir} diff --git a/performance/SIMD/roessler_simd.cpp b/performance/SIMD/roessler_simd.cpp index 41016653..a8af60be 100644 --- a/performance/SIMD/roessler_simd.cpp +++ b/performance/SIMD/roessler_simd.cpp @@ -47,15 +47,9 @@ struct roessler_system { void operator()(const state_type &x, state_type &dxdt, const double t) const { - // std::clog << "rhs: " << dxdt.size() << std::endl; dxdt[0] = -1.0*x[1] - x[2]; - // std::clog << "rhs: " << dxdt[0] << std::endl; dxdt[1] = x[0] + m_a * x[1]; - // std::clog << "rhs: " << dxdt[1] << std::endl; - //simd_pack tmp = boost::simd::splat(m_b) + x[2] * (x[0] - boost::simd::splat(m_c)); - // std::clog << "rhs: " << tmp << std::endl; dxdt[2] = m_b + x[2] * (x[0] - m_c); - // std::clog << "rhs: " << dxdt[2] << std::endl; } }; From 8d9645df668a6d412e9214b81cba3ec9f67626b8 Mon Sep 17 00:00:00 2001 From: Mario Mulansky Date: Mon, 10 Nov 2014 19:03:34 +0100 Subject: [PATCH 36/70] out file name --- performance/SIMD/perf_roessler.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/performance/SIMD/perf_roessler.sh b/performance/SIMD/perf_roessler.sh index a4715042..9e577941 100755 --- a/performance/SIMD/perf_roessler.sh +++ b/performance/SIMD/perf_roessler.sh @@ -1,4 +1,4 @@ -#!/bin/bash +git #!/bin/bash echo "Running on ${HOSTNAME}" out_dir=perf_${HOSTNAME} @@ -16,7 +16,7 @@ do done for perf_ctr in "FLOPS_DP" "FLOPS_AVX" "L2" "L3" "MEM" do - likwid-perfctr -CS0:0 -g ${perf_ctr} ./${exe} ${N} ${steps} > ${out_dir}/${exe}_${perf_ctr}_N${N}.perf + likwid-perfctr -CS0:0 -g ${perf_ctr} ./${exe} ${N} ${steps} > ${out_dir}/${exe}_${N}_${perf_ctr}.perf done done done From 7f898908009e312f6d41035b669770b5e91217d1 Mon Sep 17 00:00:00 2001 From: Mario Mulansky Date: Mon, 10 Nov 2014 19:07:32 +0100 Subject: [PATCH 37/70] typo --- performance/SIMD/perf_roessler.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/performance/SIMD/perf_roessler.sh b/performance/SIMD/perf_roessler.sh index 9e577941..5af7622a 100755 --- a/performance/SIMD/perf_roessler.sh +++ b/performance/SIMD/perf_roessler.sh @@ -1,4 +1,4 @@ -git #!/bin/bash +#!/bin/bash echo "Running on ${HOSTNAME}" out_dir=perf_${HOSTNAME} From dbc9ae9ae04a489bbd2dca1096883154aaa6d4d0 Mon Sep 17 00:00:00 2001 From: Mario Mulansky Date: Mon, 10 Nov 2014 19:09:07 +0100 Subject: [PATCH 38/70] N in filenam --- performance/SIMD/perf_roessler.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/performance/SIMD/perf_roessler.sh b/performance/SIMD/perf_roessler.sh index 5af7622a..a1094f63 100755 --- a/performance/SIMD/perf_roessler.sh +++ b/performance/SIMD/perf_roessler.sh @@ -16,7 +16,7 @@ do done for perf_ctr in "FLOPS_DP" "FLOPS_AVX" "L2" "L3" "MEM" do - likwid-perfctr -CS0:0 -g ${perf_ctr} ./${exe} ${N} ${steps} > ${out_dir}/${exe}_${N}_${perf_ctr}.perf + likwid-perfctr -CS0:0 -g ${perf_ctr} ./${exe} ${N} ${steps} > ${out_dir}/${exe}_N${N}_${perf_ctr}.perf done done done From 133fb843d32126a175caa096e34ea1d9b1ce7262 Mon Sep 17 00:00:00 2001 From: Mario Mulansky Date: Tue, 11 Nov 2014 17:32:58 +0100 Subject: [PATCH 39/70] generalized array_algebra array_algebra now works with any Array structure --- .../numeric/odeint/algebra/array_algebra.hpp | 303 +++++++++--------- test/Jamfile.v2 | 4 + 2 files changed, 164 insertions(+), 143 deletions(-) diff --git a/include/boost/numeric/odeint/algebra/array_algebra.hpp b/include/boost/numeric/odeint/algebra/array_algebra.hpp index c565d6dd..60d3b2f7 100644 --- a/include/boost/numeric/odeint/algebra/array_algebra.hpp +++ b/include/boost/numeric/odeint/algebra/array_algebra.hpp @@ -29,234 +29,251 @@ namespace odeint { struct array_algebra { - template< typename T , size_t dim , class Op > - static void for_each1( boost::array< T , dim > &s1 , Op op ) + //template< typename T , size_t dim , class Op > + template < template < typename, size_t > class Array, typename T, + size_t dim, class Op > + static void for_each1( Array< T, dim > &s1, Op op ) { for( size_t i=0 ; i - static void for_each2( boost::array< T1 , dim > &s1 , - const boost::array< T2 , dim > &s2 , Op op ) + template < template < typename, size_t > class Array, typename T, + size_t dim, class Op > + static void for_each2( Array< T, dim > &s1, const Array< T, dim > &s2, + Op op ) { for( size_t i=0 ; i - static void for_each3( boost::array< T , dim > &s1 , - const boost::array< T , dim > &s2 , - const boost::array< T , dim > &s3 , Op op ) + template < template < typename, size_t > class Array, typename T, + size_t dim, class Op > + static void for_each3( Array< T , dim > &s1 , + const Array< T , dim > &s2 , + const Array< T , dim > &s3 , Op op ) { for( size_t i=0 ; i - static void for_each3( boost::array< T , dim > &s1 , - boost::array< T , dim > &s2 , - const boost::array< T , dim > &s3 , Op op ) + template < template < typename, size_t > class Array, typename T, + size_t dim, class Op > + static void for_each3( Array< T , dim > &s1 , + Array< T , dim > &s2 , + const Array< T , dim > &s3 , Op op ) { for( size_t i=0 ; i - static void for_each4( boost::array< T , dim > &s1 , - const boost::array< T , dim > &s2 , - const boost::array< T , dim > &s3 , - const boost::array< T , dim > &s4 , Op op ) + template < template < typename, size_t > class Array, typename T, + size_t dim, class Op > + static void for_each4( Array< T , dim > &s1 , + const Array< T , dim > &s2 , + const Array< T , dim > &s3 , + const Array< T , dim > &s4 , Op op ) { for( size_t i=0 ; i - static void for_each5( boost::array< T , dim > &s1 , - const boost::array< T , dim > &s2 , - const boost::array< T , dim > &s3 , - const boost::array< T , dim > &s4 , - const boost::array< T , dim > &s5 , Op op ) + template < template < typename, size_t > class Array, typename T, + size_t dim, class Op > + static void for_each5( Array< T , dim > &s1 , + const Array< T , dim > &s2 , + const Array< T , dim > &s3 , + const Array< T , dim > &s4 , + const Array< T , dim > &s5 , Op op ) { for( size_t i=0 ; i - static void for_each6( boost::array< T , dim > &s1 , - const boost::array< T , dim > &s2 , - const boost::array< T , dim > &s3 , - const boost::array< T , dim > &s4 , - const boost::array< T , dim > &s5 , - const boost::array< T , dim > &s6 , Op op ) + template < template < typename, size_t > class Array, typename T, + size_t dim, class Op > + static void for_each6( Array< T , dim > &s1 , + const Array< T , dim > &s2 , + const Array< T , dim > &s3 , + const Array< T , dim > &s4 , + const Array< T , dim > &s5 , + const Array< T , dim > &s6 , Op op ) { for( size_t i=0 ; i - static void for_each7( boost::array< T , dim > &s1 , - const boost::array< T , dim > &s2 , - const boost::array< T , dim > &s3 , - const boost::array< T , dim > &s4 , - const boost::array< T , dim > &s5 , - const boost::array< T , dim > &s6 , - const boost::array< T , dim > &s7 , Op op ) + template < template < typename, size_t > class Array, typename T, + size_t dim, class Op > + static void for_each7( Array< T , dim > &s1 , + const Array< T , dim > &s2 , + const Array< T , dim > &s3 , + const Array< T , dim > &s4 , + const Array< T , dim > &s5 , + const Array< T , dim > &s6 , + const Array< T , dim > &s7 , Op op ) { for( size_t i=0 ; i - static void for_each8( boost::array< T , dim > &s1 , - const boost::array< T , dim > &s2 , - const boost::array< T , dim > &s3 , - const boost::array< T , dim > &s4 , - const boost::array< T , dim > &s5 , - const boost::array< T , dim > &s6 , - const boost::array< T , dim > &s7 , - const boost::array< T , dim > &s8 , Op op ) + template < template < typename, size_t > class Array, typename T, + size_t dim, class Op > + static void for_each8( Array< T , dim > &s1 , + const Array< T , dim > &s2 , + const Array< T , dim > &s3 , + const Array< T , dim > &s4 , + const Array< T , dim > &s5 , + const Array< T , dim > &s6 , + const Array< T , dim > &s7 , + const Array< T , dim > &s8 , Op op ) { for( size_t i=0 ; i - static void for_each9( boost::array< T , dim > &s1 , - const boost::array< T , dim > &s2 , - const boost::array< T , dim > &s3 , - const boost::array< T , dim > &s4 , - const boost::array< T , dim > &s5 , - const boost::array< T , dim > &s6 , - const boost::array< T , dim > &s7 , - const boost::array< T , dim > &s8 , - const boost::array< T , dim > &s9 , Op op ) + template < template < typename, size_t > class Array, typename T, + size_t dim, class Op > + static void for_each9( Array< T , dim > &s1 , + const Array< T , dim > &s2 , + const Array< T , dim > &s3 , + const Array< T , dim > &s4 , + const Array< T , dim > &s5 , + const Array< T , dim > &s6 , + const Array< T , dim > &s7 , + const Array< T , dim > &s8 , + const Array< T , dim > &s9 , Op op ) { for( size_t i=0 ; i - static void for_each10( boost::array< T , dim > &s1 , - const boost::array< T , dim > &s2 , - const boost::array< T , dim > &s3 , - const boost::array< T , dim > &s4 , - const boost::array< T , dim > &s5 , - const boost::array< T , dim > &s6 , - const boost::array< T , dim > &s7 , - const boost::array< T , dim > &s8 , - const boost::array< T , dim > &s9 , - const boost::array< T , dim > &s10 , Op op ) + template < template < typename, size_t > class Array, typename T, + size_t dim, class Op > + static void for_each10( Array< T , dim > &s1 , + const Array< T , dim > &s2 , + const Array< T , dim > &s3 , + const Array< T , dim > &s4 , + const Array< T , dim > &s5 , + const Array< T , dim > &s6 , + const Array< T , dim > &s7 , + const Array< T , dim > &s8 , + const Array< T , dim > &s9 , + const Array< T , dim > &s10 , Op op ) { for( size_t i=0 ; i - static void for_each11( boost::array< T , dim > &s1 , - const boost::array< T , dim > &s2 , - const boost::array< T , dim > &s3 , - const boost::array< T , dim > &s4 , - const boost::array< T , dim > &s5 , - const boost::array< T , dim > &s6 , - const boost::array< T , dim > &s7 , - const boost::array< T , dim > &s8 , - const boost::array< T , dim > &s9 , - const boost::array< T , dim > &s10 , - const boost::array< T , dim > &s11 , Op op ) + template < template < typename, size_t > class Array, typename T, + size_t dim, class Op > + static void for_each11( Array< T , dim > &s1 , + const Array< T , dim > &s2 , + const Array< T , dim > &s3 , + const Array< T , dim > &s4 , + const Array< T , dim > &s5 , + const Array< T , dim > &s6 , + const Array< T , dim > &s7 , + const Array< T , dim > &s8 , + const Array< T , dim > &s9 , + const Array< T , dim > &s10 , + const Array< T , dim > &s11 , Op op ) { for( size_t i=0 ; i - static void for_each12( boost::array< T , dim > &s1 , - const boost::array< T , dim > &s2 , - const boost::array< T , dim > &s3 , - const boost::array< T , dim > &s4 , - const boost::array< T , dim > &s5 , - const boost::array< T , dim > &s6 , - const boost::array< T , dim > &s7 , - const boost::array< T , dim > &s8 , - const boost::array< T , dim > &s9 , - const boost::array< T , dim > &s10 , - const boost::array< T , dim > &s11 , - const boost::array< T , dim > &s12 , Op op ) + template < template < typename, size_t > class Array, typename T, + size_t dim, class Op > + static void for_each12( Array< T , dim > &s1 , + const Array< T , dim > &s2 , + const Array< T , dim > &s3 , + const Array< T , dim > &s4 , + const Array< T , dim > &s5 , + const Array< T , dim > &s6 , + const Array< T , dim > &s7 , + const Array< T , dim > &s8 , + const Array< T , dim > &s9 , + const Array< T , dim > &s10 , + const Array< T , dim > &s11 , + const Array< T , dim > &s12 , Op op ) { for( size_t i=0 ; i - static void for_each13( boost::array< T , dim > &s1 , - const boost::array< T , dim > &s2 , - const boost::array< T , dim > &s3 , - const boost::array< T , dim > &s4 , - const boost::array< T , dim > &s5 , - const boost::array< T , dim > &s6 , - const boost::array< T , dim > &s7 , - const boost::array< T , dim > &s8 , - const boost::array< T , dim > &s9 , - const boost::array< T , dim > &s10 , - const boost::array< T , dim > &s11 , - const boost::array< T , dim > &s12 , - const boost::array< T , dim > &s13 , Op op ) + template < template < typename, size_t > class Array, typename T, + size_t dim, class Op > + static void for_each13( Array< T , dim > &s1 , + const Array< T , dim > &s2 , + const Array< T , dim > &s3 , + const Array< T , dim > &s4 , + const Array< T , dim > &s5 , + const Array< T , dim > &s6 , + const Array< T , dim > &s7 , + const Array< T , dim > &s8 , + const Array< T , dim > &s9 , + const Array< T , dim > &s10 , + const Array< T , dim > &s11 , + const Array< T , dim > &s12 , + const Array< T , dim > &s13 , Op op ) { for( size_t i=0 ; i - static void for_each14( boost::array< T , dim > &s1 , - const boost::array< T , dim > &s2 , - const boost::array< T , dim > &s3 , - const boost::array< T , dim > &s4 , - const boost::array< T , dim > &s5 , - const boost::array< T , dim > &s6 , - const boost::array< T , dim > &s7 , - const boost::array< T , dim > &s8 , - const boost::array< T , dim > &s9 , - const boost::array< T , dim > &s10 , - const boost::array< T , dim > &s11 , - const boost::array< T , dim > &s12 , - const boost::array< T , dim > &s13 , - const boost::array< T , dim > &s14 , Op op ) + template < template < typename, size_t > class Array, typename T, + size_t dim, class Op > + static void for_each14( Array< T , dim > &s1 , + const Array< T , dim > &s2 , + const Array< T , dim > &s3 , + const Array< T , dim > &s4 , + const Array< T , dim > &s5 , + const Array< T , dim > &s6 , + const Array< T , dim > &s7 , + const Array< T , dim > &s8 , + const Array< T , dim > &s9 , + const Array< T , dim > &s10 , + const Array< T , dim > &s11 , + const Array< T , dim > &s12 , + const Array< T , dim > &s13 , + const Array< T , dim > &s14 , Op op ) { for( size_t i=0 ; i - static void for_each15( boost::array< T , dim > &s1 , - const boost::array< T , dim > &s2 , - const boost::array< T , dim > &s3 , - const boost::array< T , dim > &s4 , - const boost::array< T , dim > &s5 , - const boost::array< T , dim > &s6 , - const boost::array< T , dim > &s7 , - const boost::array< T , dim > &s8 , - const boost::array< T , dim > &s9 , - const boost::array< T , dim > &s10 , - const boost::array< T , dim > &s11 , - const boost::array< T , dim > &s12 , - const boost::array< T , dim > &s13 , - const boost::array< T , dim > &s14 , - const boost::array< T , dim > &s15 , Op op ) + template < template < typename, size_t > class Array, typename T, + size_t dim, class Op > + static void for_each15( Array< T , dim > &s1 , + const Array< T , dim > &s2 , + const Array< T , dim > &s3 , + const Array< T , dim > &s4 , + const Array< T , dim > &s5 , + const Array< T , dim > &s6 , + const Array< T , dim > &s7 , + const Array< T , dim > &s8 , + const Array< T , dim > &s9 , + const Array< T , dim > &s10 , + const Array< T , dim > &s11 , + const Array< T , dim > &s12 , + const Array< T , dim > &s13 , + const Array< T , dim > &s14 , + const Array< T , dim > &s15 , Op op ) { for( size_t i=0 ; i - static typename norm_result_type< boost::array< T , dim > >::type norm_inf( const boost::array< T , dim > &s ) + template < template < typename, size_t > class Array, typename T, + size_t dim> + static typename norm_result_type< Array< T , dim > >::type norm_inf( const Array< T , dim > &s ) { BOOST_USING_STD_MAX(); using std::abs; - typedef typename norm_result_type< boost::array< T , dim > >::type result_type; + typedef typename norm_result_type< Array< T , dim > >::type result_type; result_type init = static_cast< result_type >( 0 ); for( size_t i=0 ; i(abs(s[i])) ); diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index e9b721a4..f24d8f64 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -13,6 +13,9 @@ use-project boost : $(BOOST_ROOT) ; project : requirements +# explicitely include ../include directory first to make sure local odeint +# is found first + ../include&&$(BOOST_ROOT) /boost/test//boost_unit_test_framework BOOST_ALL_NO_LIB=1 static @@ -74,6 +77,7 @@ test-suite "odeint" [ compile unwrap_boost_reference.cpp ] [ compile unwrap_reference.cpp : -std=c++0x : unwrap_reference_C++11 ] [ compile-fail unwrap_reference.cpp : -std=c++98 : unwrap_reference_C++98 ] + [ compile std_array.cpp : -std=c++0x ] : valgrind ; From 61df23d75e327426a65ff26def6d9409c453155c Mon Sep 17 00:00:00 2001 From: Karsten Ahnert Date: Tue, 11 Nov 2014 17:59:06 +0100 Subject: [PATCH 40/70] fixed https://svn.boost.org/trac/boost/ticket/10499 --- .../numeric/odeint/util/unwrap_reference.hpp | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/include/boost/numeric/odeint/util/unwrap_reference.hpp b/include/boost/numeric/odeint/util/unwrap_reference.hpp index d622a5c0..bc7d423a 100644 --- a/include/boost/numeric/odeint/util/unwrap_reference.hpp +++ b/include/boost/numeric/odeint/util/unwrap_reference.hpp @@ -31,9 +31,9 @@ namespace boost { #if BOOST_NUMERIC_ODEINT_CXX11 -template class reference_wrapper; +template struct reference_wrapper; -template class unwrap_reference; +template struct unwrap_reference; #endif namespace numeric { @@ -43,24 +43,21 @@ namespace odeint { #if BOOST_NUMERIC_ODEINT_CXX11 template -class unwrap_reference +struct unwrap_reference { -public: typedef typename std::remove_reference::type type; }; template -class unwrap_reference< std::reference_wrapper > +struct unwrap_reference< std::reference_wrapper > { -public: typedef typename std::remove_reference::type type; }; template -class unwrap_reference< boost::reference_wrapper > +struct unwrap_reference< boost::reference_wrapper > { -public: - typedef typename boost::unwrap_reference::type type; + typedef typename boost::unwrap_reference::type type; }; #else From f171a84ba7e04d8889dc5a4c9bff4adb9855f9cf Mon Sep 17 00:00:00 2001 From: Mario Mulansky Date: Tue, 11 Nov 2014 18:32:11 +0100 Subject: [PATCH 41/70] algebra dispatcher now recognizes dts::array --- .../odeint/algebra/algebra_dispatcher.hpp | 23 +++++++++++++++++++ test/Jamfile.v2 | 10 ++++---- 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/include/boost/numeric/odeint/algebra/algebra_dispatcher.hpp b/include/boost/numeric/odeint/algebra/algebra_dispatcher.hpp index 15ec0f02..11739a74 100644 --- a/include/boost/numeric/odeint/algebra/algebra_dispatcher.hpp +++ b/include/boost/numeric/odeint/algebra/algebra_dispatcher.hpp @@ -19,6 +19,7 @@ #include +#include #include #include @@ -84,4 +85,26 @@ struct algebra_dispatcher< boost::numeric::ublas::matrix< T , L , A > > } } +#ifndef BOOST_NO_CXX11_HDR_ARRAY + +// Specialization for std::array if available + +#include + +namespace boost { +namespace numeric { +namespace odeint { + +// specialize for std::array +template< class T , size_t N > +struct algebra_dispatcher< std::array< T , N > > +{ + typedef array_algebra algebra_type; +}; + +} } } + +#endif + + #endif diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index f24d8f64..15d90582 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -9,15 +9,12 @@ import testing ; -use-project boost : $(BOOST_ROOT) ; +# use-project boost : $(BOOST_ROOT) ; project : requirements -# explicitely include ../include directory first to make sure local odeint -# is found first - ../include&&$(BOOST_ROOT) - /boost/test//boost_unit_test_framework BOOST_ALL_NO_LIB=1 + $(BOOST_ROOT)/stage/lib/libboost_unit_test_framework.a static clang:-Wno-unused-variable # -D_SCL_SECURE_NO_WARNINGS @@ -78,7 +75,8 @@ test-suite "odeint" [ compile unwrap_reference.cpp : -std=c++0x : unwrap_reference_C++11 ] [ compile-fail unwrap_reference.cpp : -std=c++98 : unwrap_reference_C++98 ] [ compile std_array.cpp : -std=c++0x ] - : valgrind + : + valgrind ; # also run numeric tests From a6b85655b01d63c989165df7767d0750cd6584e0 Mon Sep 17 00:00:00 2001 From: Mario Mulansky Date: Tue, 11 Nov 2014 18:38:47 +0100 Subject: [PATCH 42/70] update in travis to build boost first --- .travis.yml | 1 + test/Jamfile.v2 | 2 ++ 2 files changed, 3 insertions(+) diff --git a/.travis.yml b/.travis.yml index 59e5470f..2b960f38 100644 --- a/.travis.yml +++ b/.travis.yml @@ -26,6 +26,7 @@ before_install: - cd $BOOST_ROOT - ./bootstrap.sh + - ./bjam - cd $TRAVIS_BUILD_DIR - if [ "$TRAVIS_OS_NAME" = "osx" ] && [ "$CC" = "gcc" ]; then export CC=gcc-4.8; fi - $CC --version diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 15d90582..85171818 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -9,11 +9,13 @@ import testing ; +# disable project boost to make sure the local odeint is included first # use-project boost : $(BOOST_ROOT) ; project : requirements BOOST_ALL_NO_LIB=1 +# use test library $(BOOST_ROOT)/stage/lib/libboost_unit_test_framework.a static clang:-Wno-unused-variable From bdf011cc55693a73b16d1251ca0d8f7d22541842 Mon Sep 17 00:00:00 2001 From: Mario Mulansky Date: Tue, 11 Nov 2014 18:41:14 +0100 Subject: [PATCH 43/70] added test/numeric to std build --- Jamroot | 1 + 1 file changed, 1 insertion(+) diff --git a/Jamroot b/Jamroot index 48384e3c..6476f9a9 100644 --- a/Jamroot +++ b/Jamroot @@ -21,6 +21,7 @@ project # tests, regression tests and examples build-project test ; +build-project test/numeric ; build-project examples ; # build-project performance ; # build-project openmp ; From 54856f39138f6d62a7ed41ae7a97a916ae5400c0 Mon Sep 17 00:00:00 2001 From: Mario Mulansky Date: Wed, 12 Nov 2014 10:01:05 +0100 Subject: [PATCH 44/70] fixes #142, fixes boost include issue in bjam --- .../odeint/algebra/algebra_dispatcher.hpp | 8 +-- .../numeric/odeint/algebra/array_algebra.hpp | 6 ++- test/Jamfile.v2 | 13 +++-- test/std_array.cpp | 54 +++++++++++++++++++ 4 files changed, 71 insertions(+), 10 deletions(-) create mode 100644 test/std_array.cpp diff --git a/include/boost/numeric/odeint/algebra/algebra_dispatcher.hpp b/include/boost/numeric/odeint/algebra/algebra_dispatcher.hpp index 11739a74..88cf159e 100644 --- a/include/boost/numeric/odeint/algebra/algebra_dispatcher.hpp +++ b/include/boost/numeric/odeint/algebra/algebra_dispatcher.hpp @@ -17,9 +17,9 @@ #ifndef BOOST_NUMERIC_ODEINT_ALGEBRA_ALGEBRA_DISPATCHER_HPP_INCLUDED #define BOOST_NUMERIC_ODEINT_ALGEBRA_ALGEBRA_DISPATCHER_HPP_INCLUDED -#include +#include -#include +#include #include #include @@ -85,9 +85,9 @@ struct algebra_dispatcher< boost::numeric::ublas::matrix< T , L , A > > } } -#ifndef BOOST_NO_CXX11_HDR_ARRAY +#ifdef BOOST_NUMERIC_ODEINT_CXX11 -// Specialization for std::array if available +// c++11 mode: specialization for std::array if available #include diff --git a/include/boost/numeric/odeint/algebra/array_algebra.hpp b/include/boost/numeric/odeint/algebra/array_algebra.hpp index 60d3b2f7..471e866f 100644 --- a/include/boost/numeric/odeint/algebra/array_algebra.hpp +++ b/include/boost/numeric/odeint/algebra/array_algebra.hpp @@ -3,7 +3,11 @@ boost/numeric/odeint/algebra/array_algebra.hpp [begin_description] - Algebra for boost::array. Highly specialized for odeint. Const arguments are introduce to work with odeint. + Algebra for Arrays. Highly specialized for odeint. Const arguments are + introduce to work with odeint. + The Array algebra can be used for Array structures with two template + parameters: + Array [end_description] Copyright 2011-2013 Mario Mulansky diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 85171818..b87df666 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -6,17 +6,20 @@ # bring in rules for testing - import testing ; -# disable project boost to make sure the local odeint is included first -# use-project boost : $(BOOST_ROOT) ; +use-project boost : $(BOOST_ROOT) ; project : requirements BOOST_ALL_NO_LIB=1 -# use test library - $(BOOST_ROOT)/stage/lib/libboost_unit_test_framework.a +# we have to add this include manually to make sure local odeint is found +# before boost when bjam is run from top level odeint-v2 directory +# it seems that use-project boost and the test library linking puts the boost +# include dir first so we have to get before that + -I"include" + # use test library + /boost//unit_test_framework static clang:-Wno-unused-variable # -D_SCL_SECURE_NO_WARNINGS diff --git a/test/std_array.cpp b/test/std_array.cpp new file mode 100644 index 00000000..480256c3 --- /dev/null +++ b/test/std_array.cpp @@ -0,0 +1,54 @@ +/* + [auto_generated] + test/std_array.cpp + + [begin_description] + Checks if odeint compiles fine with the std::array using the array algebra + [end_description] + + Copyright 2009-2014 Karsten Ahnert + Copyright 2009-2014 Mario Mulansky + + Distributed under the Boost Software License, Version 1.0. + (See accompanying file LICENSE_1_0.txt or + copy at http://www.boost.org/LICENSE_1_0.txt) + */ + + +#define BOOST_TEST_MODULE odeint_std_array + +#include +#include +#include +#include +#include + +using namespace boost::unit_test; + +typedef std::array state_type; + +void rhs(const state_type &x, state_type &dxdt, const double t) +{ +} + +BOOST_AUTO_TEST_SUITE( unwrap_reference_test ) + +BOOST_AUTO_TEST_CASE( test_case ) +{ + state_type x = {0.0, 0.0, 0.0}; + + typedef boost::numeric::odeint::runge_kutta4 stepper_type; + BOOST_STATIC_ASSERT(( boost::is_same< stepper_type::algebra_type , + boost::numeric::odeint::array_algebra >::value )); + stepper_type stepper1; + stepper1.do_step(rhs, x, 0.0, 0.1); + + boost::numeric::odeint::runge_kutta4< + state_type, double, state_type, double, + boost::numeric::odeint::array_algebra > stepper; + stepper.do_step(rhs, x, 0.0, 0.1); + +} + + +BOOST_AUTO_TEST_SUITE_END() From 297e3e15e47160813039571c3216d1ee991f4b48 Mon Sep 17 00:00:00 2001 From: Mario Mulansky Date: Wed, 12 Nov 2014 10:02:15 +0100 Subject: [PATCH 45/70] remove boost build from travis --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 2b960f38..59e5470f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -26,7 +26,6 @@ before_install: - cd $BOOST_ROOT - ./bootstrap.sh - - ./bjam - cd $TRAVIS_BUILD_DIR - if [ "$TRAVIS_OS_NAME" = "osx" ] && [ "$CC" = "gcc" ]; then export CC=gcc-4.8; fi - $CC --version From da5388eb87bf52ac2c7958a4363ef123f51b7bda Mon Sep 17 00:00:00 2001 From: Mario Mulansky Date: Wed, 12 Nov 2014 11:05:47 +0100 Subject: [PATCH 46/70] fixed std_array test for gcc 4.6 (travis) --- test/std_array.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test/std_array.cpp b/test/std_array.cpp index 480256c3..350a387a 100644 --- a/test/std_array.cpp +++ b/test/std_array.cpp @@ -38,8 +38,11 @@ BOOST_AUTO_TEST_CASE( test_case ) state_type x = {0.0, 0.0, 0.0}; typedef boost::numeric::odeint::runge_kutta4 stepper_type; +// check if array algebra is selected, but only if odeint detects c++11 +#ifdef BOOST_NUMERIC_ODEINT_CXX11 BOOST_STATIC_ASSERT(( boost::is_same< stepper_type::algebra_type , boost::numeric::odeint::array_algebra >::value )); +#endif stepper_type stepper1; stepper1.do_step(rhs, x, 0.0, 0.1); From 430fe8183b5d5a24c0ee5421851a702d193ff973 Mon Sep 17 00:00:00 2001 From: Mario Mulansky Date: Wed, 12 Nov 2014 11:07:52 +0100 Subject: [PATCH 47/70] simd performance now uses aligned memory --- performance/SIMD/Makefile | 15 +++++++++++++-- performance/SIMD/roessler_simd.cpp | 8 ++++++-- performance/plot_result.py | 22 +++++++++++++++------- 3 files changed, 34 insertions(+), 11 deletions(-) diff --git a/performance/SIMD/Makefile b/performance/SIMD/Makefile index aae510a8..baa72c40 100644 --- a/performance/SIMD/Makefile +++ b/performance/SIMD/Makefile @@ -10,6 +10,9 @@ # you also need NT2s SIMD libary available set the include path here: # SIMD_INCLUDE = /path/to/simd/include +INCLUDES += -I$(BOOST_ROOT) -I${SIMD_INCLUDE} + +# INTEL COMPILER # change this if you want to cross-compile ARCH = Host # ARCH = AVX @@ -17,6 +20,14 @@ ARCH = Host CXX = icpc CC = icpc - -INCLUDES += -I../../include/ -I$(BOOST_ROOT) -I${SIMD_INCLUDE} CXXFLAGS = -Ofast -x${ARCH} -fno-alias -ip -inline-forceinline -std=c++0x -DNDEBUG ${INCLUDES} + + +# GCC COMPILER +# change this if you want to cross-compile +# ARCH = native +# # ARCH = core-avx-i + +# CXX = g++ +# CC = g++ +# CXXFLAGS = -O3 -ffast-math -mtune=${ARCH} -march=${ARCH} -std=c++0x ${INCLUDES} diff --git a/performance/SIMD/roessler_simd.cpp b/performance/SIMD/roessler_simd.cpp index a8af60be..89e3cc3d 100644 --- a/performance/SIMD/roessler_simd.cpp +++ b/performance/SIMD/roessler_simd.cpp @@ -21,19 +21,23 @@ #include #include #include +#include #include #include #include + namespace odeint = boost::numeric::odeint; +namespace simd = boost::simd; typedef boost::timer timer_type; static const size_t dim = 3; // roessler is 3D -typedef boost::simd::pack simd_pack; +typedef simd::pack simd_pack; typedef boost::array state_type; -typedef std::vector state_vec; +// use the simd allocator to get properly aligned memory +typedef std::vector< state_type, simd::allocator< state_type > > state_vec; static const size_t pack_size = simd_pack::static_size; diff --git a/performance/plot_result.py b/performance/plot_result.py index efc2fb96..f39e49fc 100644 --- a/performance/plot_result.py +++ b/performance/plot_result.py @@ -28,20 +28,28 @@ t_intel = [get_runtime_from_file("perf_workbook/odeint_rk4_array_intel.perf"), get_runtime_from_file("perf_ariel/odeint_rk4_array_intel.perf"), get_runtime_from_file("perf_lyra/odeint_rk4_array_intel.perf")] -t_gfort = [get_runtime_from_file("perf_workbook/odeint_rk4_array_gfort.perf"), - get_runtime_from_file("perf_ariel/odeint_rk4_array_gfort.perf"), - get_runtime_from_file("perf_lyra/odeint_rk4_array_gfort.perf")] +t_gfort = [get_runtime_from_file("perf_workbook/rk4_gfort.perf"), + get_runtime_from_file("perf_ariel/rk4_gfort.perf"), + get_runtime_from_file("perf_lyra/rk4_gfort.perf")] + +t_c_intel = [get_runtime_from_file("perf_workbook/rk4_c_intel.perf"), + get_runtime_from_file("perf_ariel/rk4_c_intel.perf"), + get_runtime_from_file("perf_lyra/rk4_c_intel.perf")] + +print t_c_intel + ind = np.arange(3) # the x locations for the groups -width = 0.2 # the width of the bars +width = 0.15 # the width of the bars fig = plt.figure() ax = fig.add_subplot(111) rects1 = ax.bar(ind, t_gcc, width, color='b', label="odeint gcc") rects2 = ax.bar(ind+width, t_intel, width, color='g', label="odeint intel") -rects3 = ax.bar(ind+2*width, t_gfort, width, color='c', label="gfort") +rects3 = ax.bar(ind+2*width, t_c_intel, width, color='y', label="C intel") +rects4 = ax.bar(ind+3*width, t_gfort, width, color='c', label="gfort") -ax.axis([-width, 2.0+4*width, 0.0, 0.85]) +ax.axis([-width, 2.0+5*width, 0.0, 0.85]) ax.set_ylabel('Runtime (s)') ax.set_title('Performance for integrating the Lorenz system') ax.set_xticks(ind + 1.5*width) @@ -51,6 +59,6 @@ ax.set_xticklabels(('Core i5-3210M\n3.1 GHz', ax.legend(loc='upper left', prop={'size': 16}) plt.savefig("perf.pdf") -plt.savefig("perf.png") +plt.savefig("perf.png", dpi=50) plt.show() From 2892467c29158b2f500c7ad1866b2143439e2cd5 Mon Sep 17 00:00:00 2001 From: Mario Mulansky Date: Wed, 12 Nov 2014 12:23:39 +0100 Subject: [PATCH 48/70] revert boost build hack, added note about patch --- test/Jamfile.v2 | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index b87df666..9eeec045 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -8,17 +8,19 @@ import testing ; +# make sure you are using a new version of boost.build, otherwise the local +# odeint will not be included properly +# you can fix older boost.build versions by applying the patch provided in +# odeint's root, e.g.: +# cd ~/odeint-v2 +# sudo patch /usr/share/boost-build/build/toolset.jam toolset.jam.patch + use-project boost : $(BOOST_ROOT) ; project : requirements BOOST_ALL_NO_LIB=1 -# we have to add this include manually to make sure local odeint is found -# before boost when bjam is run from top level odeint-v2 directory -# it seems that use-project boost and the test library linking puts the boost -# include dir first so we have to get before that - -I"include" - # use test library + # use test library /boost//unit_test_framework static clang:-Wno-unused-variable From 9a03751fb74bef0c4a9f184a5b8d9c7a856f6adc Mon Sep 17 00:00:00 2001 From: Mario Mulansky Date: Thu, 13 Nov 2014 10:03:10 +0100 Subject: [PATCH 49/70] simd example now support sp precision --- performance/SIMD/Makefile | 8 ++++---- performance/SIMD/roessler.cpp | 31 ++++++++++++++++-------------- performance/SIMD/roessler_simd.cpp | 31 ++++++++++++++++-------------- 3 files changed, 38 insertions(+), 32 deletions(-) diff --git a/performance/SIMD/Makefile b/performance/SIMD/Makefile index baa72c40..811acd98 100644 --- a/performance/SIMD/Makefile +++ b/performance/SIMD/Makefile @@ -10,7 +10,7 @@ # you also need NT2s SIMD libary available set the include path here: # SIMD_INCLUDE = /path/to/simd/include -INCLUDES += -I$(BOOST_ROOT) -I${SIMD_INCLUDE} +INCLUDES = -I$(BOOST_ROOT) -I${SIMD_INCLUDE} # INTEL COMPILER # change this if you want to cross-compile @@ -20,8 +20,8 @@ ARCH = Host CXX = icpc CC = icpc -CXXFLAGS = -Ofast -x${ARCH} -fno-alias -ip -inline-forceinline -std=c++0x -DNDEBUG ${INCLUDES} - +CXXFLAGS = -O3 -x${ARCH} -std=c++0x -fno-alias -inline-forceinline -DNDEBUG ${INCLUDES} +# -ip # GCC COMPILER # change this if you want to cross-compile @@ -30,4 +30,4 @@ CXXFLAGS = -Ofast -x${ARCH} -fno-alias -ip -inline-forceinline -std=c++0x -DNDEB # CXX = g++ # CC = g++ -# CXXFLAGS = -O3 -ffast-math -mtune=${ARCH} -march=${ARCH} -std=c++0x ${INCLUDES} +# CXXFLAGS = -O3 -ffast-math -mtune=${ARCH} -march=${ARCH} -std=c++0x -DNDEBUG ${INCLUDES} diff --git a/performance/SIMD/roessler.cpp b/performance/SIMD/roessler.cpp index 077488cb..4e6cc422 100644 --- a/performance/SIMD/roessler.cpp +++ b/performance/SIMD/roessler.cpp @@ -23,18 +23,21 @@ namespace odeint = boost::numeric::odeint; typedef boost::timer timer_type; -typedef boost::array state_type; +typedef double fp_type; +//typedef float fp_type; + +typedef boost::array state_type; typedef std::vector state_vec; //--------------------------------------------------------------------------- struct roessler_system { - const double m_a, m_b, m_c; + const fp_type m_a, m_b, m_c; - roessler_system(const double a, const double b, const double c) + roessler_system(const fp_type a, const fp_type b, const fp_type c) : m_a(a), m_b(b), m_c(c) {} - void operator()(const state_type &x, state_type &dxdt, const double t) const + void operator()(const state_type &x, state_type &dxdt, const fp_type t) const { dxdt[0] = -x[1] - x[2]; dxdt[1] = x[0] + m_a * x[1]; @@ -53,17 +56,17 @@ const size_t n = atoi(argv[1]); const size_t steps = atoi(argv[2]); //const size_t steps = 50; -const double dt = 0.01; +const fp_type dt = 0.01; -const double a = 0.2; -const double b = 1.0; -const double c = 9.0; +const fp_type a = 0.2; +const fp_type b = 1.0; +const fp_type c = 9.0; // random initial conditions on the device -std::vector x(n), y(n), z(n); +std::vector x(n), y(n), z(n); std::default_random_engine generator; -std::uniform_real_distribution distribution_xy(-8.0, 8.0); -std::uniform_real_distribution distribution_z(0.0, 20.0); +std::uniform_real_distribution distribution_xy(-8.0, 8.0); +std::uniform_real_distribution distribution_z(0.0, 20.0); auto rand_xy = std::bind(distribution_xy, std::ref(generator)); auto rand_z = std::bind(distribution_z, std::ref(generator)); std::generate(x.begin(), x.end(), rand_xy); @@ -86,7 +89,7 @@ std::cout << x[0] << std::endl; // Stepper type - use never_resizer for slight performance improvement -odeint::runge_kutta4_classic stepper; @@ -95,7 +98,7 @@ roessler_system sys(a, b, c); timer_type timer; -double t = 0.0; +fp_type t = 0.0; for (int step = 0; step < steps; step++) { @@ -110,7 +113,7 @@ std::cout << "Integration finished, runtime for " << steps << " steps: "; std::cout << timer.elapsed() << " s" << std::endl; // compute some accumulation to make sure all results have been computed -double s = 0.0; +fp_type s = 0.0; for(size_t i = 0; i < n; ++i) { s += state[i][0]; diff --git a/performance/SIMD/roessler_simd.cpp b/performance/SIMD/roessler_simd.cpp index 89e3cc3d..d79af4d8 100644 --- a/performance/SIMD/roessler_simd.cpp +++ b/performance/SIMD/roessler_simd.cpp @@ -34,7 +34,10 @@ typedef boost::timer timer_type; static const size_t dim = 3; // roessler is 3D -typedef simd::pack simd_pack; +typedef double fp_type; +//typedef float fp_type; + +typedef simd::pack simd_pack; typedef boost::array state_type; // use the simd allocator to get properly aligned memory typedef std::vector< state_type, simd::allocator< state_type > > state_vec; @@ -43,13 +46,13 @@ static const size_t pack_size = simd_pack::static_size; //--------------------------------------------------------------------------- struct roessler_system { - const double m_a, m_b, m_c; + const fp_type m_a, m_b, m_c; - roessler_system(const double a, const double b, const double c) + roessler_system(const fp_type a, const fp_type b, const fp_type c) : m_a(a), m_b(b), m_c(c) {} - void operator()(const state_type &x, state_type &dxdt, const double t) const + void operator()(const state_type &x, state_type &dxdt, const fp_type t) const { dxdt[0] = -1.0*x[1] - x[2]; dxdt[1] = x[0] + m_a * x[1]; @@ -67,17 +70,17 @@ if(argc<3) const size_t n = atoi(argv[1]); const size_t steps = atoi(argv[2]); -const double dt = 0.01; +const fp_type dt = 0.01; -const double a = 0.2; -const double b = 1.0; -const double c = 9.0; +const fp_type a = 0.2; +const fp_type b = 1.0; +const fp_type c = 9.0; // random initial conditions on the device -std::vector x(n), y(n), z(n); +std::vector x(n), y(n), z(n); std::default_random_engine generator; -std::uniform_real_distribution distribution_xy(-8.0, 8.0); -std::uniform_real_distribution distribution_z(0.0, 20.0); +std::uniform_real_distribution distribution_xy(-8.0, 8.0); +std::uniform_real_distribution distribution_z(0.0, 20.0); auto rand_xy = std::bind(distribution_xy, std::ref(generator)); auto rand_z = std::bind(distribution_z, std::ref(generator)); std::generate(x.begin(), x.end(), rand_xy); @@ -102,7 +105,7 @@ std::cout << "SIMD pack size: " << pack_size << std::endl; std::cout << state[0][0] << std::endl; // Stepper type -odeint::runge_kutta4_classic stepper; @@ -110,7 +113,7 @@ roessler_system sys(a, b, c); timer_type timer; -double t = 0.0; +fp_type t = 0.0; for(int step = 0; step < steps; step++) { @@ -133,7 +136,7 @@ for(size_t i = 0; i < n/pack_size; ++i) s_pack += state[i][0]; } -double s = 0.0; +fp_type s = 0.0; for(size_t p=0; p Date: Sun, 16 Nov 2014 21:02:44 +0100 Subject: [PATCH 50/70] fixes bug in stochastic euler example. --- examples/stochastic_euler.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/examples/stochastic_euler.cpp b/examples/stochastic_euler.cpp index 23474255..c98d27b0 100644 --- a/examples/stochastic_euler.cpp +++ b/examples/stochastic_euler.cpp @@ -109,10 +109,10 @@ struct ornstein_det struct ornstein_stoch { - boost::mt19937 m_rng; + boost::mt19937 &m_rng; boost::normal_distribution<> m_dist; - ornstein_stoch( double sigma ) : m_rng() , m_dist( 0.0 , sigma ) { } + ornstein_stoch( boost::mt19937 &rng , double sigma ) : m_rng( rng ) , m_dist( 0.0 , sigma ) { } void operator()( const state_type &x , state_type &dxdt ) { @@ -137,9 +137,10 @@ int main( int argc , char **argv ) using namespace boost::numeric::odeint; //[ ornstein_uhlenbeck_main + boost::mt19937 rng; double dt = 0.1; state_type x = {{ 1.0 }}; - integrate_const( stochastic_euler< N >() , make_pair( ornstein_det() , ornstein_stoch( 1.0 ) ) , + integrate_const( stochastic_euler< N >() , make_pair( ornstein_det() , ornstein_stoch( rng , 1.0 ) ), x , 0.0 , 10.0 , dt , streaming_observer() ); //] return 0; From ee3ea15d5810b6b8d8e34cfada20cb58f01ad303 Mon Sep 17 00:00:00 2001 From: Mario Mulansky Date: Fri, 19 Dec 2014 10:06:16 -0600 Subject: [PATCH 51/70] fix #144, including test case The Adams-Bashforth-Moulton stepper called the corrector step with the wrong time value, as pointed out by GregorDeCillia in Issue #144. This commit fixes this bug and adds a test to check the correct behavior. --- .../stepper/adams_bashforth_moulton.hpp | 2 +- test/numeric/Jamfile.v2 | 1 + test/numeric/abm_time_dependent.cpp | 87 +++++++++++++++++++ 3 files changed, 89 insertions(+), 1 deletion(-) create mode 100644 test/numeric/abm_time_dependent.cpp diff --git a/include/boost/numeric/odeint/stepper/adams_bashforth_moulton.hpp b/include/boost/numeric/odeint/stepper/adams_bashforth_moulton.hpp index 19b02399..6470fbb4 100644 --- a/include/boost/numeric/odeint/stepper/adams_bashforth_moulton.hpp +++ b/include/boost/numeric/odeint/stepper/adams_bashforth_moulton.hpp @@ -158,7 +158,7 @@ private: { m_resizer.adjust_size( x , detail::bind( &stepper_type::template resize_impl< StateInOut > , detail::ref( *this ) , detail::_1 ) ); m_adams_bashforth.do_step( system , x , t , m_x.m_v , dt ); - m_adams_moulton.do_step( system , x , m_x.m_v , t , x , dt , m_adams_bashforth.step_storage() ); + m_adams_moulton.do_step( system , x , m_x.m_v , t+dt , x , dt , m_adams_bashforth.step_storage() ); } else { diff --git a/test/numeric/Jamfile.v2 b/test/numeric/Jamfile.v2 index 9797900c..963bd07f 100644 --- a/test/numeric/Jamfile.v2 +++ b/test/numeric/Jamfile.v2 @@ -28,5 +28,6 @@ test-suite "odeint" [ run rosenbrock.cpp ] [ run adams_bashforth.cpp ] [ run adams_bashforth_moulton.cpp ] + [ run abm_time_dependent.cpp ] : valgrind ; diff --git a/test/numeric/abm_time_dependent.cpp b/test/numeric/abm_time_dependent.cpp new file mode 100644 index 00000000..a7695af0 --- /dev/null +++ b/test/numeric/abm_time_dependent.cpp @@ -0,0 +1,87 @@ +/* Boost numeric test of the adams-bashforth-moulton steppers test file + + Copyright 2013 Karsten Ahnert + Copyright 2013 Mario Mulansky + + Distributed under the Boost Software License, Version 1.0. + (See accompanying file LICENSE_1_0.txt or + copy at http://www.boost.org/LICENSE_1_0.txt) +*/ + +// disable checked iterator warning for msvc +#include +#ifdef BOOST_MSVC + #pragma warning(disable:4996) +#endif + +#define BOOST_TEST_MODULE numeric_adams_bashforth_moulton + +#include +#include + +#include + +#include + +#include + +using namespace boost::unit_test; +using namespace boost::numeric::odeint; +namespace mpl = boost::mpl; + +typedef double value_type; + +typedef value_type state_type; +typedef runge_kutta_fehlberg78 initializing_stepper; + + +// simple time-dependent rhs, analytic solution x[0] = 0.5*x^2 +struct simple_rhs +{ + void operator()( const state_type& x , state_type &dxdt , const double t ) const + { + dxdt = t; + } +}; + +BOOST_AUTO_TEST_SUITE( numeric_abm_time_dependent_test ) + + +/* generic test for all adams bashforth moulton steppers */ +template< class Stepper > +struct perform_abm_time_dependent_test +{ + void operator()( void ) + { + Stepper stepper; + initializing_stepper init_stepper; + const int o = stepper.order()+1; //order of the error is order of approximation + 1 + + const state_type x0 = 0.0; + state_type x1 = x0; + double t = 0.0; + double dt = 0.1; + const int steps = 10; + +integrate_n_steps( boost::ref(stepper) , simple_rhs(), x1 , t , dt , steps ); + BOOST_CHECK_LT( std::abs( 0.5 - x1 ) , std::pow( dt , o ) ); + } +}; + +typedef mpl::vector< + adams_bashforth_moulton< 2 , state_type > , + adams_bashforth_moulton< 3 , state_type > , + adams_bashforth_moulton< 4 , state_type > , + adams_bashforth_moulton< 5 , state_type > , + adams_bashforth_moulton< 6 , state_type > , + adams_bashforth_moulton< 7 , state_type > , + adams_bashforth_moulton< 8 , state_type > + > adams_bashforth_moulton_steppers; + +BOOST_AUTO_TEST_CASE_TEMPLATE( abm_time_dependent_test , Stepper, adams_bashforth_moulton_steppers ) +{ + perform_abm_time_dependent_test< Stepper > tester; + tester(); +} + +BOOST_AUTO_TEST_SUITE_END() From fe7afc4fdeb92defa3715741efd57f6112db6d6f Mon Sep 17 00:00:00 2001 From: Mario Mulansky Date: Fri, 19 Dec 2014 11:17:27 -0600 Subject: [PATCH 52/70] typo in comment on analytic solution --- test/numeric/abm_time_dependent.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/numeric/abm_time_dependent.cpp b/test/numeric/abm_time_dependent.cpp index a7695af0..807c36da 100644 --- a/test/numeric/abm_time_dependent.cpp +++ b/test/numeric/abm_time_dependent.cpp @@ -35,7 +35,7 @@ typedef value_type state_type; typedef runge_kutta_fehlberg78 initializing_stepper; -// simple time-dependent rhs, analytic solution x[0] = 0.5*x^2 +// simple time-dependent rhs, analytic solution x = 0.5*t^2 struct simple_rhs { void operator()( const state_type& x , state_type &dxdt , const double t ) const From d43fec705f06367ebd2ceaab18e5751c85ea2056 Mon Sep 17 00:00:00 2001 From: Gregor de Cillia Date: Sun, 21 Dec 2014 22:13:21 +0100 Subject: [PATCH 53/70] First version of the polynomial test This test checks, wether solvers of order ord can solve the problem x'(t) = 1 + t^p for pvalgrind ; diff --git a/test/numeric/order_of_convergence.cpp b/test/numeric/order_of_convergence.cpp new file mode 100644 index 00000000..2915cc34 --- /dev/null +++ b/test/numeric/order_of_convergence.cpp @@ -0,0 +1,112 @@ +/* Boost numeric test for orders of convergence file + + Copyright 2012 Mario Mulansky + Copyright 2012 Karsten Ahnert + + Distributed under the Boost Software License, Version 1.0. + (See accompanying file LICENSE_1_0.txt or + copy at http://www.boost.org/LICENSE_1_0.txt) +*/ + +// disable checked iterator warning for msvc +#include + +#ifdef BOOST_MSVC + #pragma warning(disable:4996) +#endif + +#define BOOST_TEST_MODULE order_of_convergence + +#include +#include + +#include + +#include + +#include + +#include + +using namespace boost::unit_test; +using namespace boost::numeric::odeint; +namespace mpl = boost::mpl; + +typedef double value_type; +typedef boost::array< double , 1 > state_type; + +BOOST_AUTO_TEST_SUITE( order_of_convergence_test ) + +int p; + +/* generic test for all steppers that support integrate_const */ +template< class Stepper > +struct integrate_const_test +{ + void operator()( int nSteps = 1 ) + { + double tolerance = 1.0e-13; + + state_type x; + Stepper stepper; + const int o = stepper.order()+1; + for ( p = 0; p < o-1; p++ ) + { + Stepper stepper1; + x[0] = 1.0; + integrate_const( stepper1, rhs, x, 0.0, 1.0, 1.0/nSteps ); + BOOST_CHECK_LT( fabs( x[0]-1.0/(1.0+p) - 1.0 ), tolerance ); + std::cout << fabs( x[0]-1.0/(1.0+p)-1.0 ) << std::endl; + } + std::cout << std::endl; + } +private: + static void rhs( const state_type &x , state_type &dxdt , const double t ) + { + dxdt[0] = pow( t, p ); + } +}; + +typedef mpl::vector< + euler< state_type > , + modified_midpoint< state_type > , + runge_kutta4< state_type > , + runge_kutta4_classic< state_type > , + runge_kutta_cash_karp54_classic< state_type > , + runge_kutta_cash_karp54< state_type > , + runge_kutta_dopri5< state_type > , + runge_kutta_fehlberg78< state_type > + > runge_kutta_steppers; + +typedef mpl::vector< + adams_bashforth< 2, state_type >, + adams_bashforth< 3, state_type >, + adams_bashforth< 4, state_type >, + adams_bashforth_moulton< 2, state_type >, + adams_bashforth_moulton< 3, state_type >, + adams_bashforth_moulton< 4, state_type > + // \TODO: write tests for order bigger than 4. + // initialize with fehlberg + > adams_steppers; + +typedef mpl::vector< + symplectic_euler< state_type > , + symplectic_rkn_sb3a_mclachlan< state_type > + > symplectic_steppers; + + +BOOST_AUTO_TEST_CASE_TEMPLATE( runge_kutta_test , Stepper, runge_kutta_steppers ) +{ + integrate_const_test< Stepper > tester; + tester(); +} + +BOOST_AUTO_TEST_CASE_TEMPLATE( adams_moultion_test , Stepper, adams_steppers ) +{ + integrate_const_test< Stepper > tester; + tester( 16 ); +} + +// \TODO: add symplectic tests + +BOOST_AUTO_TEST_SUITE_END() From 593652e956fc94a9143dbb3c5e93230181776f9c Mon Sep 17 00:00:00 2001 From: Gregor de Cillia Date: Mon, 22 Dec 2014 05:08:42 +0100 Subject: [PATCH 54/70] order_of_convergence: new steppers tested Adams bashforth and adams bashforth moulton methods of order greater than 4 are tested. Change console output. --- test/numeric/order_of_convergence.cpp | 137 ++++++++++++++++++++------ 1 file changed, 106 insertions(+), 31 deletions(-) diff --git a/test/numeric/order_of_convergence.cpp b/test/numeric/order_of_convergence.cpp index 2915cc34..1c78527e 100644 --- a/test/numeric/order_of_convergence.cpp +++ b/test/numeric/order_of_convergence.cpp @@ -19,6 +19,7 @@ #include #include +#include #include @@ -38,28 +39,95 @@ typedef boost::array< double , 1 > state_type; BOOST_AUTO_TEST_SUITE( order_of_convergence_test ) int p; +double tolerance = 1.0e-13; /* generic test for all steppers that support integrate_const */ template< class Stepper > struct integrate_const_test { + double error; void operator()( int nSteps = 1 ) { - double tolerance = 1.0e-13; - - state_type x; - Stepper stepper; - const int o = stepper.order()+1; - for ( p = 0; p < o-1; p++ ) - { - Stepper stepper1; - x[0] = 1.0; - integrate_const( stepper1, rhs, x, 0.0, 1.0, 1.0/nSteps ); - BOOST_CHECK_LT( fabs( x[0]-1.0/(1.0+p) - 1.0 ), tolerance ); - std::cout << fabs( x[0]-1.0/(1.0+p)-1.0 ) << std::endl; - } - std::cout << std::endl; + Stepper stepper; + std::cout << boost::format( "%-20i%-20i%-20E\n" ) + % estimatedOrder() % definedOrder() % error; + BOOST_REQUIRE( estimatedOrder() == definedOrder() ); } + + const int definedOrder(){ + const Stepper stepper; + return stepper.order(); + } + + const int estimatedOrder( int nSteps = 1 ) + { + state_type x; + double t; + for ( p = 0; p < 20; p++ ) + { + Stepper stepper; + x[0] = 1.0; + t = 0; + for ( int i = 0; i < nSteps; i++ ){ + stepper.do_step( rhs, x, t, 1.0/nSteps ); + t += 1.0/nSteps; + error = fabs( x[0] - pow( t, (1.0+p) )/(1.0 + p) - 1.0 ); + if ( error >tolerance ) + return p; + } + } + return p; + } + + +private: + static void rhs( const state_type &x , state_type &dxdt , const double t ) + { + dxdt[0] = pow( t, p ); + } +}; + + +template< class Stepper > +struct integrate_const_test_initialize +{ + double error; + void operator()( int nSteps = 16 ) + { + std::cout << boost::format( "%-20i%-20i%-20E" ) % estimatedOrder() + % definedOrder() % error << std::endl; + BOOST_REQUIRE( estimatedOrder() == definedOrder() ); + } + + const int definedOrder(){ + const Stepper stepper; + return stepper.order(); + } + + const int estimatedOrder( int nSteps = 16 ) + { + state_type x; + double t; + for ( p = 0; p < 10; p++ ) + { + Stepper stepper; + x[0] = 1.0; + t = 0; + // use a high order method to initialize. + stepper.initialize( runge_kutta_fehlberg78< state_type >(), + rhs, x, t, 1.0/nSteps ); + while ( t < 1 ){ + stepper.do_step( rhs, x, t, 1.0/nSteps ); + t += 1.0/nSteps; + error = fabs( x[0]-pow( t, 1.0 + p)/(1.0+p) - 1.0 ); + if (error > tolerance ) + return p; + } + } + return p; + } + + private: static void rhs( const state_type &x , state_type &dxdt , const double t ) { @@ -67,6 +135,9 @@ private: } }; + + + typedef mpl::vector< euler< state_type > , modified_midpoint< state_type > , @@ -79,21 +150,27 @@ typedef mpl::vector< > runge_kutta_steppers; typedef mpl::vector< - adams_bashforth< 2, state_type >, - adams_bashforth< 3, state_type >, - adams_bashforth< 4, state_type >, - adams_bashforth_moulton< 2, state_type >, - adams_bashforth_moulton< 3, state_type >, - adams_bashforth_moulton< 4, state_type > - // \TODO: write tests for order bigger than 4. - // initialize with fehlberg + adams_bashforth< 2, state_type > , + adams_bashforth< 3, state_type > , + adams_bashforth< 4, state_type > , + adams_bashforth< 5, state_type > , + adams_bashforth< 6, state_type > , + adams_bashforth< 7, state_type > , + adams_bashforth< 8, state_type > , + adams_bashforth_moulton< 2, state_type > , + adams_bashforth_moulton< 3, state_type > , + adams_bashforth_moulton< 4, state_type > , + adams_bashforth_moulton< 5, state_type > , + adams_bashforth_moulton< 6, state_type > , + adams_bashforth_moulton< 7, state_type > , + adams_bashforth_moulton< 8, state_type > > adams_steppers; -typedef mpl::vector< - symplectic_euler< state_type > , - symplectic_rkn_sb3a_mclachlan< state_type > - > symplectic_steppers; - +BOOST_AUTO_TEST_CASE( print_header ) +{ + std::cout << boost::format( "%-20s%-20s%-20s\n" ) + % "Estimated order" % "defined order" % "first significant error"; +} BOOST_AUTO_TEST_CASE_TEMPLATE( runge_kutta_test , Stepper, runge_kutta_steppers ) { @@ -103,10 +180,8 @@ BOOST_AUTO_TEST_CASE_TEMPLATE( runge_kutta_test , Stepper, runge_kutta_steppers BOOST_AUTO_TEST_CASE_TEMPLATE( adams_moultion_test , Stepper, adams_steppers ) { - integrate_const_test< Stepper > tester; - tester( 16 ); + integrate_const_test_initialize< Stepper > tester; + tester(); } -// \TODO: add symplectic tests - BOOST_AUTO_TEST_SUITE_END() From 732d7770ab7988a9b21fc0710e507a48bd57d52b Mon Sep 17 00:00:00 2001 From: Gregor de Cillia Date: Tue, 23 Dec 2014 01:35:49 +0100 Subject: [PATCH 55/70] change name of test to order quadrature formula, new console output and more comments in the code --- test/numeric/Jamfile.v2 | 2 +- ...gence.cpp => order_quadrature_formula.cpp} | 88 ++++++++++++------- 2 files changed, 56 insertions(+), 34 deletions(-) rename test/numeric/{order_of_convergence.cpp => order_quadrature_formula.cpp} (65%) diff --git a/test/numeric/Jamfile.v2 b/test/numeric/Jamfile.v2 index 4cdcc4f1..a329ff7a 100644 --- a/test/numeric/Jamfile.v2 +++ b/test/numeric/Jamfile.v2 @@ -29,6 +29,6 @@ test-suite "odeint" [ run adams_bashforth.cpp ] [ run adams_bashforth_moulton.cpp ] [ run abm_time_dependent.cpp ] - [ run order_of_convergence.cpp ] + [ run order_quadrature_formula.cpp ] : valgrind ; diff --git a/test/numeric/order_of_convergence.cpp b/test/numeric/order_quadrature_formula.cpp similarity index 65% rename from test/numeric/order_of_convergence.cpp rename to test/numeric/order_quadrature_formula.cpp index 1c78527e..35372e92 100644 --- a/test/numeric/order_of_convergence.cpp +++ b/test/numeric/order_quadrature_formula.cpp @@ -1,4 +1,4 @@ -/* Boost numeric test for orders of convergence file +/* Boost numeric test for ordersof quadrature formulas test file Copyright 2012 Mario Mulansky Copyright 2012 Karsten Ahnert @@ -10,18 +10,15 @@ // disable checked iterator warning for msvc #include - +/* #ifdef BOOST_MSVC #pragma warning(disable:4996) #endif - +*/ #define BOOST_TEST_MODULE order_of_convergence #include #include -#include - -#include #include @@ -29,51 +26,65 @@ #include +#include + using namespace boost::unit_test; using namespace boost::numeric::odeint; namespace mpl = boost::mpl; typedef double value_type; -typedef boost::array< double , 1 > state_type; +typedef value_type time_type; +typedef boost::numeric::ublas::vector< double > state_type; BOOST_AUTO_TEST_SUITE( order_of_convergence_test ) int p; -double tolerance = 1.0e-13; +value_type tolerance = 1.0e-13; /* generic test for all steppers that support integrate_const */ template< class Stepper > struct integrate_const_test { double error; + double maxError; void operator()( int nSteps = 1 ) { Stepper stepper; - std::cout << boost::format( "%-20i%-20i%-20E\n" ) - % estimatedOrder() % definedOrder() % error; - BOOST_REQUIRE( estimatedOrder() == definedOrder() ); + std::cout << boost::format( "%-20i%-20i%-30E%-20E\n" ) + % estimatedOrder( nSteps ) % definedOrder() % error % maxError; + + BOOST_REQUIRE_EQUAL( estimatedOrder( nSteps ), definedOrder() ); } const int definedOrder(){ const Stepper stepper; return stepper.order(); } - + /* + the order of the stepper is estimated by trying to solve the ODE + x'(t) = t^p + until the errors are too big to be justified by finite precision. + the first value p for which the problem is *not* solved with + precision `tolerance` is the estimate for the order of the scheme. + */ const int estimatedOrder( int nSteps = 1 ) { - state_type x; + state_type x(1); double t; + maxError = 0; for ( p = 0; p < 20; p++ ) { Stepper stepper; - x[0] = 1.0; + x[0] = 0.0; t = 0; for ( int i = 0; i < nSteps; i++ ){ stepper.do_step( rhs, x, t, 1.0/nSteps ); t += 1.0/nSteps; - error = fabs( x[0] - pow( t, (1.0+p) )/(1.0 + p) - 1.0 ); - if ( error >tolerance ) + error = fabs( x[0] - pow( t, ( 1.0 + p ) )/( 1.0 + p ) ); + if ( error > tolerance ) return p; + else if ( error > maxError ) + maxError = error; } } return p; @@ -81,7 +92,7 @@ struct integrate_const_test private: - static void rhs( const state_type &x , state_type &dxdt , const double t ) + static void rhs( const state_type &x , state_type &dxdt , const time_type t ) { dxdt[0] = pow( t, p ); } @@ -91,27 +102,37 @@ private: template< class Stepper > struct integrate_const_test_initialize { - double error; + value_type error; + value_type maxError; + void operator()( int nSteps = 16 ) { - std::cout << boost::format( "%-20i%-20i%-20E" ) % estimatedOrder() - % definedOrder() % error << std::endl; - BOOST_REQUIRE( estimatedOrder() == definedOrder() ); + std::cout << boost::format( "%-20i%-20i%-30E%-20E\n" ) + % estimatedOrder( nSteps ) % definedOrder() % error % maxError; + + BOOST_REQUIRE_EQUAL( estimatedOrder( nSteps ), definedOrder() ); } const int definedOrder(){ const Stepper stepper; return stepper.order(); } + /* + just like the other version of estimatedOrder(), but with + initization performed by the fehlberg stepper ( order 8 ) + if the default initialization ( runge kutta 4 ) is used, + estimatedOrder will never return an order greater than 4. + */ const int estimatedOrder( int nSteps = 16 ) { - state_type x; - double t; + state_type x(1); + value_type t; + maxError = -1.0; for ( p = 0; p < 10; p++ ) { Stepper stepper; - x[0] = 1.0; + x[0] = 0.0; t = 0; // use a high order method to initialize. stepper.initialize( runge_kutta_fehlberg78< state_type >(), @@ -119,25 +140,25 @@ struct integrate_const_test_initialize while ( t < 1 ){ stepper.do_step( rhs, x, t, 1.0/nSteps ); t += 1.0/nSteps; - error = fabs( x[0]-pow( t, 1.0 + p)/(1.0+p) - 1.0 ); - if (error > tolerance ) + error = fabs( x[0]-pow( t, 1.0 + p)/(1.0+p) ); + if ( error > tolerance ) return p; + else if ( error > maxError ) + maxError = error; } - } + } return p; } private: - static void rhs( const state_type &x , state_type &dxdt , const double t ) - { + static void rhs( const state_type &x , state_type &dxdt , const time_type t ) + { dxdt[0] = pow( t, p ); } }; - - typedef mpl::vector< euler< state_type > , modified_midpoint< state_type > , @@ -168,8 +189,9 @@ typedef mpl::vector< BOOST_AUTO_TEST_CASE( print_header ) { - std::cout << boost::format( "%-20s%-20s%-20s\n" ) - % "Estimated order" % "defined order" % "first significant error"; + std::cout << boost::format( "%-20s%-20s%-30s%-20s\n" ) + % "Estimated order" % "defined order" + % "first significant error" % "biggest insignificant error"; } BOOST_AUTO_TEST_CASE_TEMPLATE( runge_kutta_test , Stepper, runge_kutta_steppers ) From b9fa3d5a1cc08fbf44af4e752f43457af7eff5be Mon Sep 17 00:00:00 2001 From: Gregor de Cillia Date: Tue, 23 Dec 2014 01:49:00 +0100 Subject: [PATCH 56/70] disable warnings --- test/numeric/order_quadrature_formula.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/numeric/order_quadrature_formula.cpp b/test/numeric/order_quadrature_formula.cpp index 35372e92..be0b8158 100644 --- a/test/numeric/order_quadrature_formula.cpp +++ b/test/numeric/order_quadrature_formula.cpp @@ -10,12 +10,12 @@ // disable checked iterator warning for msvc #include -/* + #ifdef BOOST_MSVC #pragma warning(disable:4996) #endif -*/ -#define BOOST_TEST_MODULE order_of_convergence + +#define BOOST_TEST_MODULE order_quadrature_formula #include #include From 4cadbe51640466f1d295f7a4c7d2375e063f0350 Mon Sep 17 00:00:00 2001 From: Mario Mulansky Date: Sat, 10 Jan 2015 16:17:06 +0100 Subject: [PATCH 57/70] fixes #147 when state_type == time_type (e.g. 1d odes with state_type = double), some do_step overloads are disabled due to ambiguities of parameter structure. However, the initialization of the Adams-Bashforth needs some of those disabled functions in its initialization. As a fix, I added do_step_dxdt to the stepper base classes to provide direct access to the required functions that will not be disabled in the case of state_type == time_type. --- .../odeint/stepper/adams_bashforth.hpp | 4 +- .../base/explicit_error_stepper_base.hpp | 33 ++++++- .../base/explicit_error_stepper_fsal_base.hpp | 25 +++++- .../stepper/base/explicit_stepper_base.hpp | 30 +++++++ test/Jamfile.v2 | 2 + test/regression/Jamfile.v2 | 28 ++++++ test/regression/regression_147.cpp | 88 +++++++++++++++++++ 7 files changed, 200 insertions(+), 10 deletions(-) create mode 100644 test/regression/Jamfile.v2 create mode 100644 test/regression/regression_147.cpp diff --git a/include/boost/numeric/odeint/stepper/adams_bashforth.hpp b/include/boost/numeric/odeint/stepper/adams_bashforth.hpp index 59ed1c90..4e55e77c 100644 --- a/include/boost/numeric/odeint/stepper/adams_bashforth.hpp +++ b/include/boost/numeric/odeint/stepper/adams_bashforth.hpp @@ -181,7 +181,7 @@ public : { if( i != 0 ) m_step_storage.rotate(); sys( x , m_step_storage[0].m_v , t ); - stepper.do_step( system , x , m_step_storage[0].m_v , t , dt ); + stepper.do_step_dxdt( system , x , m_step_storage[0].m_v , t , dt ); t += dt; } m_steps_initialized = steps; @@ -222,7 +222,7 @@ private: { if( m_steps_initialized != 0 ) m_step_storage.rotate(); sys( in , m_step_storage[0].m_v , t ); - m_initializing_stepper.do_step( system , in , m_step_storage[0].m_v , t , out , dt ); + m_initializing_stepper.do_step_dxdt( system , in , m_step_storage[0].m_v , t , out , dt ); ++m_steps_initialized; } else diff --git a/include/boost/numeric/odeint/stepper/base/explicit_error_stepper_base.hpp b/include/boost/numeric/odeint/stepper/base/explicit_error_stepper_base.hpp index 3ba11a4f..72deaf50 100644 --- a/include/boost/numeric/odeint/stepper/base/explicit_error_stepper_base.hpp +++ b/include/boost/numeric/odeint/stepper/base/explicit_error_stepper_base.hpp @@ -151,6 +151,22 @@ public: } + /* + * named Version 2: do_step_dxdt( sys , in , dxdt , t , dt ) + * + * this version is needed when this stepper is used for initializing + * multistep stepper like adams-bashforth. Hence we provide an explicitely + * named version that is not disabled. + */ + template< class System, class StateInOut, class DerivIn > + void do_step_dxdt( System system, StateInOut &x, const DerivIn &dxdt, + time_type t, time_type dt ) + { + this->stepper().do_step_impl( system , x , dxdt , t , x , dt ); + } + + + /* * Version 3 : do_step( sys , in , t , out , dt ) * @@ -181,10 +197,19 @@ public: { this->stepper().do_step_impl( system , in , dxdt , t , out , dt ); } - - - - + + /* + * named Version 4: do_step_dxdt( sys , in , dxdt , t , out, dt ) + * + * this version is needed when this stepper is used for initializing + * multistep stepper like adams-bashforth. Hence we provide an explicitely + * named version that is not disabled. + */ + template< class System , class StateIn , class DerivIn , class StateOut > + void do_step_dxdt( System system , const StateIn &in , const DerivIn &dxdt , time_type t , StateOut &out , time_type dt ) + { + this->stepper().do_step_impl( system , in , dxdt , t , out , dt ); + } /* * Version 5 :do_step( sys , x , t , dt , xerr ) diff --git a/include/boost/numeric/odeint/stepper/base/explicit_error_stepper_fsal_base.hpp b/include/boost/numeric/odeint/stepper/base/explicit_error_stepper_fsal_base.hpp index a055c7fa..b7185901 100644 --- a/include/boost/numeric/odeint/stepper/base/explicit_error_stepper_fsal_base.hpp +++ b/include/boost/numeric/odeint/stepper/base/explicit_error_stepper_fsal_base.hpp @@ -150,6 +150,21 @@ public: } + /* + * named Version 2: do_step_dxdt( sys , in , dxdt , t , dt ) + * + * this version is needed when this stepper is used for initializing + * multistep stepper like adams-bashforth. Hence we provide an explicitely + * named version that is not disabled. + */ + template< class System , class StateInOut , class DerivInOut > + void do_step_dxdt( System system , StateInOut &x , DerivInOut &dxdt , time_type t , time_type dt ) + { + m_first_call = true; + this->stepper().do_step_impl( system , x , dxdt , t , x , dxdt , dt ); + } + + /* * version 3 : do_step( sys , in , t , out , dt ) * @@ -174,12 +189,14 @@ public: * * this version does not solve the forwarding problem, boost.range can not be used */ - template< class System , class StateIn , class DerivIn , class StateOut , class DerivOut > - void do_step( System system , const StateIn &in , const DerivIn &dxdt_in , time_type t , - StateOut &out , DerivOut &dxdt_out , time_type dt ) + template< class System, class StateIn, class DerivIn, class StateOut, + class DerivOut > + void do_step( System system, const StateIn &in, const DerivIn &dxdt_in, + time_type t, StateOut &out, DerivOut &dxdt_out, time_type dt ) { m_first_call = true; - this->stepper().do_step_impl( system , in , dxdt_in , t , out , dxdt_out , dt ); + this->stepper().do_step_impl( system, in, dxdt_in, t, out, dxdt_out, + dt ); } diff --git a/include/boost/numeric/odeint/stepper/base/explicit_stepper_base.hpp b/include/boost/numeric/odeint/stepper/base/explicit_stepper_base.hpp index 40aab803..b3288b19 100644 --- a/include/boost/numeric/odeint/stepper/base/explicit_stepper_base.hpp +++ b/include/boost/numeric/odeint/stepper/base/explicit_stepper_base.hpp @@ -138,6 +138,21 @@ public: } + /* + * named Version 2: do_step_dxdt( sys , in , dxdt , t , dt ) + * + * this version is needed when this stepper is used for initializing + * multistep stepper like adams-bashforth. Hence we provide an explicitely + * named version that is not disabled. + */ + template< class System, class StateInOut, class DerivIn > + void do_step_dxdt( System system, StateInOut &x, const DerivIn &dxdt, + time_type t, time_type dt ) + { + this->stepper().do_step_impl( system , x , dxdt , t , x , dt ); + } + + /* * Version 3 : do_step( sys , in , t , out , dt ) * @@ -164,6 +179,21 @@ public: this->stepper().do_step_impl( system , in , dxdt , t , out , dt ); } + + /* + * named Version 4: do_step_dxdt( sys , in , dxdt , t , out, dt ) + * + * this version is needed when this stepper is used for initializing + * multistep stepper like adams-bashforth. Hence we provide an explicitely + * named version. + */ + template< class System, class StateIn, class DerivIn, class StateOut > + void do_step_dxdt( System system, const StateIn &in, const DerivIn &dxdt, + time_type t, StateOut &out, time_type dt ) + { + this->stepper().do_step_impl( system , in , dxdt , t , out , dt ); + } + template< class StateIn > void adjust_size( const StateIn &x ) { diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 9eeec045..efa35a57 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -89,6 +89,8 @@ test-suite "odeint" # also run numeric tests build-project numeric ; +build-project regression ; + # test-suite "odeint-iterator_integrate" # : # [ run integrate.cpp : : : : integrate_iterator ] diff --git a/test/regression/Jamfile.v2 b/test/regression/Jamfile.v2 new file mode 100644 index 00000000..6bf16f1c --- /dev/null +++ b/test/regression/Jamfile.v2 @@ -0,0 +1,28 @@ +# Copyright 2012 Karsten Ahnert +# Copyright 2012 Mario Mulansky +# Distributed under the Boost Software License, Version 1.0. +# (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +# bring in rules for testing + + +import testing ; + +use-project boost : $(BOOST_ROOT) ; + +project + : requirements + /boost/test//boost_unit_test_framework + BOOST_ALL_NO_LIB=1 + ../../include + static + clang:-Wno-unused-variable + +# -D_SCL_SECURE_NO_WARNINGS + ; + +test-suite "odeint" + : + [ run regression_147.cpp ] + : valgrind + ; diff --git a/test/regression/regression_147.cpp b/test/regression/regression_147.cpp new file mode 100644 index 00000000..7373782d --- /dev/null +++ b/test/regression/regression_147.cpp @@ -0,0 +1,88 @@ +/* + + [begin_description] + Test case for issue 147 + [end_description] + + Copyright 2011-2015 Karsten Ahnert + Copyright 2011-2015 Mario Mulansky + + Distributed under the Boost Software License, Version 1.0. + (See accompanying file LICENSE_1_0.txt or + copy at http://www.boost.org/LICENSE_1_0.txt) + */ + + +// disable checked iterator warning for msvc + +#include +#ifdef BOOST_MSVC + #pragma warning(disable:4996) +#endif + +#define BOOST_TEST_MODULE odeint_regression_147 + +#include + +#include + +#include + +#include + +#include + +using namespace boost::unit_test; +using namespace boost::numeric::odeint; +namespace mpl = boost::mpl; + +typedef double state_type; + +void rhs( const state_type &x , state_type &dxdt , const double t ) +{ + dxdt = 1; +} + + +template +struct perform_init_test +{ + void operator()( void ) + { + double t = 0; + const double dt = 0.1; + + state_type x = 0; + + Stepper stepper; + InitStepper init_stepper; + stepper.initialize( init_stepper, rhs, x, t, dt ); + + // ab-stepper needs order-1 init steps: t and x should be (order-1)*dt + BOOST_CHECK_CLOSE( t , (stepper.order()-1)*dt , 1E-16 ); + BOOST_CHECK_CLOSE( x, ( stepper.order() - 1 ) * dt, 2E-14 ); + } +}; + +typedef mpl::vector< + euler< state_type > , + modified_midpoint< state_type > , + runge_kutta4< state_type > , + runge_kutta4_classic< state_type > , + runge_kutta_cash_karp54_classic< state_type > , + runge_kutta_cash_karp54< state_type > , + runge_kutta_dopri5< state_type > , + runge_kutta_fehlberg78< state_type > + > runge_kutta_steppers; + + +BOOST_AUTO_TEST_SUITE( regression_147_test ) + +BOOST_AUTO_TEST_CASE_TEMPLATE( init_test , InitStepper, + runge_kutta_steppers ) +{ + perform_init_test< adams_bashforth<4, state_type>, InitStepper > tester; + tester(); +} + +BOOST_AUTO_TEST_SUITE_END() From 82e2a70aa21e8958a3a4bf7b97af264a316e1c49 Mon Sep 17 00:00:00 2001 From: Mario Mulansky Date: Sat, 10 Jan 2015 19:34:53 +0100 Subject: [PATCH 58/70] fixed adams bashforth test case --- test/adams_bashforth.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/adams_bashforth.cpp b/test/adams_bashforth.cpp index 91c2b876..c96334d9 100644 --- a/test/adams_bashforth.cpp +++ b/test/adams_bashforth.cpp @@ -69,14 +69,14 @@ public: size_t do_count; template< class System , class StateIn , class DerivIn , class StateOut > - void do_step( System system , const StateIn &in , const DerivIn &dxdt , value_type t , StateOut &out , value_type dt ) + void do_step_dxdt( System system , const StateIn &in , const DerivIn &dxdt , value_type t , StateOut &out , value_type dt ) { m_stepper.do_step( system , in , dxdt , t , out , dt ); ++do_count; } template< class System , class StateInOut , class DerivIn > - void do_step( System system , StateInOut &x , const DerivIn &dxdt , value_type t , value_type dt ) + void do_step_dxdt( System system , StateInOut &x , const DerivIn &dxdt , value_type t , value_type dt ) { m_stepper.do_step( system , x , dxdt , t , dt ); ++do_count; From d323be0220d228913c40c69a382074d1a09d843b Mon Sep 17 00:00:00 2001 From: Mario Mulansky Date: Tue, 13 Jan 2015 20:20:32 +0100 Subject: [PATCH 59/70] renamed do_step_dxdt to do_step_dxdt_impl --- .../odeint/stepper/adams_bashforth.hpp | 6 ++++-- .../base/explicit_error_stepper_base.hpp | 20 ++++++++++-------- .../base/explicit_error_stepper_fsal_base.hpp | 13 ++++++------ .../stepper/base/explicit_stepper_base.hpp | 21 ++++++++++--------- 4 files changed, 33 insertions(+), 27 deletions(-) diff --git a/include/boost/numeric/odeint/stepper/adams_bashforth.hpp b/include/boost/numeric/odeint/stepper/adams_bashforth.hpp index 4e55e77c..014461cb 100644 --- a/include/boost/numeric/odeint/stepper/adams_bashforth.hpp +++ b/include/boost/numeric/odeint/stepper/adams_bashforth.hpp @@ -181,7 +181,8 @@ public : { if( i != 0 ) m_step_storage.rotate(); sys( x , m_step_storage[0].m_v , t ); - stepper.do_step_dxdt( system , x , m_step_storage[0].m_v , t , dt ); + stepper.do_step_dxdt_impl( system, x, m_step_storage[0].m_v, t, + dt ); t += dt; } m_steps_initialized = steps; @@ -222,7 +223,8 @@ private: { if( m_steps_initialized != 0 ) m_step_storage.rotate(); sys( in , m_step_storage[0].m_v , t ); - m_initializing_stepper.do_step_dxdt( system , in , m_step_storage[0].m_v , t , out , dt ); + m_initializing_stepper.do_step_dxdt_impl( + system, in, m_step_storage[0].m_v, t, out, dt ); ++m_steps_initialized; } else diff --git a/include/boost/numeric/odeint/stepper/base/explicit_error_stepper_base.hpp b/include/boost/numeric/odeint/stepper/base/explicit_error_stepper_base.hpp index 72deaf50..08009dc1 100644 --- a/include/boost/numeric/odeint/stepper/base/explicit_error_stepper_base.hpp +++ b/include/boost/numeric/odeint/stepper/base/explicit_error_stepper_base.hpp @@ -152,15 +152,15 @@ public: /* - * named Version 2: do_step_dxdt( sys , in , dxdt , t , dt ) + * named Version 2: do_step_dxdt_impl( sys , in , dxdt , t , dt ) * * this version is needed when this stepper is used for initializing * multistep stepper like adams-bashforth. Hence we provide an explicitely - * named version that is not disabled. + * named version that is not disabled. Meant for internal use only. */ - template< class System, class StateInOut, class DerivIn > - void do_step_dxdt( System system, StateInOut &x, const DerivIn &dxdt, - time_type t, time_type dt ) + template < class System, class StateInOut, class DerivIn > + void do_step_dxdt_impl( System system, StateInOut &x, const DerivIn &dxdt, + time_type t, time_type dt ) { this->stepper().do_step_impl( system , x , dxdt , t , x , dt ); } @@ -199,14 +199,16 @@ public: } /* - * named Version 4: do_step_dxdt( sys , in , dxdt , t , out, dt ) + * named Version 4: do_step_dxdt_impl( sys , in , dxdt , t , out, dt ) * * this version is needed when this stepper is used for initializing * multistep stepper like adams-bashforth. Hence we provide an explicitely - * named version that is not disabled. + * named version that is not disabled. Meant for internal use only. */ - template< class System , class StateIn , class DerivIn , class StateOut > - void do_step_dxdt( System system , const StateIn &in , const DerivIn &dxdt , time_type t , StateOut &out , time_type dt ) + template < class System, class StateIn, class DerivIn, class StateOut > + void do_step_dxdt_impl( System system, const StateIn &in, + const DerivIn &dxdt, time_type t, StateOut &out, + time_type dt ) { this->stepper().do_step_impl( system , in , dxdt , t , out , dt ); } diff --git a/include/boost/numeric/odeint/stepper/base/explicit_error_stepper_fsal_base.hpp b/include/boost/numeric/odeint/stepper/base/explicit_error_stepper_fsal_base.hpp index b7185901..b1d751a0 100644 --- a/include/boost/numeric/odeint/stepper/base/explicit_error_stepper_fsal_base.hpp +++ b/include/boost/numeric/odeint/stepper/base/explicit_error_stepper_fsal_base.hpp @@ -151,26 +151,27 @@ public: /* - * named Version 2: do_step_dxdt( sys , in , dxdt , t , dt ) + * named Version 2: do_step_dxdt_impl( sys , in , dxdt , t , dt ) * * this version is needed when this stepper is used for initializing * multistep stepper like adams-bashforth. Hence we provide an explicitely - * named version that is not disabled. + * named version that is not disabled. Meant for internal use only. */ template< class System , class StateInOut , class DerivInOut > - void do_step_dxdt( System system , StateInOut &x , DerivInOut &dxdt , time_type t , time_type dt ) + void do_step_dxdt_impl( System system , StateInOut &x , DerivInOut &dxdt , time_type t , time_type dt ) { m_first_call = true; this->stepper().do_step_impl( system , x , dxdt , t , x , dxdt , dt ); } - /* * version 3 : do_step( sys , in , t , out , dt ) * - * this version does not solve the forwarding problem, boost.range can not be used + * this version does not solve the forwarding problem, boost.range can not + * be used. * - * the disable is needed to avoid ambiguous overloads if state_type = time_type + * the disable is needed to avoid ambiguous overloads if + * state_type = time_type */ template< class System , class StateIn , class StateOut > typename boost::disable_if< boost::is_same< StateIn , time_type > , void >::type diff --git a/include/boost/numeric/odeint/stepper/base/explicit_stepper_base.hpp b/include/boost/numeric/odeint/stepper/base/explicit_stepper_base.hpp index b3288b19..d81c8c7a 100644 --- a/include/boost/numeric/odeint/stepper/base/explicit_stepper_base.hpp +++ b/include/boost/numeric/odeint/stepper/base/explicit_stepper_base.hpp @@ -139,15 +139,15 @@ public: /* - * named Version 2: do_step_dxdt( sys , in , dxdt , t , dt ) + * named Version 2: do_step_dxdt_impl( sys , in , dxdt , t , dt ) * * this version is needed when this stepper is used for initializing * multistep stepper like adams-bashforth. Hence we provide an explicitely - * named version that is not disabled. + * named version that is not disabled. Meant for internal use only. */ - template< class System, class StateInOut, class DerivIn > - void do_step_dxdt( System system, StateInOut &x, const DerivIn &dxdt, - time_type t, time_type dt ) + template < class System, class StateInOut, class DerivIn > + void do_step_dxdt_impl( System system, StateInOut &x, const DerivIn &dxdt, + time_type t, time_type dt ) { this->stepper().do_step_impl( system , x , dxdt , t , x , dt ); } @@ -181,15 +181,16 @@ public: /* - * named Version 4: do_step_dxdt( sys , in , dxdt , t , out, dt ) + * named Version 4: do_step_dxdt_impl( sys , in , dxdt , t , out, dt ) * * this version is needed when this stepper is used for initializing * multistep stepper like adams-bashforth. Hence we provide an explicitely - * named version. + * named version. Meant for internal use only. */ - template< class System, class StateIn, class DerivIn, class StateOut > - void do_step_dxdt( System system, const StateIn &in, const DerivIn &dxdt, - time_type t, StateOut &out, time_type dt ) + template < class System, class StateIn, class DerivIn, class StateOut > + void do_step_dxdt_impl( System system, const StateIn &in, + const DerivIn &dxdt, time_type t, StateOut &out, + time_type dt ) { this->stepper().do_step_impl( system , in , dxdt , t , out , dt ); } From 4b5a34dd9a067b09367a29cab2e4c0ac45f51784 Mon Sep 17 00:00:00 2001 From: Mario Mulansky Date: Tue, 13 Jan 2015 22:09:02 +0100 Subject: [PATCH 60/70] fixed adams-bashforth test --- test/adams_bashforth.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/adams_bashforth.cpp b/test/adams_bashforth.cpp index c96334d9..f7e5e2bf 100644 --- a/test/adams_bashforth.cpp +++ b/test/adams_bashforth.cpp @@ -69,14 +69,14 @@ public: size_t do_count; template< class System , class StateIn , class DerivIn , class StateOut > - void do_step_dxdt( System system , const StateIn &in , const DerivIn &dxdt , value_type t , StateOut &out , value_type dt ) + void do_step_dxdt_impl( System system , const StateIn &in , const DerivIn &dxdt , value_type t , StateOut &out , value_type dt ) { m_stepper.do_step( system , in , dxdt , t , out , dt ); ++do_count; } template< class System , class StateInOut , class DerivIn > - void do_step_dxdt( System system , StateInOut &x , const DerivIn &dxdt , value_type t , value_type dt ) + void do_step_dxdt_impl( System system , StateInOut &x , const DerivIn &dxdt , value_type t , value_type dt ) { m_stepper.do_step( system , x , dxdt , t , dt ); ++do_count; From c7d40ae0f1caf8cfb3dfd6e896ea005dffef4edd Mon Sep 17 00:00:00 2001 From: Gregor de Cillia Date: Tue, 20 Jan 2015 01:43:52 +0100 Subject: [PATCH 61/70] applied recommendations mentioned in #146 * state_type is now a double * rhs is global * p is a member of rhs, called exponent * 'main loop' is of the form do{ exponent++; ... } while ( error < tolerance ); --- test/numeric/order_quadrature_formula.cpp | 156 ++++++++++++---------- 1 file changed, 85 insertions(+), 71 deletions(-) diff --git a/test/numeric/order_quadrature_formula.cpp b/test/numeric/order_quadrature_formula.cpp index be0b8158..8a87c612 100644 --- a/test/numeric/order_quadrature_formula.cpp +++ b/test/numeric/order_quadrature_formula.cpp @@ -1,4 +1,4 @@ -/* Boost numeric test for ordersof quadrature formulas test file +/* Boost numeric test for orders of quadrature formulas test file Copyright 2012 Mario Mulansky Copyright 2012 Karsten Ahnert @@ -10,11 +10,11 @@ // disable checked iterator warning for msvc #include - +/* #ifdef BOOST_MSVC #pragma warning(disable:4996) #endif - +*/ #define BOOST_TEST_MODULE order_quadrature_formula #include @@ -34,26 +34,36 @@ namespace mpl = boost::mpl; typedef double value_type; typedef value_type time_type; -typedef boost::numeric::ublas::vector< double > state_type; +typedef value_type state_type; BOOST_AUTO_TEST_SUITE( order_of_convergence_test ) -int p; value_type tolerance = 1.0e-13; +struct monome +{ + int exponent; + monome() : exponent( 0 ){}; + void operator()( const state_type &x , state_type &dxdt , const time_type t ){ + dxdt = ( 1.0 + exponent )*pow( t, exponent ); + } +}; + +monome rhs; + /* generic test for all steppers that support integrate_const */ template< class Stepper > struct integrate_const_test { - double error; double maxError; + int estimatedOrder; void operator()( int nSteps = 1 ) { - Stepper stepper; - std::cout << boost::format( "%-20i%-20i%-30E%-20E\n" ) - % estimatedOrder( nSteps ) % definedOrder() % error % maxError; + estimateOrder(); + std::cout << boost::format( "%-20i%-20i%-20E\n" ) + % estimatedOrder % definedOrder() % maxError; - BOOST_REQUIRE_EQUAL( estimatedOrder( nSteps ), definedOrder() ); + BOOST_REQUIRE_EQUAL( estimatedOrder, definedOrder() ); } const int definedOrder(){ @@ -67,34 +77,33 @@ struct integrate_const_test the first value p for which the problem is *not* solved with precision `tolerance` is the estimate for the order of the scheme. */ - const int estimatedOrder( int nSteps = 1 ) + void estimateOrder( int nSteps = 1 ) { - state_type x(1); + state_type x; double t; maxError = 0; - for ( p = 0; p < 20; p++ ) - { - Stepper stepper; - x[0] = 0.0; - t = 0; - for ( int i = 0; i < nSteps; i++ ){ - stepper.do_step( rhs, x, t, 1.0/nSteps ); - t += 1.0/nSteps; - error = fabs( x[0] - pow( t, ( 1.0 + p ) )/( 1.0 + p ) ); - if ( error > tolerance ) - return p; - else if ( error > maxError ) - maxError = error; - } + rhs.exponent = -1; + do{ + // begin with x'(t) = ( t^0 )/1 = 1 + // => x (t) = t + // then use x'(t) = ( t^1 )/2 = t/2 + // => x (t) = t^2 + // ... + rhs.exponent++; + Stepper stepper; + x = 0.0; + t = 0; + for ( int i = 0; i < nSteps; i++ ){ + stepper.do_step( rhs, x, t, 1.0/nSteps ); + t += 1.0/nSteps; + // compute the error using the exact solution x(t)=t^(1+p) + value_type error = fabs( x - pow( t, ( 1.0 + rhs.exponent ) ) ); + maxError = fmax( error, maxError ); } - return p; - } - - -private: - static void rhs( const state_type &x , state_type &dxdt , const time_type t ) - { - dxdt[0] = pow( t, p ); + } + while ( maxError < tolerance ); + // return the first exponent for which the test failed + estimatedOrder = rhs.exponent; } }; @@ -102,15 +111,16 @@ private: template< class Stepper > struct integrate_const_test_initialize { - value_type error; + int estimatedOrder; value_type maxError; void operator()( int nSteps = 16 ) { - std::cout << boost::format( "%-20i%-20i%-30E%-20E\n" ) - % estimatedOrder( nSteps ) % definedOrder() % error % maxError; + estimateOrder( nSteps ); + std::cout << boost::format( "%-20i%-20i%-30E\n" ) + % estimatedOrder % definedOrder() % maxError; - BOOST_REQUIRE_EQUAL( estimatedOrder( nSteps ), definedOrder() ); + BOOST_REQUIRE_EQUAL( estimatedOrder, definedOrder() ); } const int definedOrder(){ @@ -118,43 +128,39 @@ struct integrate_const_test_initialize return stepper.order(); } /* - just like the other version of estimatedOrder(), but with + just like the other version of estimateOrder(), but with initization performed by the fehlberg stepper ( order 8 ) if the default initialization ( runge kutta 4 ) is used, - estimatedOrder will never return an order greater than 4. + the estimated order will never be greater than 4. */ - const int estimatedOrder( int nSteps = 16 ) + void estimateOrder( int nSteps = 16 ) { - state_type x(1); - value_type t; - maxError = -1.0; - for ( p = 0; p < 10; p++ ) - { - Stepper stepper; - x[0] = 0.0; - t = 0; - // use a high order method to initialize. - stepper.initialize( runge_kutta_fehlberg78< state_type >(), - rhs, x, t, 1.0/nSteps ); - while ( t < 1 ){ - stepper.do_step( rhs, x, t, 1.0/nSteps ); - t += 1.0/nSteps; - error = fabs( x[0]-pow( t, 1.0 + p)/(1.0+p) ); - if ( error > tolerance ) - return p; - else if ( error > maxError ) - maxError = error; - } + state_type x; + time_type t; + const time_type dt = 1.0/nSteps; + maxError = 0.0; + rhs.exponent = -1; + do{ + rhs.exponent++; + // construct the stepper inside the for loop to reset the + // step storage + Stepper stepper; + x = 0.0; + t = 0.0; + // use a high order method to initialize. + stepper.initialize( runge_kutta_fehlberg78< state_type >(), + rhs, x, t, dt ); + while ( t < 1 ){ + stepper.do_step( rhs, x, t, 1.0/nSteps ); + t += 1.0/nSteps; + // compute the error using the exact solution x(t)=t^(1+p) + value_type error = fabs( x - pow( t, 1.0 + rhs.exponent) ); + maxError = fmax( error, maxError ); } - return p; - } - - -private: - static void rhs( const state_type &x , state_type &dxdt , const time_type t ) - { - dxdt[0] = pow( t, p ); + } while( maxError < tolerance ); + // return the first exponent for which the test failed + estimatedOrder = rhs.exponent; } }; @@ -189,9 +195,9 @@ typedef mpl::vector< BOOST_AUTO_TEST_CASE( print_header ) { - std::cout << boost::format( "%-20s%-20s%-30s%-20s\n" ) + std::cout << boost::format( "%-20s%-20s%-30s\n" ) % "Estimated order" % "defined order" - % "first significant error" % "biggest insignificant error"; + % "maxError"; } BOOST_AUTO_TEST_CASE_TEMPLATE( runge_kutta_test , Stepper, runge_kutta_steppers ) @@ -200,6 +206,14 @@ BOOST_AUTO_TEST_CASE_TEMPLATE( runge_kutta_test , Stepper, runge_kutta_steppers tester(); } +BOOST_AUTO_TEST_CASE( print_seperator ) +{ + std::cout << "-------------------" + << " ABM STEPPERS " + << "-------------------" + << std::endl; +} + BOOST_AUTO_TEST_CASE_TEMPLATE( adams_moultion_test , Stepper, adams_steppers ) { integrate_const_test_initialize< Stepper > tester; From 8ee12ec2d12bcd5c890a36892229ee988882e2b9 Mon Sep 17 00:00:00 2001 From: Gregor de Cillia Date: Tue, 20 Jan 2015 01:48:57 +0100 Subject: [PATCH 62/70] disable warnings --- test/numeric/order_quadrature_formula.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/numeric/order_quadrature_formula.cpp b/test/numeric/order_quadrature_formula.cpp index 8a87c612..276e272b 100644 --- a/test/numeric/order_quadrature_formula.cpp +++ b/test/numeric/order_quadrature_formula.cpp @@ -10,11 +10,11 @@ // disable checked iterator warning for msvc #include -/* + #ifdef BOOST_MSVC #pragma warning(disable:4996) #endif -*/ + #define BOOST_TEST_MODULE order_quadrature_formula #include From 5925f23db7219bd9735895de07c6193dc8cdcb9f Mon Sep 17 00:00:00 2001 From: GregorDeCillia Date: Tue, 20 Jan 2015 10:32:27 +0100 Subject: [PATCH 63/70] Update order_quadrature_formula.cpp --- test/numeric/order_quadrature_formula.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/test/numeric/order_quadrature_formula.cpp b/test/numeric/order_quadrature_formula.cpp index 276e272b..bf976d77 100644 --- a/test/numeric/order_quadrature_formula.cpp +++ b/test/numeric/order_quadrature_formula.cpp @@ -1,7 +1,6 @@ /* Boost numeric test for orders of quadrature formulas test file - Copyright 2012 Mario Mulansky - Copyright 2012 Karsten Ahnert + Copyright 2015 Gregor de Cillia Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or From f5079fb258d32ae4bc99b55b698e3b571bc608f5 Mon Sep 17 00:00:00 2001 From: Mario Mulansky Date: Wed, 21 Jan 2015 13:52:56 +0100 Subject: [PATCH 64/70] add init_stepper as template param to abm stepper The Adams-Bashforth-Moulton stepper has now also the initializing stepper as a template parameter. This allows to get rid of the specific test case for multi-step methods in order_quadrature_formula. Furthermore, some cosmetic adjustments were made in this test: global variables, camel case naming, while loop -> for loop. --- .../stepper/adams_bashforth_moulton.hpp | 8 +- test/numeric/order_quadrature_formula.cpp | 238 ++++++++---------- 2 files changed, 107 insertions(+), 139 deletions(-) diff --git a/include/boost/numeric/odeint/stepper/adams_bashforth_moulton.hpp b/include/boost/numeric/odeint/stepper/adams_bashforth_moulton.hpp index 6470fbb4..2f7cc4c6 100644 --- a/include/boost/numeric/odeint/stepper/adams_bashforth_moulton.hpp +++ b/include/boost/numeric/odeint/stepper/adams_bashforth_moulton.hpp @@ -49,7 +49,8 @@ class Deriv = State , class Time = Value , class Algebra = typename algebra_dispatcher< State >::algebra_type , class Operations = typename operations_dispatcher< State >::operations_type , -class Resizer = initially_resizer +class Resizer = initially_resizer, +class InitializingStepper = runge_kutta4< State , Value , Deriv , Time , Algebra , Operations, Resizer > > class adams_bashforth_moulton { @@ -71,12 +72,13 @@ public : typedef Operations operations_type; typedef Resizer resizer_type; typedef stepper_tag stepper_category; + typedef InitializingStepper initializing_stepper_type; static const size_t steps = Steps; #ifndef DOXYGEN_SKIP - typedef adams_bashforth< steps , state_type , value_type , deriv_type , time_type , algebra_type , operations_type , resizer_type > adams_bashforth_type; + typedef adams_bashforth< steps , state_type , value_type , deriv_type , time_type , algebra_type , operations_type , resizer_type, initializing_stepper_type > adams_bashforth_type; typedef adams_moulton< steps , state_type , value_type , deriv_type , time_type , algebra_type , operations_type , resizer_type > adams_moulton_type; - typedef adams_bashforth_moulton< steps , state_type , value_type , deriv_type , time_type , algebra_type , operations_type , resizer_type > stepper_type; + typedef adams_bashforth_moulton< steps , state_type , value_type , deriv_type , time_type , algebra_type , operations_type , resizer_type , initializing_stepper_type> stepper_type; #endif //DOXYGEN_SKIP typedef unsigned short order_type; static const order_type order_value = steps; diff --git a/test/numeric/order_quadrature_formula.cpp b/test/numeric/order_quadrature_formula.cpp index bf976d77..b73d6a4e 100644 --- a/test/numeric/order_quadrature_formula.cpp +++ b/test/numeric/order_quadrature_formula.cpp @@ -1,6 +1,7 @@ /* Boost numeric test for orders of quadrature formulas test file Copyright 2015 Gregor de Cillia + Copyright 2015 Mario Mulansky Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or @@ -37,129 +38,64 @@ typedef value_type state_type; BOOST_AUTO_TEST_SUITE( order_of_convergence_test ) -value_type tolerance = 1.0e-13; - -struct monome +/* defines the simple monomial f(t) = (p+1) * t^p.*/ +struct monomial { - int exponent; - monome() : exponent( 0 ){}; - void operator()( const state_type &x , state_type &dxdt , const time_type t ){ - dxdt = ( 1.0 + exponent )*pow( t, exponent ); + int power; + + monomial(int p = 0) : power( p ){}; + + void operator()( const state_type &x , state_type &dxdt , const time_type t ) + { + dxdt = ( 1.0 + power ) * pow( t, power ); } }; -monome rhs; /* generic test for all steppers that support integrate_const */ template< class Stepper > -struct integrate_const_test +struct stepper_order_test { - double maxError; - int estimatedOrder; - void operator()( int nSteps = 1 ) + void operator()( int steps = 1 ) { - estimateOrder(); - std::cout << boost::format( "%-20i%-20i%-20E\n" ) - % estimatedOrder % definedOrder() % maxError; + const int estimated_order = estimate_order( steps ); + const int defined_order = Stepper::order_value; - BOOST_REQUIRE_EQUAL( estimatedOrder, definedOrder() ); + std::cout << boost::format( "%-20i%-20i\n" ) + % estimated_order % defined_order; + + BOOST_REQUIRE_EQUAL( estimated_order, defined_order ); } - const int definedOrder(){ - const Stepper stepper; - return stepper.order(); - } /* the order of the stepper is estimated by trying to solve the ODE - x'(t) = t^p + x'(t) = (p+1) * t^p until the errors are too big to be justified by finite precision. - the first value p for which the problem is *not* solved with - precision `tolerance` is the estimate for the order of the scheme. + the first value p for which the problem is *not* solved within the + finite precision tolerance is the estimate for the order of the scheme. */ - void estimateOrder( int nSteps = 1 ) + int estimate_order( int steps ) { - state_type x; - double t; - maxError = 0; - rhs.exponent = -1; - do{ - // begin with x'(t) = ( t^0 )/1 = 1 - // => x (t) = t - // then use x'(t) = ( t^1 )/2 = t/2 - // => x (t) = t^2 - // ... - rhs.exponent++; - Stepper stepper; - x = 0.0; - t = 0; - for ( int i = 0; i < nSteps; i++ ){ - stepper.do_step( rhs, x, t, 1.0/nSteps ); - t += 1.0/nSteps; - // compute the error using the exact solution x(t)=t^(1+p) - value_type error = fabs( x - pow( t, ( 1.0 + rhs.exponent ) ) ); - maxError = fmax( error, maxError ); - } - } - while ( maxError < tolerance ); - // return the first exponent for which the test failed - estimatedOrder = rhs.exponent; - } -}; + const double dt = 1.0/steps; + const double tolerance = steps*1E-15; + int p; + for( p = 0; true; p++ ) + { + // begin with x'(t) = t^0 = 1 + // => x (t) = t + // then use x'(t) = 2*t^1 + // => x (t) = t^2 + // ... + state_type x = 0.0; - -template< class Stepper > -struct integrate_const_test_initialize -{ - int estimatedOrder; - value_type maxError; - - void operator()( int nSteps = 16 ) - { - estimateOrder( nSteps ); - std::cout << boost::format( "%-20i%-20i%-30E\n" ) - % estimatedOrder % definedOrder() % maxError; - - BOOST_REQUIRE_EQUAL( estimatedOrder, definedOrder() ); - } - - const int definedOrder(){ - const Stepper stepper; - return stepper.order(); - } - /* - just like the other version of estimateOrder(), but with - initization performed by the fehlberg stepper ( order 8 ) - - if the default initialization ( runge kutta 4 ) is used, - the estimated order will never be greater than 4. - */ - void estimateOrder( int nSteps = 16 ) - { - state_type x; - time_type t; - const time_type dt = 1.0/nSteps; - maxError = 0.0; - rhs.exponent = -1; - do{ - rhs.exponent++; - // construct the stepper inside the for loop to reset the - // step storage - Stepper stepper; - x = 0.0; - t = 0.0; - // use a high order method to initialize. - stepper.initialize( runge_kutta_fehlberg78< state_type >(), - rhs, x, t, dt ); - while ( t < 1 ){ - stepper.do_step( rhs, x, t, 1.0/nSteps ); - t += 1.0/nSteps; - // compute the error using the exact solution x(t)=t^(1+p) - value_type error = fabs( x - pow( t, 1.0 + rhs.exponent) ); - maxError = fmax( error, maxError ); - } - } while( maxError < tolerance ); - // return the first exponent for which the test failed - estimatedOrder = rhs.exponent; + double t = integrate_n_steps( Stepper(), monomial( p ), x, 0.0, dt, + steps ); + if( fabs( x - pow( t, ( 1.0 + p ) ) ) > tolerance ) + break; + } + // the smallest power p for which the test failed is the estimated order, + // as the solution for this power is x(t) = t^{p+1} + return p; } }; @@ -176,47 +112,77 @@ typedef mpl::vector< > runge_kutta_steppers; typedef mpl::vector< - adams_bashforth< 2, state_type > , - adams_bashforth< 3, state_type > , - adams_bashforth< 4, state_type > , - adams_bashforth< 5, state_type > , - adams_bashforth< 6, state_type > , - adams_bashforth< 7, state_type > , - adams_bashforth< 8, state_type > , - adams_bashforth_moulton< 2, state_type > , - adams_bashforth_moulton< 3, state_type > , - adams_bashforth_moulton< 4, state_type > , - adams_bashforth_moulton< 5, state_type > , - adams_bashforth_moulton< 6, state_type > , - adams_bashforth_moulton< 7, state_type > , - adams_bashforth_moulton< 8, state_type > - > adams_steppers; + adams_bashforth< 2, state_type, double, state_type, double, + vector_space_algebra, default_operations, + initially_resizer, runge_kutta_fehlberg78< state_type > >, + adams_bashforth< 3, state_type, double, state_type, double, + vector_space_algebra, default_operations, + initially_resizer, runge_kutta_fehlberg78< state_type > >, + adams_bashforth< 4, state_type, double, state_type, double, + vector_space_algebra, default_operations, + initially_resizer, runge_kutta_fehlberg78< state_type > >, + adams_bashforth< 5, state_type, double, state_type, double, + vector_space_algebra, default_operations, + initially_resizer, runge_kutta_fehlberg78< state_type > >, + adams_bashforth< 6, state_type, double, state_type, double, + vector_space_algebra, default_operations, + initially_resizer, runge_kutta_fehlberg78< state_type > >, + adams_bashforth< 7, state_type, double, state_type, double, + vector_space_algebra, default_operations, + initially_resizer, runge_kutta_fehlberg78< state_type > > + > ab_steppers; + + +typedef mpl::vector< + adams_bashforth_moulton< 2, state_type, double, state_type, double, + vector_space_algebra, default_operations, + initially_resizer, + runge_kutta_fehlberg78< state_type > >, + adams_bashforth_moulton< 3, state_type, double, state_type, double, + vector_space_algebra, default_operations, + initially_resizer, + runge_kutta_fehlberg78< state_type > >, + adams_bashforth_moulton< 4, state_type, double, state_type, double, + vector_space_algebra, default_operations, + initially_resizer, + runge_kutta_fehlberg78< state_type > >, + adams_bashforth_moulton< 5, state_type, double, state_type, double, + vector_space_algebra, default_operations, + initially_resizer, + runge_kutta_fehlberg78< state_type > >, + adams_bashforth_moulton< 6, state_type, double, state_type, double, + vector_space_algebra, default_operations, + initially_resizer, + runge_kutta_fehlberg78< state_type > >, + adams_bashforth_moulton< 7, state_type, double, state_type, double, + vector_space_algebra, default_operations, + initially_resizer, + runge_kutta_fehlberg78< state_type > >, + adams_bashforth_moulton< 8, state_type, double, state_type, double, + vector_space_algebra, default_operations, + initially_resizer, + runge_kutta_fehlberg78< state_type > > + > abm_steppers; -BOOST_AUTO_TEST_CASE( print_header ) -{ - std::cout << boost::format( "%-20s%-20s%-30s\n" ) - % "Estimated order" % "defined order" - % "maxError"; -} BOOST_AUTO_TEST_CASE_TEMPLATE( runge_kutta_test , Stepper, runge_kutta_steppers ) { - integrate_const_test< Stepper > tester; - tester(); + stepper_order_test< Stepper > tester; + tester(10); } -BOOST_AUTO_TEST_CASE( print_seperator ) + +BOOST_AUTO_TEST_CASE_TEMPLATE( adams_bashforth_test , Stepper, ab_steppers ) { - std::cout << "-------------------" - << " ABM STEPPERS " - << "-------------------" - << std::endl; + stepper_order_test< Stepper > tester; + tester(16); } -BOOST_AUTO_TEST_CASE_TEMPLATE( adams_moultion_test , Stepper, adams_steppers ) + +BOOST_AUTO_TEST_CASE_TEMPLATE( adams_bashforth_moultion_test , Stepper, abm_steppers ) { - integrate_const_test_initialize< Stepper > tester; - tester(); + stepper_order_test< Stepper > tester; + tester(16); } BOOST_AUTO_TEST_SUITE_END() From 109e9112a832a2ba5b0b807b157e726a863e4d7b Mon Sep 17 00:00:00 2001 From: Mario Mulansky Date: Wed, 21 Jan 2015 14:38:05 +0100 Subject: [PATCH 65/70] added missing adams-bashforth test with 8 steps --- test/numeric/order_quadrature_formula.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test/numeric/order_quadrature_formula.cpp b/test/numeric/order_quadrature_formula.cpp index b73d6a4e..bdf2ae46 100644 --- a/test/numeric/order_quadrature_formula.cpp +++ b/test/numeric/order_quadrature_formula.cpp @@ -128,6 +128,9 @@ typedef mpl::vector< vector_space_algebra, default_operations, initially_resizer, runge_kutta_fehlberg78< state_type > >, adams_bashforth< 7, state_type, double, state_type, double, + vector_space_algebra, default_operations, + initially_resizer, runge_kutta_fehlberg78< state_type > >, + adams_bashforth< 8, state_type, double, state_type, double, vector_space_algebra, default_operations, initially_resizer, runge_kutta_fehlberg78< state_type > > > ab_steppers; From 56850b94e5b2e5410c993893756db4ff89a4614a Mon Sep 17 00:00:00 2001 From: Karsten Ahnert Date: Tue, 27 Jan 2015 09:20:27 +0100 Subject: [PATCH 66/70] fixing broken links to github examples --- doc/Jamfile.v2 | 2 +- ...etails_state_types_algebras_operations.qbk | 8 +- doc/examples_table.qbk | 82 +++++++++---------- doc/getting_started.qbk | 2 +- doc/odeint.qbk | 2 +- doc/tutorial_chaotic_system.qbk | 2 +- doc/tutorial_harmonic_oscillator.qbk | 2 +- doc/tutorial_parallel.qbk | 6 +- doc/tutorial_solar_system.qbk | 2 +- doc/tutorial_special_topics.qbk | 18 ++-- doc/tutorial_stiff_systems.qbk | 2 +- doc/tutorial_thrust_cuda.qbk | 8 +- 12 files changed, 68 insertions(+), 68 deletions(-) diff --git a/doc/Jamfile.v2 b/doc/Jamfile.v2 index 3ca8aa1a..426a9889 100644 --- a/doc/Jamfile.v2 +++ b/doc/Jamfile.v2 @@ -37,7 +37,7 @@ if --enable-index in [ modules.peek : ARGV ] # PDF native index support is probably better for PDFs as then you actually get page numbers. odeint.idx # Specifies the name of the index script to load. - ../../../.. + ../include # Inform Quickbook that there is to be an index(es). enable_index diff --git a/doc/details_state_types_algebras_operations.qbk b/doc/details_state_types_algebras_operations.qbk index a8bc4290..274306b3 100644 --- a/doc/details_state_types_algebras_operations.qbk +++ b/doc/details_state_types_algebras_operations.qbk @@ -124,7 +124,7 @@ If we wouldn't specialize the `is_resizeable` template, the code would still compile but odeint would not adjust the size of temporary internal instances of my_vector and hence try to fill zero-sized vectors resulting in segmentation faults! -The full example can be found in [github_link libs/numeric/odeint/examples/my_vector.cpp my_vector.cpp] +The full example can be found in [github_link examples/my_vector.cpp my_vector.cpp] [endsect] @@ -152,7 +152,7 @@ The following code shows the required template specializations: With these definitions odeint knows how to resize `std::list`s and so they can be used as state types. -A complete example can be found in [github_link libs/numeric/odeint/examples/list_lattice.cpp list_lattice.cpp]. +A complete example can be found in [github_link examples/list_lattice.cpp list_lattice.cpp]. [endsect] @@ -407,7 +407,7 @@ The following code shows the corresponding definitions: Note again, that we haven't supported the requirements for controlled steppers, but only for simple Runge-Kutta methods. You can find the full example in [github_link -libs/numeric/odeint/examples/ublas/lorenz_ublas.cpp lorenz_ublas.cpp]. +examples/ublas/lorenz_ublas.cpp lorenz_ublas.cpp]. [endsect] /] @@ -453,7 +453,7 @@ template argument list: [point3D_main] The whole example can be found in [github_link -libs/numeric/odeint/examples/lorenz_point.cpp lorenz_point.cpp] +examples/lorenz_point.cpp lorenz_point.cpp] [note For the most `state_types`, odeint is able to automatically determine the correct algebra and operations. But if you want to use your own `state_type`, as in this diff --git a/doc/examples_table.qbk b/doc/examples_table.qbk index 05a5a514..e28b7cd7 100644 --- a/doc/examples_table.qbk +++ b/doc/examples_table.qbk @@ -15,128 +15,128 @@ [table Examples Overview [[File] [Brief Description]] - [[[github_link libs/numeric/odeint/examples/bind_member_functions.cpp bind_member_functions.cpp]] + [[[github_link examples/bind_member_functions.cpp bind_member_functions.cpp]] [This examples shows how member functions can be used as system functions in odeint.]] - [[[github_link libs/numeric/odeint/examples/bind_member_functions.cpp bind_member_functions_cpp11.cpp]] + [[[github_link examples/bind_member_functions.cpp bind_member_functions_cpp11.cpp]] [This examples shows how member functions can be used as system functions in odeint with `std::bind` in C++11.]] - [[[github_link libs/numeric/odeint/examples/bulirsch_stoer.cpp bulirsch_stoer.cpp]] + [[[github_link examples/bulirsch_stoer.cpp bulirsch_stoer.cpp]] [Shows the usage of the Bulirsch-Stoer method.]] - [[[github_link libs/numeric/odeint/examples/chaotic_system.cpp chaotic_system.cpp]] + [[[github_link examples/chaotic_system.cpp chaotic_system.cpp]] [The chaotic system examples integrates the Lorenz system and calculates the Lyapunov exponents.]] - [[[github_link libs/numeric/odeint/examples/elliptic_functions.cpp elliptic_functions.cpp]] + [[[github_link examples/elliptic_functions.cpp elliptic_functions.cpp]] [Example calculating the elliptic functions using Bulirsch-Stoer and Runge-Kutta-Dopri5 Steppers with dense output.]] - [[[github_link libs/numeric/odeint/examples/fpu.cpp fpu.cpp]] + [[[github_link examples/fpu.cpp fpu.cpp]] [The Fermi-Pasta-Ulam (FPU) example shows how odeint can be used to integrate lattice systems.]] - [[[github_link libs/numeric/odeint/examples/generation_functions.cpp generation_functions.cpp]] + [[[github_link examples/generation_functions.cpp generation_functions.cpp]] [Shows skeletal code on how to implement own factory functions.]] - [[[github_link libs/numeric/odeint/examples/harmonic_oscillator.cpp harmonic_oscillator.cpp]] + [[[github_link examples/harmonic_oscillator.cpp harmonic_oscillator.cpp]] [The harmonic oscillator examples gives a brief introduction to odeint and shows the usage of the classical Runge-Kutta-solvers.]] - [[[github_link libs/numeric/odeint/examples/harmonic_oscillator_units.cpp harmonic_oscillator_units.cpp]] + [[[github_link examples/harmonic_oscillator_units.cpp harmonic_oscillator_units.cpp]] [This examples shows how __boost_units can be used with odeint.]] - [[[github_link libs/numeric/odeint/examples/heun.cpp heun.cpp]] + [[[github_link examples/heun.cpp heun.cpp]] [The Heun example shows how an custom Runge-Kutta stepper can be created with odeint generic Runge-Kutta method.]] - [[[github_link libs/numeric/odeint/examples/list_lattice.cpp list_lattice.cpp]] + [[[github_link examples/list_lattice.cpp list_lattice.cpp]] [Example of a phase lattice integration using `std::list` as state type.]] - [[[github_link libs/numeric/odeint/examples/lorenz_point.cpp lorenz_point.cpp]] + [[[github_link examples/lorenz_point.cpp lorenz_point.cpp]] [Alternative way of integrating lorenz by using a self defined point3d data type as state type.]] - [[[github_link libs/numeric/odeint/examples/my_vector.cpp my_vector.cpp]] + [[[github_link examples/my_vector.cpp my_vector.cpp]] [Simple example showing how to get odeint to work with a self-defined vector type.]] - [[[github_link libs/numeric/odeint/examples/phase_oscillator_ensemble.cpp phase_oscillator_ensemble.cpp]] + [[[github_link examples/phase_oscillator_ensemble.cpp phase_oscillator_ensemble.cpp]] [The phase oscillator ensemble example shows how globally coupled oscillators can be analyzed and how statistical measures can be computed during integration.]] - [[[github_link libs/numeric/odeint/examples/resizing_lattice.cpp resizing_lattice.cpp]] + [[[github_link examples/resizing_lattice.cpp resizing_lattice.cpp]] [Shows the strength of odeint's memory management by simulating a Hamiltonian system on an expanding lattice.]] - [[[github_link libs/numeric/odeint/examples/simple1d.cpp simple1d.cpp]] + [[[github_link examples/simple1d.cpp simple1d.cpp]] [Integrating a simple, one-dimensional ODE showing the usage of integrate- and generate-functions.]] - [[[github_link libs/numeric/odeint/examples/solar_system.cpp solar_system.cpp]] + [[[github_link examples/solar_system.cpp solar_system.cpp]] [The solar system example shows the usage of the symplectic solvers.]] - [[[github_link libs/numeric/odeint/examples/stepper_details.cpp stepper_details.cpp]] + [[[github_link examples/stepper_details.cpp stepper_details.cpp]] [Trivial example showing the usability of the several stepper classes.]] - [[[github_link libs/numeric/odeint/examples/stiff_system.cpp stiff_system.cpp]] + [[[github_link examples/stiff_system.cpp stiff_system.cpp]] [The stiff system example shows the usage of the stiff solvers using the Jacobian of the system function.]] - [[[github_link libs/numeric/odeint/examples/stochastic_euler.cpp stochastic_euler.cpp]] + [[[github_link examples/stochastic_euler.cpp stochastic_euler.cpp]] [Implementation of a custom stepper - the stochastic euler - for solving stochastic differential equations.]] - [[[github_link libs/numeric/odeint/examples/stuart_landau.cpp stuart_landau.cpp]] + [[[github_link examples/stuart_landau.cpp stuart_landau.cpp]] [The Stuart-Landau example shows how odeint can be used with complex state types.]] - [[[github_link libs/numeric/odeint/examples/two_dimensional_phase_lattice.cpp two_dimensional_phase_lattice.cpp]] + [[[github_link examples/two_dimensional_phase_lattice.cpp two_dimensional_phase_lattice.cpp]] [The 2D phase oscillator example shows how a two-dimensional lattice works with odeint and how matrix types can be used as state types in odeint.]] - [[[github_link libs/numeric/odeint/examples/van_der_pol_stiff.cpp van_der_pol_stiff.cpp]] + [[[github_link examples/van_der_pol_stiff.cpp van_der_pol_stiff.cpp]] [This stiff system example again shows the usage of the stiff solvers by integrating the van der Pol oscillator.]] - [[[github_link libs/numeric/odeint/examples/gmpxx/lorenz_gmpxx.cpp gmpxx/lorenz_gmpxx.cpp]] + [[[github_link examples/gmpxx/lorenz_gmpxx.cpp gmpxx/lorenz_gmpxx.cpp]] [This examples integrates the Lorenz system by means of an arbitrary precision type.]] - [[[github_link libs/numeric/odeint/examples/mtl/gauss_packet.cpp mtl/gauss_packet.cpp]] + [[[github_link examples/mtl/gauss_packet.cpp mtl/gauss_packet.cpp]] [The MTL-Gauss-packet example shows how the MTL can be easily used with odeint.]] - [[[github_link libs/numeric/odeint/examples/mtl/implicit_euler_mtl.cpp mtl/implicit_euler_mtl.cpp]] + [[[github_link examples/mtl/implicit_euler_mtl.cpp mtl/implicit_euler_mtl.cpp]] [This examples shows the usage of the MTL implicit Euler method with a sparse matrix type.]] - [[[github_link libs/numeric/odeint/examples/thrust/phase_oscillator_ensemble.cu thrust/phase_oscillator_ensemble.cu]] + [[[github_link examples/thrust/phase_oscillator_ensemble.cu thrust/phase_oscillator_ensemble.cu]] [The Thrust phase oscillator ensemble example shows how globally coupled oscillators can be analyzed with Thrust and CUDA, employing the power of modern graphic devices.]] - [[[github_link libs/numeric/odeint/examples/thrust/phase_oscillator_chain.cu thrust/phase_oscillator_chain.cu]] + [[[github_link examples/thrust/phase_oscillator_chain.cu thrust/phase_oscillator_chain.cu]] [The Thrust phase oscillator chain example shows how chains of nearest neighbor coupled oscillators can be integrated with Thrust and odeint.]] - [[[github_link libs/numeric/odeint/examples/thrust/lorenz_parameters.cu thrust/lorenz_parameters.cu]] + [[[github_link examples/thrust/lorenz_parameters.cu thrust/lorenz_parameters.cu]] [The Lorenz parameters examples show how ensembles of ordinary differential equations can be solved by means of Thrust to study the dependence of an ODE on some parameters.]] - [[[github_link libs/numeric/odeint/examples/thrust/relaxation.cu thrust/relaxation.cu]] + [[[github_link examples/thrust/relaxation.cu thrust/relaxation.cu]] [Another examples for the usage of Thrust.]] - [[[github_link libs/numeric/odeint/examples/ublas/lorenz_ublas.cpp ublas/lorenz_ublas.cpp]] + [[[github_link examples/ublas/lorenz_ublas.cpp ublas/lorenz_ublas.cpp]] [This example shows how the ublas vector types can be used with odeint.]] - [[[github_link libs/numeric/odeint/examples/vexcl/lorenz_ensemble.cpp vexcl/lorenz_ensemble.cpp]] + [[[github_link examples/vexcl/lorenz_ensemble.cpp vexcl/lorenz_ensemble.cpp]] [This example shows how the VexCL - a framework for OpenCL computation - can be used with odeint.]] - [[[github_link libs/numeric/odeint/examples/openmp/lorenz_ensemble_simple.cpp openmp/lorenz_ensemble_simple.cpp]] + [[[github_link examples/openmp/lorenz_ensemble_simple.cpp openmp/lorenz_ensemble_simple.cpp]] [OpenMP Lorenz attractor parameter study with continuous data.]] - [[[github_link libs/numeric/odeint/examples/openmp/lorenz_ensemble.cpp openmp/lorenz_ensemble.cpp]] + [[[github_link examples/openmp/lorenz_ensemble.cpp openmp/lorenz_ensemble.cpp]] [OpenMP Lorenz attractor parameter study with split data.]] - [[[github_link libs/numeric/odeint/examples/openmp/lorenz_ensemble.cpp openmp/lorenz_ensemble_nested.cpp]] + [[[github_link examples/openmp/lorenz_ensemble.cpp openmp/lorenz_ensemble_nested.cpp]] [OpenMP Lorenz attractor parameter study with nested `vector_space_algebra`.]] - [[[github_link libs/numeric/odeint/examples/openmp/phase_chain.cpp openmp/phase_chain.cpp]] + [[[github_link examples/openmp/phase_chain.cpp openmp/phase_chain.cpp]] [OpenMP nearest neighbour coupled phase chain with continuous state.]] - [[[github_link libs/numeric/odeint/examples/openmp/phase_chain_omp_state.cpp openmp/phase_chain_omp_state.cpp]] + [[[github_link examples/openmp/phase_chain_omp_state.cpp openmp/phase_chain_omp_state.cpp]] [OpenMP nearest neighbour coupled phase chain with split state.]] - [[[github_link libs/numeric/odeint/examples/mpi/phase_chain.cpp mpi/phase_chain.cpp]] + [[[github_link examples/mpi/phase_chain.cpp mpi/phase_chain.cpp]] [MPI nearest neighbour coupled phase chain.]] - [[[github_link libs/numeric/odeint/examples/2d_lattice/spreading.cpp 2d_lattice/spreading.cpp]] + [[[github_link examples/2d_lattice/spreading.cpp 2d_lattice/spreading.cpp]] [This examples shows how a `vector< vector< T > >` can be used a state type for odeint and how a resizing mechanism of this state can be implemented.]] - [[[github_link libs/numeric/odeint/examples/quadmath/black_hole.cpp quadmath/black_hole.cpp]] + [[[github_link examples/quadmath/black_hole.cpp quadmath/black_hole.cpp]] [This examples shows how gcc libquadmath can be used with odeint. It provides a high precision floating point type which is adapted to odeint in this example.]] - [[[github_link libs/numeric/odeint/examples/molecular_dynamics.cpp molecular_dynamics.cpp]] + [[[github_link examples/molecular_dynamics.cpp molecular_dynamics.cpp]] [A very basic molecular dynamics simulation with the Velocity-Verlet method.]] ] diff --git a/doc/getting_started.qbk b/doc/getting_started.qbk index ce00e71e..7819940d 100644 --- a/doc/getting_started.qbk +++ b/doc/getting_started.qbk @@ -133,7 +133,7 @@ to pass this container to the integration function: That is all. You can use functional libraries like __boost_lambda or __boost_phoenix to ease the creation of observer functions. -The full cpp file for this example can be found here: [github_link libs/numeric/odeint/examples/harmonic_oscillator.cpp harmonic_oscillator.cpp] +The full cpp file for this example can be found here: [github_link examples/harmonic_oscillator.cpp harmonic_oscillator.cpp] diff --git a/doc/odeint.qbk b/doc/odeint.qbk index e9fc53fa..275c9bee 100644 --- a/doc/odeint.qbk +++ b/doc/odeint.qbk @@ -181,7 +181,7 @@ [template sub[x]''''''[x]''''''] [template subl[x]''''''__space[x]''''''] -[template github_link[url text]''''''[text]''''''] +[template github_link[url text]''''''[text]''''''] [/ [template github_link[url text]''''''[text]'''''']] diff --git a/doc/tutorial_chaotic_system.qbk b/doc/tutorial_chaotic_system.qbk index 23be5677..93057337 100644 --- a/doc/tutorial_chaotic_system.qbk +++ b/doc/tutorial_chaotic_system.qbk @@ -157,6 +157,6 @@ Having integrated a sufficient number of transients steps we are now able to cal [lyapunov_full_code] -The full code can be found here: [github_link libs/numeric/odeint/examples/chaotic_system.cpp chaotic_system.cpp] +The full code can be found here: [github_link examples/chaotic_system.cpp chaotic_system.cpp] [endsect] diff --git a/doc/tutorial_harmonic_oscillator.qbk b/doc/tutorial_harmonic_oscillator.qbk index a8630ce9..53b8d882 100644 --- a/doc/tutorial_harmonic_oscillator.qbk +++ b/doc/tutorial_harmonic_oscillator.qbk @@ -117,7 +117,7 @@ odeint supports iterators for solving ODEs. That is, you instantiate a pair of i [endsect] -The full source file for this example can be found here: [github_link libs/numeric/odeint/examples/harmonic_oscillator.cpp harmonic_oscillator.cpp] +The full source file for this example can be found here: [github_link examples/harmonic_oscillator.cpp harmonic_oscillator.cpp] [endsect] diff --git a/doc/tutorial_parallel.qbk b/doc/tutorial_parallel.qbk index 00e22d1f..38376f9b 100644 --- a/doc/tutorial_parallel.qbk +++ b/doc/tutorial_parallel.qbk @@ -70,7 +70,7 @@ Note, that you can specify the OpenMP scheduling by calling `omp_set_schedule` in the beginning of your program: [phase_chain_scheduling] -See [github_link libs/numeric/odeint/examples/openmp/phase_chain.cpp +See [github_link examples/openmp/phase_chain.cpp openmp/phase_chain.cpp] for the complete example. [heading Split state] @@ -109,7 +109,7 @@ back together into a single vector. and supports any model of Random Access Range as the outer, parallel state type, and will use the given algebra on its elements.] -See [github_link libs/numeric/odeint/examples/openmp/phase_chain_omp_state.cpp +See [github_link examples/openmp/phase_chain_omp_state.cpp openmp/phase_chain_omp_state.cpp] for the complete example. [endsect] @@ -165,7 +165,7 @@ guarded by any barriers either, so if you don't manually place any (for example in parameter studies cases where the elements are completely independent) you might see the nodes diverging, returning from this call at different times.] -See [github_link libs/numeric/odeint/examples/mpi/phase_chain.cpp +See [github_link examples/mpi/phase_chain.cpp mpi/phase_chain.cpp] for the complete example. [endsect] diff --git a/doc/tutorial_solar_system.qbk b/doc/tutorial_solar_system.qbk index a56785cb..a9e66779 100644 --- a/doc/tutorial_solar_system.qbk +++ b/doc/tutorial_solar_system.qbk @@ -102,7 +102,7 @@ These integration routine was used to produce the above sketch of the solar syst [tip You can use C++11 lambda to create the observers] -The full example can be found here: [github_link libs/numeric/odeint/examples/solar_system.cpp solar_system.cpp] +The full example can be found here: [github_link examples/solar_system.cpp solar_system.cpp] [endsect] diff --git a/doc/tutorial_special_topics.qbk b/doc/tutorial_special_topics.qbk index 8beff621..0e3e9dc3 100644 --- a/doc/tutorial_special_topics.qbk +++ b/doc/tutorial_special_topics.qbk @@ -46,7 +46,7 @@ found in the section __adapt_state_types. [stuart_landau_integration] The full cpp file for the Stuart-Landau example can be found here [github_link -libs/numeric/odeint/examples/stuart_landau.cpp stuart_landau.cpp] +examples/stuart_landau.cpp stuart_landau.cpp] [endsect] @@ -75,7 +75,7 @@ The observer uses a reference to the system object to calculate the local energi [fpu_observer] -The full cpp file for this FPU example can be found here [github_link libs/numeric/odeint/examples/fpu.cpp fpu.cpp] +The full cpp file for this FPU example can be found here [github_link examples/fpu.cpp fpu.cpp] [endsect] @@ -103,7 +103,7 @@ Now, we do several integrations for different values of ['__epsilon] and record [phase_oscillator_ensemble_integration] -The full cpp file for this example can be found here [github_link libs/numeric/odeint/examples/phase_oscillator_ensemble.cpp phase_oscillator_ensemble.cpp] +The full cpp file for this example can be found here [github_link examples/phase_oscillator_ensemble.cpp phase_oscillator_ensemble.cpp] [endsect] @@ -159,7 +159,7 @@ It is quite easy but the compilation time might take very long. Furthermore, the memory consuming. For example the unit test for the usage of __boost_units in odeint take up to 4 GB of memory at compilation.] -The full cpp file for this example can be found here [github_link libs/numeric/odeint/examples/harmonic_oscillator_units.cpp harmonic_oscillator_units.cpp]. +The full cpp file for this example can be found here [github_link examples/harmonic_oscillator_units.cpp harmonic_oscillator_units.cpp]. [endsect] @@ -179,7 +179,7 @@ In principle this is all. Please note, that the above code is far from being opt [$phase_lattice_2d_0000.jpg] [$phase_lattice_2d_0100.jpg] [$phase_lattice_2d_1000.jpg] -The full cpp for this example can be found here [github_link libs/numeric/odeint/examples/two_dimensional_phase_lattice.cpp two_dimensional_phase_lattice.cpp]. +The full cpp for this example can be found here [github_link examples/two_dimensional_phase_lattice.cpp two_dimensional_phase_lattice.cpp]. [endsect] @@ -224,13 +224,13 @@ The actual integration then is straight forward: [mp_lorenz_int] -The full example can be found at [github_link libs/numeric/odeint/examples/multiprecision/lorenz_mp.cpp lorenz_mp.cpp]. +The full example can be found at [github_link examples/multiprecision/lorenz_mp.cpp lorenz_mp.cpp]. Another example that compares the accuracy of the high precision type with -standard double can be found at [github_link libs/numeric/odeint/examples/multiprecision/cmp_precision.cpp cmp_precision.cpp]. +standard double can be found at [github_link examples/multiprecision/cmp_precision.cpp cmp_precision.cpp]. Furthermore, odeint can also be run with other multiprecision libraries, e.g. [@http://gmplib.org/ gmp]. -An example for this is given in [github_link libs/numeric/odeint/examples/gmpxx/lorenz_gmpxx.cpp lorenz_gmpxx.cpp]. +An example for this is given in [github_link examples/gmpxx/lorenz_gmpxx.cpp lorenz_gmpxx.cpp]. [endsect] @@ -267,7 +267,7 @@ The `do_resize` function simply calls `vector.resize` of `q` , `p` and `distr`. [resizing_lattice_resize_function] -The full example can be found in [github_link libs/numeric/odeint/examples/resizing_lattice.cpp resizing_lattice.cpp] +The full example can be found in [github_link examples/resizing_lattice.cpp resizing_lattice.cpp] [endsect] diff --git a/doc/tutorial_stiff_systems.qbk b/doc/tutorial_stiff_systems.qbk index 0ab647df..6e28257a 100644 --- a/doc/tutorial_stiff_systems.qbk +++ b/doc/tutorial_stiff_systems.qbk @@ -56,7 +56,7 @@ During the integration 71 steps have been done. Comparing to a classical Runge-K Note, that we have used __boost_phoenix, a great functional programming library, to create and compose the observer. -The full example can be found here: [github_link libs/numeric/odeint/examples/stiff_system.cpp stiff_system.cpp] +The full example can be found here: [github_link examples/stiff_system.cpp stiff_system.cpp] [endsect] diff --git a/doc/tutorial_thrust_cuda.qbk b/doc/tutorial_thrust_cuda.qbk index 283a834b..4ad6aa05 100644 --- a/doc/tutorial_thrust_cuda.qbk +++ b/doc/tutorial_thrust_cuda.qbk @@ -107,7 +107,7 @@ Then, it is straightforward to integrate the phase ensemble by creating an insta We have to use `boost::ref` here in order to pass the rhs class as reference and not by value. This ensures that the natural frequencies of each oscillator are not copied when calling `integrate_const`. In the full example the performance and results of the Runge-Kutta-4 and the Dopri5 solver are compared. -The full example can be found at [github_link libs/numeric/odeint/examples/thrust/phase_oscillator_ensemble.cu phase_oscillator_example.cu]. +The full example can be found at [github_link examples/thrust/phase_oscillator_ensemble.cu phase_oscillator_example.cu]. [endsect] @@ -130,7 +130,7 @@ Now we put everything together. We create random initial conditions and decreasi [thrust_phase_chain_integration] -The full example can be found at [github_link libs/numeric/odeint/examples/thrust/phase_oscillator_chain.cu phase_oscillator_chain.cu]. +The full example can be found at [github_link examples/thrust/phase_oscillator_chain.cu phase_oscillator_chain.cu]. [endsect] @@ -153,7 +153,7 @@ The next thing we have to implement is the Lorenz system without perturbations. As `state_type` a `thrust::device_vector` or a __boost_range of a `device_vector` is used. The length of the state is ['3N] where ['N] is the number of systems. The system is encoded into this vector such that all ['x] components come first, then every ['y] components and finally every ['z] components. Implementing the device function is then a simple task, you only have to decompose the tuple originating from the zip iterators. -Besides the system without perturbations we furthermore need to calculate the system including linearized equations governing the time evolution of small perturbations. Using the method from above this is straightforward, with a small difficulty that Thrust's tuples have a maximal arity of 10. But this is only a small problem since we can create a zip iterator packed with zip iterators. So the top level zip iterator contains one zip iterator for the state, one normal iterator for the parameter, and one zip iterator for the derivative. Accessing the elements of this tuple in the system function is then straightforward, you unpack the tuple with `thrust::get<>()`. We will not show the code here, it is to large. It can be found [github_link libs/numeric/odeint/examples/thrust/lorenz_parameters.cu here] and is easy to understand. +Besides the system without perturbations we furthermore need to calculate the system including linearized equations governing the time evolution of small perturbations. Using the method from above this is straightforward, with a small difficulty that Thrust's tuples have a maximal arity of 10. But this is only a small problem since we can create a zip iterator packed with zip iterators. So the top level zip iterator contains one zip iterator for the state, one normal iterator for the parameter, and one zip iterator for the derivative. Accessing the elements of this tuple in the system function is then straightforward, you unpack the tuple with `thrust::get<>()`. We will not show the code here, it is to large. It can be found [github_link examples/thrust/lorenz_parameters.cu here] and is easy to understand. Furthermore, we need an observer which determines the norm of the perturbations, normalizes them and averages the logarithm of the norm. The device functor which is used within this observer is defined @@ -165,7 +165,7 @@ Now we complete the whole code to calculate the Lyapunov exponents. First, we ha [thrust_lorenz_parameters_integration] -The full example can be found at [github_link libs/numeric/odeint/examples/thrust/lorenz_parameters.cu lorenz_parameters.cu]. +The full example can be found at [github_link examples/thrust/lorenz_parameters.cu lorenz_parameters.cu]. [endsect] From fe00c541a9b16b353d47d3dfeb56d13096fa57a7 Mon Sep 17 00:00:00 2001 From: Mario Mulansky Date: Tue, 27 Jan 2015 14:06:33 +0100 Subject: [PATCH 67/70] added test case for issue #149 --- test/regression/Jamfile.v2 | 1 + test/regression/regression_149.cpp | 84 ++++++++++++++++++++++++++++++ 2 files changed, 85 insertions(+) create mode 100644 test/regression/regression_149.cpp diff --git a/test/regression/Jamfile.v2 b/test/regression/Jamfile.v2 index 6bf16f1c..3ac05361 100644 --- a/test/regression/Jamfile.v2 +++ b/test/regression/Jamfile.v2 @@ -24,5 +24,6 @@ project test-suite "odeint" : [ run regression_147.cpp ] + [ compile regression_149.cpp : -std=c++11 ] : valgrind ; diff --git a/test/regression/regression_149.cpp b/test/regression/regression_149.cpp new file mode 100644 index 00000000..a61082b3 --- /dev/null +++ b/test/regression/regression_149.cpp @@ -0,0 +1,84 @@ +/* + + [begin_description] + Test case for issue 149: + Error C2582 with msvc-10 when using iterator-based integration + [end_description] + + Copyright 2011-2015 Karsten Ahnert + Copyright 2011-2015 Mario Mulansky + + Distributed under the Boost Software License, Version 1.0. + (See accompanying file LICENSE_1_0.txt or + copy at http://www.boost.org/LICENSE_1_0.txt) + */ + + +// disable checked iterator warning for msvc + +#include +#ifdef BOOST_MSVC + #pragma warning(disable:4996) +#endif + +#define BOOST_TEST_MODULE odeint_regression_147 + +#include +#include + +#include + +#include +#include + +#include + +using namespace boost::unit_test; +using namespace boost::numeric::odeint; +namespace mpl = boost::mpl; + +typedef std::vector state_type; + +void rhs( const state_type &x , state_type &dxdt , const double t ) +{ +} + + +template +struct perform_test +{ + void operator()( void ) + { + bulirsch_stoer< state_type > stepper( 1e-9, 0.0, 0.0, 0.0 ); + state_type x( 3, 10.0 ); + + auto iter = boost::find_if( + make_adaptive_time_range( stepper, rhs, x, 0.0, 1.0, 0.01 ), + []( const std::pair< const state_type &, double > &x ) + { return ( x.first[0] < 0.0 ); } ); + + std::cout << iter->second << "\t" << iter->first[0] << "\t" + << iter->first[1] << "\t" << iter->first[2] << "\n"; + } +}; + +typedef mpl::vector< + euler< state_type > , + runge_kutta4< state_type > , + runge_kutta_cash_karp54< state_type > , + runge_kutta_dopri5< state_type > , + runge_kutta_fehlberg78< state_type > , + bulirsch_stoer< state_type > + > steppers; + + +BOOST_AUTO_TEST_SUITE( regression_147_test ) + +BOOST_AUTO_TEST_CASE_TEMPLATE( regression_147_test , Stepper, + steppers ) +{ + perform_test< Stepper > tester; + tester(); +} + +BOOST_AUTO_TEST_SUITE_END() From 54a601d6790967cda7ade62d165bafb6d6d8026a Mon Sep 17 00:00:00 2001 From: Mario Mulansky Date: Tue, 27 Jan 2015 16:35:30 +0100 Subject: [PATCH 68/70] fixed compiler flag --- test/regression/Jamfile.v2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/regression/Jamfile.v2 b/test/regression/Jamfile.v2 index 3ac05361..e44b5354 100644 --- a/test/regression/Jamfile.v2 +++ b/test/regression/Jamfile.v2 @@ -24,6 +24,6 @@ project test-suite "odeint" : [ run regression_147.cpp ] - [ compile regression_149.cpp : -std=c++11 ] + [ compile regression_149.cpp : -std=c++0x ] : valgrind ; From 4adf0b0f802d6a8dd49ff9c3ea30acd2bf50e3d9 Mon Sep 17 00:00:00 2001 From: Karsten Ahnert Date: Thu, 29 Jan 2015 21:45:06 +0100 Subject: [PATCH 69/70] fixes #150 --- include/boost/numeric/odeint/stepper/velocity_verlet.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/boost/numeric/odeint/stepper/velocity_verlet.hpp b/include/boost/numeric/odeint/stepper/velocity_verlet.hpp index 24f3c0e3..3a20fc25 100644 --- a/include/boost/numeric/odeint/stepper/velocity_verlet.hpp +++ b/include/boost/numeric/odeint/stepper/velocity_verlet.hpp @@ -114,7 +114,7 @@ public: algebra_stepper_base_type::m_algebra.for_each4( qout , qin , pin , ain , - typename operations_type::template scale_sum3< value_type , time_type , time_square_type >( one , one_half * dt , one * dt * dt ) ); + typename operations_type::template scale_sum3< value_type , time_type , time_square_type >( one , one * dt , one_half * dt * dt ) ); typename odeint::unwrap_reference< System >::type & sys = system; From d3ca31a8e38256762fb23e9acf3fc76f43214945 Mon Sep 17 00:00:00 2001 From: Karsten Ahnert Date: Thu, 29 Jan 2015 23:27:44 +0100 Subject: [PATCH 70/70] removing warnings, see track ticket #10931 --- .../numeric/odeint/algebra/multi_array_algebra.hpp | 4 ++-- .../odeint/iterator/impl/adaptive_iterator_impl.hpp | 2 +- .../odeint/iterator/impl/const_step_iterator_impl.hpp | 2 +- .../iterator/integrate/detail/integrate_n_steps.hpp | 4 ++-- .../stepper/base/symplectic_rkn_stepper_base.hpp | 2 +- .../stepper/detail/adams_bashforth_call_algebra.hpp | 4 ++-- .../stepper/detail/adams_moulton_call_algebra.hpp | 2 +- include/boost/numeric/odeint/stepper/euler.hpp | 4 ++-- include/boost/numeric/odeint/util/same_instance.hpp | 2 +- test/default_operations.cpp | 11 ----------- 10 files changed, 13 insertions(+), 24 deletions(-) diff --git a/include/boost/numeric/odeint/algebra/multi_array_algebra.hpp b/include/boost/numeric/odeint/algebra/multi_array_algebra.hpp index 4d1fc16c..0bc476e6 100644 --- a/include/boost/numeric/odeint/algebra/multi_array_algebra.hpp +++ b/include/boost/numeric/odeint/algebra/multi_array_algebra.hpp @@ -113,13 +113,13 @@ struct multi_array_algebra template< class S1 , class S2 , class S3 , class S4 , class S5 , class S6 ,class S7 , class S8 , class S9 , class S10 , class S11 , class S12 , class S13 , class S14 , class Op > static void for_each14( S1 &s1 , S2 &s2 , S3 &s3 , S4 &s4 , S5 &s5 , S6 &s6 , S7 &s7 , S8 &s8 , S9 &s9 , S10 &s10 , S11 &s11 , S12 &s12 , S13 &s13 , S14 &s14 , Op op ) { - detail::for_each14( s1.data() , s1.data() + s1.num_elements() , s2.data() , s3.data() , s4.data() , s5.data() , s6.data() , s7.data() , s8.data() , s9.data() , s10.data() , s11.data() , s12.data() , s14.data() , op ); + detail::for_each14( s1.data() , s1.data() + s1.num_elements() , s2.data() , s3.data() , s4.data() , s5.data() , s6.data() , s7.data() , s8.data() , s9.data() , s10.data() , s11.data() , s12.data() , s13.data() , s14.data() , op ); } template< class S1 , class S2 , class S3 , class S4 , class S5 , class S6 ,class S7 , class S8 , class S9 , class S10 , class S11 , class S12 , class S13 , class S14 , class S15 , class Op > static void for_each15( S1 &s1 , S2 &s2 , S3 &s3 , S4 &s4 , S5 &s5 , S6 &s6 , S7 &s7 , S8 &s8 , S9 &s9 , S10 &s10 , S11 &s11 , S12 &s12 , S13 &s13 , S14 &s14 , S15 &s15 , Op op ) { - detail::for_each15( s1.data() , s1.data() + s1.num_elements() , s2.data() , s3.data() , s4.data() , s5.data() , s6.data() , s7.data() , s8.data() , s9.data() , s10.data() , s11.data() , s12.data() , s14.data() , s15.data() , op ); + detail::for_each15( s1.data() , s1.data() + s1.num_elements() , s2.data() , s3.data() , s4.data() , s5.data() , s6.data() , s7.data() , s8.data() , s9.data() , s10.data() , s11.data() , s12.data() , s13.data() , s14.data() , s15.data() , op ); } template< typename S > diff --git a/include/boost/numeric/odeint/iterator/impl/adaptive_iterator_impl.hpp b/include/boost/numeric/odeint/iterator/impl/adaptive_iterator_impl.hpp index 643b5393..e5b4b3cf 100644 --- a/include/boost/numeric/odeint/iterator/impl/adaptive_iterator_impl.hpp +++ b/include/boost/numeric/odeint/iterator/impl/adaptive_iterator_impl.hpp @@ -205,7 +205,7 @@ namespace odeint { * \param sys The system function (ODE) to solve. * \param s The initial state. */ - adaptive_iterator_impl( stepper_type stepper , system_type sys , state_type &s ) + adaptive_iterator_impl( stepper_type stepper , system_type sys , state_type& /* s */ ) : base_type( stepper , sys ) { } protected: diff --git a/include/boost/numeric/odeint/iterator/impl/const_step_iterator_impl.hpp b/include/boost/numeric/odeint/iterator/impl/const_step_iterator_impl.hpp index 449acfa7..e23474c7 100644 --- a/include/boost/numeric/odeint/iterator/impl/const_step_iterator_impl.hpp +++ b/include/boost/numeric/odeint/iterator/impl/const_step_iterator_impl.hpp @@ -77,7 +77,7 @@ namespace odeint { * \param sys The system function (ODE) to solve. * \param s The initial state. const_step_iterator stores a reference of s and changes its value during the iteration. */ - const_step_iterator_impl( stepper_type stepper , system_type sys , state_type &s ) + const_step_iterator_impl( stepper_type stepper , system_type sys , state_type& /* s */ ) : base_type( stepper , sys ) { } protected: diff --git a/include/boost/numeric/odeint/iterator/integrate/detail/integrate_n_steps.hpp b/include/boost/numeric/odeint/iterator/integrate/detail/integrate_n_steps.hpp index 14779904..f90f8875 100644 --- a/include/boost/numeric/odeint/iterator/integrate/detail/integrate_n_steps.hpp +++ b/include/boost/numeric/odeint/iterator/integrate/detail/integrate_n_steps.hpp @@ -48,7 +48,7 @@ Time integrate_n_steps( Observer observer , stepper_tag ) { // ToDo: is there a better way to extract the final time? - Time t; + Time t = start_time; // Assignment is only here to avoid warnings. boost::for_each( make_n_step_time_range( stepper , system , start_state , start_time , dt , num_of_steps ) , obs_caller_time< Observer , Time >( t , observer ) ); @@ -91,7 +91,7 @@ Time integrate_n_steps( Observer observer , dense_output_stepper_tag ) { // ToDo: is there a better way to extract the final time? - Time t; + Time t = start_time; // Assignment is only here to avoid warnings. boost::for_each( make_n_step_time_range( stepper , system , start_state , start_time , dt , num_of_steps ) , obs_caller_time< Observer , Time >( t , observer ) ); diff --git a/include/boost/numeric/odeint/stepper/base/symplectic_rkn_stepper_base.hpp b/include/boost/numeric/odeint/stepper/base/symplectic_rkn_stepper_base.hpp index ea3523e5..eb09aefc 100644 --- a/include/boost/numeric/odeint/stepper/base/symplectic_rkn_stepper_base.hpp +++ b/include/boost/numeric/odeint/stepper/base/symplectic_rkn_stepper_base.hpp @@ -182,7 +182,7 @@ private: // stepper for systems with function for dq/dt = f(p) and dp/dt = -f(q) template< class System , class StateIn , class StateOut > - void do_step_impl( System system , const StateIn &in , time_type t , StateOut &out , time_type dt , boost::mpl::true_ ) + void do_step_impl( System system , const StateIn &in , time_type /* t */ , StateOut &out , time_type dt , boost::mpl::true_ ) { typedef typename odeint::unwrap_reference< System >::type system_type; typedef typename odeint::unwrap_reference< typename system_type::first_type >::type coor_deriv_func_type; diff --git a/include/boost/numeric/odeint/stepper/detail/adams_bashforth_call_algebra.hpp b/include/boost/numeric/odeint/stepper/detail/adams_bashforth_call_algebra.hpp index 168bc692..cc279abb 100644 --- a/include/boost/numeric/odeint/stepper/detail/adams_bashforth_call_algebra.hpp +++ b/include/boost/numeric/odeint/stepper/detail/adams_bashforth_call_algebra.hpp @@ -117,7 +117,7 @@ struct adams_bashforth_call_algebra< 7 , Algebra , Operations > { //BOOST_ASSERT( false ); // not implemented typedef typename Coefficients::value_type value_type; - Algebra::for_each9( out , in , steps[0].m_v , steps[1].m_v , steps[2].m_v , steps[3].m_v , steps[4].m_v , steps[5].m_v , steps[6].m_v , + algebra.for_each9( out , in , steps[0].m_v , steps[1].m_v , steps[2].m_v , steps[3].m_v , steps[4].m_v , steps[5].m_v , steps[6].m_v , typename Operations::template scale_sum8< value_type , Time , Time , Time , Time , Time , Time >( 1.0 , dt * coef[0] , dt * coef[1] , dt * coef[2] , dt * coef[3] , dt * coef[4] , dt * coef[5] , dt * coef[6] ) ); } @@ -132,7 +132,7 @@ struct adams_bashforth_call_algebra< 8 , Algebra , Operations > { //BOOST_ASSERT( false ); // not implemented typedef typename Coefficients::value_type value_type; - Algebra::for_each10( out , in , steps[0].m_v , steps[1].m_v , steps[2].m_v , steps[3].m_v , steps[4].m_v , steps[5].m_v , steps[6].m_v , steps[7].m_v , + algebra.for_each10( out , in , steps[0].m_v , steps[1].m_v , steps[2].m_v , steps[3].m_v , steps[4].m_v , steps[5].m_v , steps[6].m_v , steps[7].m_v , typename Operations::template scale_sum9< value_type , Time , Time , Time , Time , Time , Time , Time >( 1.0 , dt * coef[0] , dt * coef[1] , dt * coef[2] , dt * coef[3] , dt * coef[4] , dt * coef[5] , dt * coef[6] , dt * coef[7] ) ); } diff --git a/include/boost/numeric/odeint/stepper/detail/adams_moulton_call_algebra.hpp b/include/boost/numeric/odeint/stepper/detail/adams_moulton_call_algebra.hpp index f8a15055..b6f5f2a4 100644 --- a/include/boost/numeric/odeint/stepper/detail/adams_moulton_call_algebra.hpp +++ b/include/boost/numeric/odeint/stepper/detail/adams_moulton_call_algebra.hpp @@ -32,7 +32,7 @@ template< class Algebra , class Operations > struct adams_moulton_call_algebra< 1 , Algebra , Operations > { template< class StateIn , class StateOut , class DerivIn , class StepStorage , class Coefficients , class Time > - void operator()( Algebra &algebra , const StateIn &in , StateOut &out , const DerivIn &dxdt , const StepStorage &steps , const Coefficients &coef , Time dt ) const + void operator()( Algebra &algebra , const StateIn &in , StateOut &out , const DerivIn &dxdt , const StepStorage& /* steps */ , const Coefficients &coef , Time dt ) const { typedef typename Coefficients::value_type value_type; algebra.for_each3( out , in , dxdt , typename Operations::template scale_sum2< value_type , Time >( 1.0 , dt * coef[0] ) ); diff --git a/include/boost/numeric/odeint/stepper/euler.hpp b/include/boost/numeric/odeint/stepper/euler.hpp index 443f9427..1c7c126b 100644 --- a/include/boost/numeric/odeint/stepper/euler.hpp +++ b/include/boost/numeric/odeint/stepper/euler.hpp @@ -76,7 +76,7 @@ public : { } template< class System , class StateIn , class DerivIn , class StateOut > - void do_step_impl( System system , const StateIn &in , const DerivIn &dxdt , time_type t , StateOut &out , time_type dt ) + void do_step_impl( System /* system */ , const StateIn &in , const DerivIn &dxdt , time_type /* t */ , StateOut &out , time_type dt ) { stepper_base_type::m_algebra.for_each3( out , in , dxdt , typename operations_type::template scale_sum2< value_type , time_type >( 1.0 , dt ) ); @@ -84,7 +84,7 @@ public : } template< class StateOut , class StateIn1 , class StateIn2 > - void calc_state( StateOut &x , time_type t , const StateIn1 &old_state , time_type t_old , const StateIn2 ¤t_state , time_type t_new ) const + void calc_state( StateOut &x , time_type t , const StateIn1 &old_state , time_type t_old , const StateIn2 & /*current_state*/ , time_type /* t_new */ ) const { const time_type delta = t - t_old; stepper_base_type::m_algebra.for_each3( x , old_state , stepper_base_type::m_dxdt.m_v , diff --git a/include/boost/numeric/odeint/util/same_instance.hpp b/include/boost/numeric/odeint/util/same_instance.hpp index dc55db30..a889ee19 100644 --- a/include/boost/numeric/odeint/util/same_instance.hpp +++ b/include/boost/numeric/odeint/util/same_instance.hpp @@ -25,7 +25,7 @@ namespace odeint { template< class T1 , class T2 , class Enabler=void > struct same_instance_impl { - static bool same_instance( const T1 &x1 , const T2 &x2 ) + static bool same_instance( const T1& /* x1 */ , const T2& /* x2 */ ) { return false; } diff --git a/test/default_operations.cpp b/test/default_operations.cpp index 2b6a7559..a2634b7f 100644 --- a/test/default_operations.cpp +++ b/test/default_operations.cpp @@ -229,12 +229,6 @@ BOOST_AUTO_TEST_CASE_TEMPLATE( scale_sum2_units_test , T , test_types ) typedef unit_fixture< T > fix_type; typedef typename fix_type::value_type value_type; typedef typename fix_type::time_type time_type; - typedef typename fix_type::time_2_type time_2_type; - typedef typename fix_type::time_3_type time_3_type; - typedef typename fix_type::time_4_type time_4_type; - typedef typename fix_type::time_5_type time_5_type; - typedef typename fix_type::time_6_type time_6_type; - typedef typename fix_type::time_7_type time_7_type; fix_type f; typedef default_operations::scale_sum2< value_type , time_type > Op; @@ -249,11 +243,6 @@ BOOST_AUTO_TEST_CASE_TEMPLATE( scale_sum3_units_test , T , test_types ) typedef typename fix_type::value_type value_type; typedef typename fix_type::time_type time_type; typedef typename fix_type::time_2_type time_2_type; - typedef typename fix_type::time_3_type time_3_type; - typedef typename fix_type::time_4_type time_4_type; - typedef typename fix_type::time_5_type time_5_type; - typedef typename fix_type::time_6_type time_6_type; - typedef typename fix_type::time_7_type time_7_type; fix_type f; typedef default_operations::scale_sum3< value_type , time_type , time_2_type > Op;