New upstream version 2019.02.00.5
Barak A. Pearlmutter
4 years ago
17 | 17 | /new.*/ |
18 | 18 | # directory that is ignored by master, but not by gh-pages |
19 | 19 | /doc/ |
20 | /dev/ | |
20 | 21 | # ---------------------------------------------------------------------------- |
21 | 22 | # specific extensions in top direcotry |
22 | 23 | /*.err |
24 | 24 | endif() |
25 | 25 | # |
26 | 26 | # cppad_version is used by version.sh to get the version number. |
27 | SET(cppad_version "20190200.3") | |
27 | SET(cppad_version "20190200.5") | |
28 | 28 | SET(cppad_url "http://www.coin-or.org/CppAD" ) |
29 | 29 | SET(cppad_description "Differentiation of C++ Algorithms" ) |
30 | 30 | # |
0 | 0 | #! /bin/bash -e |
1 | 1 | # ----------------------------------------------------------------------------- |
2 | # CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell | |
2 | # CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-19 Bradley M. Bell | |
3 | 3 | # |
4 | 4 | # CppAD is distributed under the terms of the |
5 | 5 | # Eclipse Public License Version 2.0. |
164 | 164 | # Run automated checks for the form bin/check_*.sh with a few exceptions. |
165 | 165 | list=`ls bin/check_* | sed \ |
166 | 166 | -e '/check_all.sh/d' \ |
167 | -e '/check_doxygen.sh/d' \ | |
167 | 168 | -e '/check_jenkins.sh/d' \ |
168 | 169 | -e '/check_svn_dist.sh/d'` |
169 | 170 | # ~/devel/check_copyright.sh not included in batch_edit branch |
0 | 0 | #! /bin/sh |
1 | 1 | # Guess values for system-dependent variables and create Makefiles. |
2 | # Generated by GNU Autoconf 2.69 for cppad 20190200.3. | |
2 | # Generated by GNU Autoconf 2.69 for cppad 20190200.5. | |
3 | 3 | # |
4 | 4 | # Report bugs to <cppad@list.coin-or.org>. |
5 | 5 | # |
578 | 578 | # Identity of this package. |
579 | 579 | PACKAGE_NAME='cppad' |
580 | 580 | PACKAGE_TARNAME='cppad' |
581 | PACKAGE_VERSION='20190200.3' | |
582 | PACKAGE_STRING='cppad 20190200.3' | |
581 | PACKAGE_VERSION='20190200.5' | |
582 | PACKAGE_STRING='cppad 20190200.5' | |
583 | 583 | PACKAGE_BUGREPORT='cppad@list.coin-or.org' |
584 | 584 | PACKAGE_URL='' |
585 | 585 | |
1356 | 1356 | # Omit some internal or obsolete options to make the list less imposing. |
1357 | 1357 | # This message is too long to be a string in the A/UX 3.1 sh. |
1358 | 1358 | cat <<_ACEOF |
1359 | \`configure' configures cppad 20190200.3 to adapt to many kinds of systems. | |
1359 | \`configure' configures cppad 20190200.5 to adapt to many kinds of systems. | |
1360 | 1360 | |
1361 | 1361 | Usage: $0 [OPTION]... [VAR=VALUE]... |
1362 | 1362 | |
1426 | 1426 | |
1427 | 1427 | if test -n "$ac_init_help"; then |
1428 | 1428 | case $ac_init_help in |
1429 | short | recursive ) echo "Configuration of cppad 20190200.3:";; | |
1429 | short | recursive ) echo "Configuration of cppad 20190200.5:";; | |
1430 | 1430 | esac |
1431 | 1431 | cat <<\_ACEOF |
1432 | 1432 | |
1548 | 1548 | test -n "$ac_init_help" && exit $ac_status |
1549 | 1549 | if $ac_init_version; then |
1550 | 1550 | cat <<\_ACEOF |
1551 | cppad configure 20190200.3 | |
1551 | cppad configure 20190200.5 | |
1552 | 1552 | generated by GNU Autoconf 2.69 |
1553 | 1553 | |
1554 | 1554 | Copyright (C) 2012 Free Software Foundation, Inc. |
1921 | 1921 | This file contains any messages produced by compilers while |
1922 | 1922 | running configure, to aid debugging if configure makes a mistake. |
1923 | 1923 | |
1924 | It was created by cppad $as_me 20190200.3, which was | |
1924 | It was created by cppad $as_me 20190200.5, which was | |
1925 | 1925 | generated by GNU Autoconf 2.69. Invocation command line was |
1926 | 1926 | |
1927 | 1927 | $ $0 $@ |
2811 | 2811 | |
2812 | 2812 | # Define the identity of the package. |
2813 | 2813 | PACKAGE='cppad' |
2814 | VERSION='20190200.3' | |
2814 | VERSION='20190200.5' | |
2815 | 2815 | |
2816 | 2816 | |
2817 | 2817 | cat >>confdefs.h <<_ACEOF |
7658 | 7658 | # report actual input values of CONFIG_FILES etc. instead of their |
7659 | 7659 | # values after options handling. |
7660 | 7660 | ac_log=" |
7661 | This file was extended by cppad $as_me 20190200.3, which was | |
7661 | This file was extended by cppad $as_me 20190200.5, which was | |
7662 | 7662 | generated by GNU Autoconf 2.69. Invocation command line was |
7663 | 7663 | |
7664 | 7664 | CONFIG_FILES = $CONFIG_FILES |
7715 | 7715 | cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 |
7716 | 7716 | ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" |
7717 | 7717 | ac_cs_version="\\ |
7718 | cppad config.status 20190200.3 | |
7718 | cppad config.status 20190200.5 | |
7719 | 7719 | configured by $0, generated by GNU Autoconf 2.69, |
7720 | 7720 | with options \\"\$ac_cs_config\\" |
7721 | 7721 |
10 | 10 | # ----------------------------------------------------------------------------- |
11 | 11 | dnl Process this file with autoconf to produce a configure script. |
12 | 12 | dnl package version bug-report |
13 | AC_INIT([cppad], [20190200.3], [cppad@list.coin-or.org]) | |
13 | AC_INIT([cppad], [20190200.5], [cppad@list.coin-or.org]) | |
14 | 14 | AM_SILENT_RULES([no]) |
15 | 15 | |
16 | 16 | dnl By defalut disable maintainer mode when running configure; |
61 | 61 | |
62 | 62 | $comment bin/version assumes that : follows cppad version number here$$ |
63 | 63 | $section |
64 | cppad-20190200.3: A C++ Algorithmic Differentiation Package$$ | |
64 | cppad-20190200.5: A C++ Algorithmic Differentiation Package$$ | |
65 | 65 | |
66 | 66 | $comment =================================================================== $$ |
67 | 67 | $align middle$$ |
0 | 0 | # ifndef CPPAD_CORE_CHKPOINT_TWO_CHKPOINT_TWO_HPP |
1 | 1 | # define CPPAD_CORE_CHKPOINT_TWO_CHKPOINT_TWO_HPP |
2 | 2 | /* -------------------------------------------------------------------------- |
3 | CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell | |
3 | CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-19 Bradley M. Bell | |
4 | 4 | |
5 | 5 | CppAD is distributed under the terms of the |
6 | 6 | Eclipse Public License Version 2.0. |
152 | 152 | void allocate_member(size_t thread) |
153 | 153 | { CPPAD_ASSERT_UNKNOWN( use_in_parallel_ ); |
154 | 154 | if( member_[thread] == CPPAD_NULL ) |
155 | { // Other threds have copy of corresponding informaiton. | |
155 | { // allocaate raw memory | |
156 | size_t min_bytes = sizeof(member_struct); | |
157 | size_t num_bytes; | |
158 | void* v_ptr = thread_alloc::get_memory(min_bytes, num_bytes); | |
159 | // convert to member_struct* | |
160 | member_[thread] = reinterpret_cast<member_struct*>(v_ptr); | |
161 | // call member_struct constructor | |
162 | new( member_[thread] ) member_struct; | |
163 | // | |
164 | // The thread has a copy of corresponding informaiton. | |
156 | 165 | member_[thread]->g_ = g_; |
157 | 166 | member_[thread]->ag_ = ag_; |
158 | 167 | } |
163 | 172 | /// free member_ for this thread |
164 | 173 | void free_member(size_t thread) |
165 | 174 | { if( member_[thread] != CPPAD_NULL ) |
166 | { delete member_[thread]; | |
175 | { // call destructor | |
176 | member_[thread]->~member_struct(); | |
177 | // return raw m,emory to available pool for this thread | |
178 | void* v_ptr = reinterpret_cast<void*>(member_[thread]); | |
179 | thread_alloc::return_memory(v_ptr); | |
180 | // mark member for this thread as not allocated | |
167 | 181 | member_[thread] = CPPAD_NULL; |
168 | 182 | } |
169 | 183 | return; |
0 | 0 | # ifndef CPPAD_LOCAL_PLAY_PLAYER_HPP |
1 | 1 | # define CPPAD_LOCAL_PLAY_PLAYER_HPP |
2 | 2 | /* -------------------------------------------------------------------------- |
3 | CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell | |
3 | CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-19 Bradley M. Bell | |
4 | 4 | |
5 | 5 | CppAD is distributed under the terms of the |
6 | 6 | Eclipse Public License Version 2.0. |
295 | 295 | case InvOp: |
296 | 296 | case LdpOp: |
297 | 297 | case LeppOp: |
298 | case LtppOp: | |
298 | 299 | case NeppOp: |
299 | 300 | case ParOp: |
300 | 301 | case AFunOp: |
342 | 343 | case EqpvOp: |
343 | 344 | case LdvOp: |
344 | 345 | case LepvOp: |
345 | case LtppOp: | |
346 | 346 | case LtpvOp: |
347 | 347 | case MulpvOp: |
348 | 348 | case NepvOp: |
0 | 0 | # ----------------------------------------------------------------------------- |
1 | # CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell | |
1 | # CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-19 Bradley M. Bell | |
2 | 2 | # |
3 | 3 | # CppAD is distributed under the terms of the |
4 | 4 | # Eclipse Public License Version 2.0. |
22 | 22 | perfer_reverse.cpp |
23 | 23 | multi_atomic.cpp |
24 | 24 | multi_checkpoint.cpp |
25 | multi_chkpoint_two.cpp | |
25 | 26 | ) |
26 | 27 | set_compile_flags( |
27 | 28 | test_more_${name} "${cppad_debug_which}" "${source_list}" |
0 | 0 | /* -------------------------------------------------------------------------- |
1 | CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell | |
1 | CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-19 Bradley M. Bell | |
2 | 2 | |
3 | 3 | CppAD is distributed under the terms of the |
4 | 4 | Eclipse Public License Version 2.0. |
15 | 15 | extern bool prefer_reverse(void); |
16 | 16 | extern bool multi_atomic(void); |
17 | 17 | extern bool multi_checkpoint(void); |
18 | extern bool multi_chkpoint_two(void); | |
18 | 19 | |
19 | 20 | int main(void) |
20 | 21 | { std::string group = "test_more/cppad_for_tmb"; |
26 | 27 | Run( implicit_ctor, "implicit_ctor" ); |
27 | 28 | Run( prefer_reverse, "prefer_reverse" ); |
28 | 29 | Run( multi_atomic, "multi_atomic" ); |
29 | Run( multi_checkpoint, "multi_checkpoint" ); | |
30 | Run( multi_chkpoint_two, "multi_chkpoint_two" ); | |
30 | 31 | |
31 | 32 | // check for memory leak |
32 | 33 | bool memory_ok = CppAD::thread_alloc::free_all(); |
0 | /* -------------------------------------------------------------------------- | |
1 | CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-19 Bradley M. Bell | |
2 | ||
3 | CppAD is distributed under the terms of the | |
4 | Eclipse Public License Version 2.0. | |
5 | ||
6 | This Source Code may also be made available under the following | |
7 | Secondary License when the conditions for such availability set forth | |
8 | in the Eclipse Public License, Version 2.0 are satisfied: | |
9 | GNU General Public License, Version 2.0 or later. | |
10 | ---------------------------------------------------------------------------- */ | |
11 | # include <cppad/cppad.hpp> | |
12 | # include <omp.h> | |
13 | ||
14 | namespace { | |
15 | ||
16 | typedef CPPAD_TESTVECTOR(double) d_vector; | |
17 | typedef CPPAD_TESTVECTOR( CppAD::AD<double> ) ad_vector; | |
18 | ||
19 | ||
20 | // algorithm that we are checkpoingint | |
21 | const size_t length_of_sum_ = 5000; | |
22 | void long_sum_algo(const ad_vector& ax, ad_vector& ay) | |
23 | { ay[0] = 0.0; | |
24 | for(size_t i = 0; i < length_of_sum_; ++i) | |
25 | ay[0] += ax[0]; | |
26 | return; | |
27 | } | |
28 | // inform CppAD if we are in parallel mode | |
29 | bool in_parallel(void) | |
30 | { return omp_in_parallel() != 0; } | |
31 | // | |
32 | // inform CppAD of the current thread number | |
33 | size_t thread_num(void) | |
34 | { return static_cast<size_t>( omp_get_thread_num() ); } | |
35 | ||
36 | } | |
37 | ||
38 | // multi_thread_chkpoint_two | |
39 | bool multi_chkpoint_two(void) | |
40 | { bool ok = true; | |
41 | ||
42 | // OpenMP setup | |
43 | size_t num_threads = 4; // number of threads | |
44 | omp_set_dynamic(0); // turn off dynamic thread adjustment | |
45 | omp_set_num_threads( int(num_threads) ); // set number of OMP threads | |
46 | ||
47 | // check that multi-threading is possible on this machine | |
48 | if( omp_get_max_threads() < 2 ) | |
49 | { std::cout << "This machine does not support multi-threading: "; | |
50 | } | |
51 | ||
52 | // create ADFun corresponding to long_sum_algo | |
53 | size_t n(1), m(1); | |
54 | ad_vector ax(n), ay(m); | |
55 | ax[0] = 2.0; | |
56 | CppAD::Independent(ax); | |
57 | long_sum_algo(ax, ay); | |
58 | CppAD::ADFun<double> fun(ax, ay); | |
59 | ||
60 | // create chkpoint_two version of algorithm | |
61 | const char* name = "long_sum"; | |
62 | bool internal_bool = false; | |
63 | bool use_hes_sparsity = false; | |
64 | bool use_base2ad = false; | |
65 | bool use_in_parallel = true; | |
66 | CppAD::chkpoint_two<double> chk_fun( fun, name, | |
67 | internal_bool, use_hes_sparsity, use_base2ad, use_in_parallel | |
68 | ); | |
69 | // setup for using CppAD in paralle mode | |
70 | CppAD::thread_alloc::parallel_setup(num_threads, in_parallel, thread_num); | |
71 | CppAD::thread_alloc::hold_memory(true); | |
72 | CppAD::parallel_ad<double>(); | |
73 | ||
74 | // place to hold result for each thread | |
75 | d_vector y(num_threads); | |
76 | for(size_t thread = 0; thread < num_threads; thread++) | |
77 | y[thread] = 0.0; | |
78 | ||
79 | # pragma omp parallel for | |
80 | for(int thread = 0; thread < int(num_threads); thread++) | |
81 | { ad_vector au(n), av(m); | |
82 | au[0] = 1.0; | |
83 | CppAD::Independent(au); | |
84 | chk_fun(au, av); | |
85 | CppAD::ADFun<double> f(au, av); | |
86 | // | |
87 | d_vector x(n), v(m); | |
88 | x[0] = double( thread + 1 ); | |
89 | v = f.Forward(0, x); | |
90 | // | |
91 | // this assigment has false sharing; i.e., will case cache resets | |
92 | // (conversion avoids boost vector conversion warning) | |
93 | y[size_t(thread)] = v[0]; | |
94 | } | |
95 | ||
96 | // check the results | |
97 | for(size_t thread = 0; thread < num_threads; thread++) | |
98 | { double check = double( length_of_sum_ * (thread + 1) ); | |
99 | ok &= check == y[thread]; | |
100 | } | |
101 | return ok; | |
102 | } |