forked from headmyshoulder/odeint-v2
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
openmp_range_algebra: parallel for over a random access container. openmp_nested_algebra: processs parts of a split container in parallel. openmp_state: a split container based on vector<vector<>>. openmp_algebra: use a range_algebra on each part of that container.
- Loading branch information
Pascal Germroth
committed
Jul 19, 2013
1 parent
53fa449
commit de83cdc
Showing
7 changed files
with
252 additions
and
256 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
101 changes: 0 additions & 101 deletions
101
boost/numeric/odeint/external/openmp/openmp_algebra.hpp
This file was deleted.
Oops, something went wrong.
40 changes: 0 additions & 40 deletions
40
boost/numeric/odeint/external/openmp/openmp_algebra_dispatcher.hpp
This file was deleted.
Oops, something went wrong.
71 changes: 71 additions & 0 deletions
71
boost/numeric/odeint/external/openmp/openmp_nested_algebra.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/* | ||
[auto_generated] | ||
boost/numeric/odeint/external/openmp/openmp_nested_algebra.hpp | ||
[begin_description] | ||
Nested parallelized algebra for OpenMP. | ||
[end_description] | ||
Copyright 2009-2011 Karsten Ahnert | ||
Copyright 2009-2011 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_OPENMP_OPENMP_NESTED_ALGEBRA_HPP_INCLUDED | ||
#define BOOST_NUMERIC_ODEINT_EXTERNAL_OPENMP_OPENMP_NESTED_ALGEBRA_HPP_INCLUDED | ||
|
||
#include <boost/numeric/odeint/algebra/norm_result_type.hpp> | ||
#include <boost/numeric/odeint/util/n_ary_helper.hpp> | ||
|
||
namespace boost { | ||
namespace numeric { | ||
namespace odeint { | ||
|
||
/** \brief OpenMP-parallelized algebra, wrapping another, non-parallelized algebra. | ||
* The NestedState must be a Random Access Container where the elements are sub-states | ||
* which will be processed in parallel. | ||
* | ||
* Requires a NestedState with `s::value_type`, `s[n]` and `s.size()`. | ||
*/ | ||
template< class InnerAlgebra > | ||
struct openmp_nested_algebra | ||
{ | ||
|
||
// FIXME: _Pragma is C++11. | ||
#define BOOST_ODEINT_GEN_BODY(n) \ | ||
const size_t len = s0.size(); \ | ||
_Pragma("omp parallel for schedule(runtime)") \ | ||
for( size_t i = 0 ; i < len ; i++ ) \ | ||
InnerAlgebra::for_each##n( \ | ||
BOOST_PP_ENUM_BINARY_PARAMS(n, s, [i] BOOST_PP_INTERCEPT) , \ | ||
op \ | ||
); | ||
BOOST_ODEINT_GEN_FOR_EACH(BOOST_ODEINT_GEN_BODY) | ||
#undef BOOST_ODEINT_GEN_BODY | ||
|
||
|
||
template< class NestedState > | ||
static typename norm_result_type< typename NestedState::value_type >::type norm_inf( const NestedState &s ) | ||
{ | ||
using std::max; | ||
using std::abs; | ||
typedef typename norm_result_type< typename NestedState::value_type >::type result_type; | ||
result_type init = static_cast< result_type >( 0 ); | ||
# pragma omp parallel for reduction(max: init) schedule(dynamic) | ||
for( size_t i = 0 ; i < s.size() ; i++ ) | ||
init = max( init , InnerAlgebra::norm_inf( s[i] ) ); | ||
return init; | ||
} | ||
|
||
}; | ||
|
||
|
||
} | ||
} | ||
} | ||
|
||
#endif |
65 changes: 65 additions & 0 deletions
65
boost/numeric/odeint/external/openmp/openmp_range_algebra.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/* | ||
[auto_generated] | ||
boost/numeric/odeint/external/openmp/openmp_range_algebra.hpp | ||
[begin_description] | ||
Range algebra for OpenMP. | ||
[end_description] | ||
Copyright 2009-2011 Karsten Ahnert | ||
Copyright 2009-2011 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_OPENMP_OPENMP_RANGE_ALGEBRA_HPP_INCLUDED | ||
#define BOOST_NUMERIC_ODEINT_EXTERNAL_OPENMP_OPENMP_RANGE_ALGEBRA_HPP_INCLUDED | ||
|
||
#include <boost/numeric/odeint/algebra/norm_result_type.hpp> | ||
#include <boost/numeric/odeint/util/n_ary_helper.hpp> | ||
|
||
namespace boost { | ||
namespace numeric { | ||
namespace odeint { | ||
|
||
/** \brief OpenMP-parallelized range algebra. | ||
* | ||
* Requires a state with `s.size()` and `s[n]`, i.e. a Random Access Container. | ||
*/ | ||
struct openmp_range_algebra | ||
{ | ||
|
||
// FIXME: _Pragma is C++11. | ||
#define BOOST_ODEINT_GEN_BODY(n) \ | ||
const size_t len = s0.size(); \ | ||
_Pragma("omp parallel for schedule(runtime)") \ | ||
for( size_t i = 0 ; i < len ; i++ ) \ | ||
op( BOOST_PP_ENUM_BINARY_PARAMS(n, s, [i] BOOST_PP_INTERCEPT) ); | ||
BOOST_ODEINT_GEN_FOR_EACH(BOOST_ODEINT_GEN_BODY) | ||
#undef BOOST_ODEINT_GEN_BODY | ||
|
||
|
||
template< class S > | ||
static typename norm_result_type< S >::type norm_inf( const S &s ) | ||
{ | ||
using std::max; | ||
using std::abs; | ||
typedef typename norm_result_type< S >::type result_type; | ||
result_type init = static_cast< result_type >( 0 ); | ||
# pragma omp parallel for reduction(max: init) schedule(dynamic) | ||
for( size_t i = 0 ; i < s.size() ; ++i ) | ||
init = max( init , abs(s[i]) ); | ||
return init; | ||
} | ||
|
||
}; | ||
|
||
|
||
} | ||
} | ||
} | ||
|
||
#endif |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.