-
Notifications
You must be signed in to change notification settings - Fork 99
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
master: parallel_ad: Increase the set of CheckSimpleVector cases init…
…ialized. check_simple_vector.hpp: Imporve parallel mode error message.
- Loading branch information
Showing
5 changed files
with
57 additions
and
21 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
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
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 |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
# define CPPAD_CORE_PARALLEL_AD_HPP | ||
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later | ||
// SPDX-FileCopyrightText: Bradley M. Bell <[email protected]> | ||
// SPDX-FileContributor: 2003-23 Bradley M. Bell | ||
// SPDX-FileContributor: 2003-24 Bradley M. Bell | ||
// ---------------------------------------------------------------------------- | ||
/* | ||
{xrst_begin parallel_ad} | ||
|
@@ -41,11 +41,11 @@ This routine does extra setup | |
CheckSimpleVector | ||
***************** | ||
This routine has the side effect of calling the routines | ||
``CheckSimpleVector`` < *Type* , ``CppAD::vector<`` *Type* > >() | ||
where *Type* is *Base* and ``AD`` < *Base* > . | ||
This routine has the side effect of calling ``CheckSimpleVector`` | ||
for an unspecified number of cases of | ||
:ref:`CheckSimpleVector@Vector` and :ref:`CheckSimpleVector@Scalar` . | ||
The set of these cases may increase in the future so that the user | ||
does not need to initialize them separately. | ||
Example | ||
******* | ||
|
@@ -76,6 +76,8 @@ they must be initialized separately: | |
----------------------------------------------------------------------------- | ||
*/ | ||
|
||
# include <vector> | ||
# include <cppad/utility/vector.hpp> | ||
# include <cppad/local/std_set.hpp> | ||
# include <cppad/local/val_graph/enable_parallel.hpp> | ||
|
||
|
@@ -123,9 +125,15 @@ void parallel_ad(void) | |
local::val_graph::enable_parallel<Base>(); // val_graph/*_op.hpp | ||
discrete<Base>::List(); // discrete.hpp | ||
|
||
// check_simple_vector.hpp | ||
// Some check_simple_vector.hpp cases | ||
// | ||
CheckSimpleVector< bool, CppAD::vectorBool >(); | ||
CheckSimpleVector< size_t, CppAD::vector<size_t> >(); | ||
CheckSimpleVector< Base, CppAD::vector<Base> >(); | ||
CheckSimpleVector< AD<Base>, CppAD::vector< AD<Base> > >(); | ||
// | ||
CheckSimpleVector< Base, std::vector<Base> >(); | ||
CheckSimpleVector< AD<Base>, std::vector< AD<Base> > >(); | ||
|
||
} | ||
|
||
|
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 |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
# define CPPAD_UTILITY_CHECK_SIMPLE_VECTOR_HPP | ||
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later | ||
// SPDX-FileCopyrightText: Bradley M. Bell <[email protected]> | ||
// SPDX-FileContributor: 2003-23 Bradley M. Bell | ||
// SPDX-FileContributor: 2003-24 Bradley M. Bell | ||
// ---------------------------------------------------------------------------- | ||
/* | ||
{xrst_begin CheckSimpleVector} | ||
|
@@ -12,12 +12,9 @@ Check Simple Vector Concept | |
Syntax | ||
****** | ||
# ``include <cppad/utility/check_simple_vector.hpp>`` | ||
``CheckSimpleVector`` < *Scalar* , *Vector* >() | ||
``CheckSimpleVector`` < *Scalar* , *Vector* >( *x* , *y* ) | ||
| # ``include <cppad/utility/check_simple_vector.hpp>`` | ||
| ``CheckSimpleVector`` < *Scalar* , *Vector* >() | ||
| ``CheckSimpleVector`` < *Scalar* , *Vector* >( *x* , *y* ) | ||
Purpose | ||
******* | ||
|
@@ -29,6 +26,14 @@ a :ref:`SimpleVector-name` class with | |
If a requirement is not satisfied, | ||
a an error message makes it clear what condition is not satisfied. | ||
Vector | ||
****** | ||
is the vector type we are checking. | ||
Scalar | ||
****** | ||
is the type corresponding to the elements of an *Vector* . | ||
x, y | ||
**** | ||
If the arguments *x* and *y* are present, | ||
|
@@ -70,9 +75,12 @@ if the CppAD include files. | |
Parallel Mode | ||
************* | ||
The routine :ref:`thread_alloc::parallel_setup<ta_parallel_setup-name>` | ||
must be called before it | ||
can be used in :ref:`parallel<ta_in_parallel-name>` mode. | ||
This routine must be called before entering parallel mode | ||
because it has static variables that must be initialized. | ||
If it's first call is not in parallel mode, and NDEBUG is not defined, | ||
you will get an assertion. Running in the debugger and going to the | ||
stack frame where CheckSimpleVector is called may help you determine | ||
what the value of *Scalar* and *Vector* need to be initialized. | ||
Example | ||
******* | ||
|
@@ -112,10 +120,17 @@ namespace CppAD { | |
|
||
template <class Scalar, class Vector> | ||
void CheckSimpleVector(const Scalar& x, const Scalar& y) | ||
{ CPPAD_ASSERT_FIRST_CALL_NOT_PARALLEL | ||
static size_t count; | ||
{ // | ||
// count | ||
static size_t count = 0; | ||
if( count > 0 ) | ||
return; | ||
CPPAD_ASSERT_KNOWN( | ||
! CppAD::thread_alloc::in_parallel() , | ||
"In parallel mode and CheckSimpleVector was not previously called\n" | ||
"with this Scalar and Vector type; see the heading\n" | ||
"Parallel Mode in the CheckSimpleVector documentation." | ||
); | ||
count++; | ||
|
||
// value_type must be type of elements of Vector | ||
|
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