Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r65762 - in sandbox/odeint/branches/karsten: . boost/numeric/odeint/algebra/external libs/numeric/odeint/test/mkl
From: mario.mulansky_at_[hidden]
Date: 2010-10-05 07:14:28


Author: mariomulansky
Date: 2010-10-05 07:14:18 EDT (Tue, 05 Oct 2010)
New Revision: 65762
URL: http://svn.boost.org/trac/boost/changeset/65762

Log:
added a quick'n'dirty binding for using explicit_euler with intel mkl routines
Added:
   sandbox/odeint/branches/karsten/boost/numeric/odeint/algebra/external/mkl_operations.hpp (contents, props changed)
   sandbox/odeint/branches/karsten/libs/numeric/odeint/test/mkl/
   sandbox/odeint/branches/karsten/libs/numeric/odeint/test/mkl/Jamfile (contents, props changed)
   sandbox/odeint/branches/karsten/libs/numeric/odeint/test/mkl/check_mkl.cpp (contents, props changed)
Text files modified:
   sandbox/odeint/branches/karsten/Jamroot | 6 ++++++
   1 files changed, 6 insertions(+), 0 deletions(-)

Modified: sandbox/odeint/branches/karsten/Jamroot
==============================================================================
--- sandbox/odeint/branches/karsten/Jamroot (original)
+++ sandbox/odeint/branches/karsten/Jamroot 2010-10-05 07:14:18 EDT (Tue, 05 Oct 2010)
@@ -13,7 +13,13 @@
 
 build-project libs/numeric/odeint/examples ;
 build-project libs/numeric/odeint/test ;
+
+# additional tests with external libraries :
 build-project libs/numeric/odeint/test/gmp ;
+build-project libs/numeric/odeint/test/mkl ;
+#build-project libs/numeric/odeint/test/gsl ;
+
+# docs:
 # build-project libs/numeric/odeint/doc ;
 
 

Added: sandbox/odeint/branches/karsten/boost/numeric/odeint/algebra/external/mkl_operations.hpp
==============================================================================
--- (empty file)
+++ sandbox/odeint/branches/karsten/boost/numeric/odeint/algebra/external/mkl_operations.hpp 2010-10-05 07:14:18 EDT (Tue, 05 Oct 2010)
@@ -0,0 +1,62 @@
+/*
+ boost header: BOOST_NUMERIC_ODEINT/mkl_operations.hpp
+
+ Algebra for using the Intel Math Kernel Library Blas1 routines in odeint
+
+ Copyright 2009 Karsten Ahnert
+ Copyright 2009 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_MKL_OPERATIONS_HPP_INCLUDED
+#define BOOST_NUMERIC_ODEINT_MKL_OPERATIONS_HPP_INCLUDED
+
+#include <mkl_blas.h>
+
+/* exemplary example for writing bindings to the Intel MKL library
+ * see test/mkl for how to use mkl with odeint
+ * this is a quick and dirty implementation showing the general possibility.
+ * It works only with containers based on double and sequentiel memory allocation.
+ */
+
+namespace boost {
+namespace numeric {
+namespace odeint {
+
+/* only defined for doubles */
+struct mkl_operations
+{
+
+ typedef double time_type;
+
+ struct scale_sum2
+ {
+ const time_type m_alpha1;
+ const time_type m_alpha2;
+
+ scale_sum2( const time_type alpha1 , const time_type alpha2 ) : m_alpha1( alpha1 ) , m_alpha2( alpha2 ) { }
+
+ template< class T1 , class T2 , class T3 >
+ void operator()( T1 &t1 , const T2 &t2 , const T3 &t3) const
+ {
+ // we get Containers that have size() and [i]-access
+ const int n = t1.size();
+ const int one = 1;
+ //boost::numeric::odeint::copy( t1 , t3 );
+ t1 = t2;
+ if ( m_alpha1 != 1.0 )
+ dscal( &n , &m_alpha1 , &(t1[0]) , &one );
+ daxpy( &n , &m_alpha2 , &(t3[0]) , &one , &(t1[0]) , &one );
+ }
+ };
+
+};
+
+} // odeint
+} // numeric
+} // boost
+
+#endif /* BOOST_NUMERIC_ODEINT_MKL_OPERATIONS_HPP_INCLUDED */

Added: sandbox/odeint/branches/karsten/libs/numeric/odeint/test/mkl/Jamfile
==============================================================================
--- (empty file)
+++ sandbox/odeint/branches/karsten/libs/numeric/odeint/test/mkl/Jamfile 2010-10-05 07:14:18 EDT (Tue, 05 Oct 2010)
@@ -0,0 +1,30 @@
+# (C) Copyright 2010 : Karsten Ahnert, 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 ;
+
+project
+ : requirements
+ <library>/boost/test//boost_unit_test_framework
+ <include>../../../../..
+ <include>$BOOST_ROOT
+ ;
+
+
+lib libmkl : : <name>mkl_intel_lp64 <link>shared ;
+lib libmkl_core : : <name>mkl_core <link>shared ;
+lib libmkl_intel_thread : : <name>mkl_intel_thread ;
+lib libiomp5 : : <name>iomp5 ;
+lib libpthread : : <name>pthread ;
+
+test-suite "mkl"
+ :
+ [ run check_mkl.cpp libpthread libiomp5 libmkl_core libmkl_intel_thread libmkl
+ :
+ :
+ : <link>shared:<define>BOOST_TEST_DYN_LINK=1
+ ]
+ ;

Added: sandbox/odeint/branches/karsten/libs/numeric/odeint/test/mkl/check_mkl.cpp
==============================================================================
--- (empty file)
+++ sandbox/odeint/branches/karsten/libs/numeric/odeint/test/mkl/check_mkl.cpp 2010-10-05 07:14:18 EDT (Tue, 05 Oct 2010)
@@ -0,0 +1,49 @@
+/* Boost check_mkl.cpp test file
+
+ Copyright 2009 Karsten Ahnert
+ Copyright 2009 Mario Mulansky
+
+ This file tests the odeint library with the intel mkl blas1 routines
+
+ 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 test_mkl
+
+#include <boost/test/unit_test.hpp>
+
+#include <boost/numeric/odeint.hpp>
+#include <boost/numeric/odeint/algebra/vector_space_algebra.hpp>
+#include <boost/numeric/odeint/algebra/external/mkl_operations.hpp>
+
+using namespace boost::numeric::odeint;
+
+typedef double value_type;
+typedef boost::array< value_type , 1 > state_type;
+
+
+void constant_system( state_type &x , state_type &dxdt , value_type t )
+{
+ dxdt[0] = 1.0;
+}
+
+const double eps = 1E-14;
+
+
+BOOST_AUTO_TEST_CASE( test_mkl )
+{
+
+ //to use mkl routines we have to use the vector_space_algebra and the mkl_operations
+ explicit_euler< state_type , value_type , vector_space_algebra , mkl_operations > stepper;
+ state_type x;
+ x[0] = 0.0;
+
+ stepper.do_step( constant_system , x , 0.0 , 0.1 );
+
+ using std::abs;
+
+ BOOST_CHECK_SMALL( abs( x[0] - 0.1 ) , eps );
+
+}


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk