Codebase list cppad / f4f7a91
New upstream version 2019.02.00.5 Barak A. Pearlmutter 4 years ago
11 changed file(s) with 143 addition(s) and 22 deletion(s). Raw diff Collapse all Expand all
1717 /new.*/
1818 # directory that is ignored by master, but not by gh-pages
1919 /doc/
20 /dev/
2021 # ----------------------------------------------------------------------------
2122 # specific extensions in top direcotry
2223 /*.err
2424 endif()
2525 #
2626 # cppad_version is used by version.sh to get the version number.
27 SET(cppad_version "20190200.3")
27 SET(cppad_version "20190200.5")
2828 SET(cppad_url "http://www.coin-or.org/CppAD" )
2929 SET(cppad_description "Differentiation of C++ Algorithms" )
3030 #
00 #! /bin/bash -e
11 # -----------------------------------------------------------------------------
2 # CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell
2 # CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-19 Bradley M. Bell
33 #
44 # CppAD is distributed under the terms of the
55 # Eclipse Public License Version 2.0.
164164 # Run automated checks for the form bin/check_*.sh with a few exceptions.
165165 list=`ls bin/check_* | sed \
166166 -e '/check_all.sh/d' \
167 -e '/check_doxygen.sh/d' \
167168 -e '/check_jenkins.sh/d' \
168169 -e '/check_svn_dist.sh/d'`
169170 # ~/devel/check_copyright.sh not included in batch_edit branch
00 #! /bin/sh
11 # 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.
33 #
44 # Report bugs to <cppad@list.coin-or.org>.
55 #
578578 # Identity of this package.
579579 PACKAGE_NAME='cppad'
580580 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'
583583 PACKAGE_BUGREPORT='cppad@list.coin-or.org'
584584 PACKAGE_URL=''
585585
13561356 # Omit some internal or obsolete options to make the list less imposing.
13571357 # This message is too long to be a string in the A/UX 3.1 sh.
13581358 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.
13601360
13611361 Usage: $0 [OPTION]... [VAR=VALUE]...
13621362
14261426
14271427 if test -n "$ac_init_help"; then
14281428 case $ac_init_help in
1429 short | recursive ) echo "Configuration of cppad 20190200.3:";;
1429 short | recursive ) echo "Configuration of cppad 20190200.5:";;
14301430 esac
14311431 cat <<\_ACEOF
14321432
15481548 test -n "$ac_init_help" && exit $ac_status
15491549 if $ac_init_version; then
15501550 cat <<\_ACEOF
1551 cppad configure 20190200.3
1551 cppad configure 20190200.5
15521552 generated by GNU Autoconf 2.69
15531553
15541554 Copyright (C) 2012 Free Software Foundation, Inc.
19211921 This file contains any messages produced by compilers while
19221922 running configure, to aid debugging if configure makes a mistake.
19231923
1924 It was created by cppad $as_me 20190200.3, which was
1924 It was created by cppad $as_me 20190200.5, which was
19251925 generated by GNU Autoconf 2.69. Invocation command line was
19261926
19271927 $ $0 $@
28112811
28122812 # Define the identity of the package.
28132813 PACKAGE='cppad'
2814 VERSION='20190200.3'
2814 VERSION='20190200.5'
28152815
28162816
28172817 cat >>confdefs.h <<_ACEOF
76587658 # report actual input values of CONFIG_FILES etc. instead of their
76597659 # values after options handling.
76607660 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
76627662 generated by GNU Autoconf 2.69. Invocation command line was
76637663
76647664 CONFIG_FILES = $CONFIG_FILES
77157715 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
77167716 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
77177717 ac_cs_version="\\
7718 cppad config.status 20190200.3
7718 cppad config.status 20190200.5
77197719 configured by $0, generated by GNU Autoconf 2.69,
77207720 with options \\"\$ac_cs_config\\"
77217721
1010 # -----------------------------------------------------------------------------
1111 dnl Process this file with autoconf to produce a configure script.
1212 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])
1414 AM_SILENT_RULES([no])
1515
1616 dnl By defalut disable maintainer mode when running configure;
6161
6262 $comment bin/version assumes that : follows cppad version number here$$
6363 $section
64 cppad-20190200.3: A C++ Algorithmic Differentiation Package$$
64 cppad-20190200.5: A C++ Algorithmic Differentiation Package$$
6565
6666 $comment =================================================================== $$
6767 $align middle$$
00 # ifndef CPPAD_CORE_CHKPOINT_TWO_CHKPOINT_TWO_HPP
11 # define CPPAD_CORE_CHKPOINT_TWO_CHKPOINT_TWO_HPP
22 /* --------------------------------------------------------------------------
3 CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell
3 CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-19 Bradley M. Bell
44
55 CppAD is distributed under the terms of the
66 Eclipse Public License Version 2.0.
152152 void allocate_member(size_t thread)
153153 { CPPAD_ASSERT_UNKNOWN( use_in_parallel_ );
154154 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.
156165 member_[thread]->g_ = g_;
157166 member_[thread]->ag_ = ag_;
158167 }
163172 /// free member_ for this thread
164173 void free_member(size_t thread)
165174 { 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
167181 member_[thread] = CPPAD_NULL;
168182 }
169183 return;
00 # ifndef CPPAD_LOCAL_PLAY_PLAYER_HPP
11 # define CPPAD_LOCAL_PLAY_PLAYER_HPP
22 /* --------------------------------------------------------------------------
3 CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell
3 CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-19 Bradley M. Bell
44
55 CppAD is distributed under the terms of the
66 Eclipse Public License Version 2.0.
295295 case InvOp:
296296 case LdpOp:
297297 case LeppOp:
298 case LtppOp:
298299 case NeppOp:
299300 case ParOp:
300301 case AFunOp:
342343 case EqpvOp:
343344 case LdvOp:
344345 case LepvOp:
345 case LtppOp:
346346 case LtpvOp:
347347 case MulpvOp:
348348 case NepvOp:
00 # -----------------------------------------------------------------------------
1 # CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell
1 # CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-19 Bradley M. Bell
22 #
33 # CppAD is distributed under the terms of the
44 # Eclipse Public License Version 2.0.
2222 perfer_reverse.cpp
2323 multi_atomic.cpp
2424 multi_checkpoint.cpp
25 multi_chkpoint_two.cpp
2526 )
2627 set_compile_flags(
2728 test_more_${name} "${cppad_debug_which}" "${source_list}"
00 /* --------------------------------------------------------------------------
1 CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell
1 CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-19 Bradley M. Bell
22
33 CppAD is distributed under the terms of the
44 Eclipse Public License Version 2.0.
1515 extern bool prefer_reverse(void);
1616 extern bool multi_atomic(void);
1717 extern bool multi_checkpoint(void);
18 extern bool multi_chkpoint_two(void);
1819
1920 int main(void)
2021 { std::string group = "test_more/cppad_for_tmb";
2627 Run( implicit_ctor, "implicit_ctor" );
2728 Run( prefer_reverse, "prefer_reverse" );
2829 Run( multi_atomic, "multi_atomic" );
29 Run( multi_checkpoint, "multi_checkpoint" );
30 Run( multi_chkpoint_two, "multi_chkpoint_two" );
3031
3132 // check for memory leak
3233 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 }