Changeset 2307


Ignore:
Timestamp:
Mar 21, 2012 3:13:44 PM (8 years ago)
Author:
bradbell
Message:

Include automated test for, and fix, bug in thread_alloc.

speed_compare.sh: fix old version of make test command.
alloc_global.sh: original version of test before totally automated.
reachable.sh: add copyright.
thread_alloc.hpp: fix bug, fix documentation of return_memory.

Location:
trunk
Files:
1 added
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/bin/speed_compare.sh

    r2082 r2307  
    22# $Id$
    33# -----------------------------------------------------------------------------
    4 # CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-11 Bradley M. Bell
     4# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell
    55#
    66# CppAD is distributed under multiple licenses. This distribution is under
     
    9292        cd work/speed/src; make clean; make
    9393        #
    94         echo "cd ../cppad; make clean; make test.sh"
    95         cd ../cppad; make clean; make test.sh
     94        echo "cd ../cppad; make clean; make test"
     95        cd ../cppad; make clean; make test
    9696        #
    9797        # run speed test for the current version
     
    125125        cd work/speed/src; make clean; make
    126126        #
    127         echo "cd ../cppad; make clean; make test.sh"
    128         cd ../cppad; make clean; make test.sh
     127        echo "cd ../cppad; make clean; make test"
     128        cd ../cppad; make clean; make test
    129129        #
    130130        #
  • trunk/bug/alloc_global.sh

    • Property svn:keywords set to Id
    r2306 r2307  
    11#! /bin/bash -e
    2 # $Id:$
     2# $Id$
    33# -----------------------------------------------------------------------------
    44# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell
     
    5151}
    5252
    53 // This test routine is only called by the master thread (thread_num = 0).
     53// Test routine called by the master thread (thread_num = 0).
    5454bool alloc_global(void)
    5555{       bool ok = true;
     
    5757        size_t num_threads = NUMBER_THREADS;
    5858
    59         // call setup for using CppAD::AD<double> in parallel mode.
     59        // call setup for using thread_alloc in parallel mode.
    6060        thread_alloc::parallel_setup(num_threads, in_parallel, thread_number);
    6161       
     
    7171
    7272        for(thread_num = 0; thread_num < num_threads; thread_num++)
    73         {       // check calculations by this thread
     73        {       // check calculations by this thread in parallel model
    7474                ok &= thread_all_[thread_num].x[0] == static_cast<double>(thread_num);
    75                 // free memory that was allocated by this thread
     75
     76                // free memory that was allocated by thread thread_num
    7677                thread_all_[thread_num].x.resize(0);
    7778        }
     
    9091echo "./$name"
    9192./$name
     93#
     94echo "rm $name $name.cpp"
     95rm $name $name.cpp
  • trunk/bug/reachable.sh

    r2306 r2307  
     1#! /bin/bash -e
     2# $Id$
     3# -----------------------------------------------------------------------------
     4# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell
     5#
     6# CppAD is distributed under multiple licenses. This distribution is under
     7# the terms of the
     8#                     Common Public License Version 1.0.
     9#
     10# A copy of this license is included in the COPYING file of this distribution.
     11# Please visit http://www.coin-or.org/CppAD/ for information on other licenses.
     12# -----------------------------------------------------------------------------
    113#
    214echo "create reachable.cpp"
  • trunk/cppad/local/epsilon.hpp

    r2283 r2307  
    3737$head Float$$
    3838this type can either be $codei%AD<%Base%>%$$,
    39 or it can be $icode Base$$ for any $code%AD<%Base%>%$$ type;
     39or it can be $icode Base$$ for any $codei%AD<%Base%>%$$ type;
    4040see $cref/base_std_math/base_std_math/epsilon/$$.
    4141
  • trunk/cppad/thread_alloc.hpp

    r2300 r2307  
    290290        static void dec_inuse(size_t dec, size_t thread)
    291291        {       
    292                 CPPAD_ASSERT_UNKNOWN( thread < num_threads() );
     292                CPPAD_ASSERT_UNKNOWN(
     293                        thread < num_threads() || (! in_parallel())
     294                );
    293295                CPPAD_ASSERT_UNKNOWN(
    294296                        thread == thread_num() || (! in_parallel())
     
    904906
    905907$head Purpose$$
    906 If $cref/num_threads/ta_num_threads/$$ is one,
     908If $cref/hold_memory/ta_hold_memory/$$ is false,
    907909the memory is returned to the system.
    908910Otherwise, the memory is retained by $cref thread_alloc$$ for quick future use
     
    915917%$$.
    916918It must be a pointer to memory that is currently in use; i.e.
    917 obtained by a previous call to $cref/get_memory/ta_get_memory/$$ and not yet returned.
     919obtained by a previous call to
     920$cref/get_memory/ta_get_memory/$$ and not yet returned.
    918921
    919922$head Thread$$
  • trunk/omh/whats_new_12.omh

    r2303 r2307  
    3737assist you in learning about changes between various versions of CppAD.
    3838
     39$head 03-21$$
     40Fix an incorrect error check in $code thread_alloc$$
     41that did not allow $cref ta_return_memory$$
     42to return memory in sequential execution mode that was allocated by a
     43different thread during parallel execution.
     44
    3945$head 03-17$$
    4046Debian recently converted the default shell from $code bash$$ to $code dash$$
  • trunk/test_more/makefile.am

    r2281 r2307  
    1515DEFS          =
    1616#
     17if CppAD_OPENMP
     18OPENMP_SRC_FILES   = alloc_openmp.cpp
     19else
     20OPENMP_SRC_FILES   =
     21endif
    1722if CppAD_ADOLC
    1823ADOLC_SRC_FILES   = base_adolc.cpp
    1924ADOLC_INCLUDE     = -I$(ADOLC_DIR)/include
    20 ADOLC_LIB         = -ladolc
    21 ADOLC_LIB_DIRS    = -L$(ADOLC_DIR)/lib -L$(ADOLC_DIR)/lib64
    22 ADOLC_FLAGS       = -DCPPAD_ADOLC_TEST
     25ADOLC_LIB         = -ladolc -L$(ADOLC_DIR)/lib -L$(ADOLC_DIR)/lib64
    2326else
    2427ADOLC_SRC_FILES   =
    2528ADOLC_INCLUDE     =
    2629ADOLC_LIB         =
    27 ADOLC_LIB_DIRS    =
    28 ADOLC_FLAGS       =
    2930endif
    3031if CppAD_BOOST_DIR
     
    4546        -I$(top_srcdir) \
    4647        $(BOOST_INCLUDE) \
    47         $(ADOLC_INCLUDE)
     48        $(ADOLC_INCLUDE) \
     49        $(OPENMP_FLAGS)
    4850#
    4951AM_CXXFLAGS       = -g $(ADOLC_FLAGS) $(CXX_FLAGS)
    5052#
    51 LDADD             = $(ADOLC_LIB)
    52 AM_LDFLAGS        = $(ADOLC_LIB_DIRS)
     53AM_LDFLAGS        = $(ADOLC_LIB) $(OPENMP_FLAGS)
    5354#
    5455test_more_SOURCES  = \
    5556        $(ADOLC_SRC_FILES) \
     57        $(OPENMP_SRC_FILES) \
    5658        test_more.cpp \
    5759        abs.cpp \
  • trunk/test_more/makefile.in

    r2281 r2307  
    4343CONFIG_CLEAN_FILES = test_one.sh
    4444CONFIG_CLEAN_VPATH_FILES =
    45 am__test_more_SOURCES_DIST = base_adolc.cpp test_more.cpp abs.cpp \
    46         acos.cpp asin.cpp add.cpp add_eq.cpp add_zero.cpp atan.cpp \
    47         atan_2.cpp base_alloc.cpp check_simple_vector.cpp compare.cpp \
    48         compare_change.cpp cond_exp.cpp cond_exp_ad.cpp copy.cpp \
    49         cos.cpp cosh.cpp dbl_epsilon.cpp div.cpp div_eq.cpp \
    50         div_zero_one.cpp erf.cpp exp.cpp for_hess.cpp \
    51         for_sparse_jac.cpp forward.cpp from_base.cpp fun_check.cpp \
    52         jacobian.cpp log.cpp log_10.cpp mul.cpp mul_eq.cpp \
    53         mul_level.cpp mul_zero_one.cpp ndebug.cpp near_equal_ext.cpp \
    54         neg.cpp ode_err_control.cpp optimize.cpp parameter.cpp \
    55         poly.cpp pow.cpp pow_int.cpp print_for.cpp romberg_one.cpp \
    56         rosen_34.cpp runge_45.cpp reverse.cpp rev_sparse_hes.cpp \
    57         rev_sparse_jac.cpp rev_two.cpp simple_vector.cpp sin.cpp \
    58         sin_cos.cpp sinh.cpp sparse_hessian.cpp sparse_jacobian.cpp \
    59         sparse_vec_ad.cpp sqrt.cpp std_math.cpp sub.cpp sub_eq.cpp \
    60         sub_zero.cpp tan.cpp track_new_del.cpp value.cpp vec_ad.cpp \
    61         vec_ad_par.cpp vec_unary.cpp
     45am__test_more_SOURCES_DIST = base_adolc.cpp alloc_openmp.cpp \
     46        test_more.cpp abs.cpp acos.cpp asin.cpp add.cpp add_eq.cpp \
     47        add_zero.cpp atan.cpp atan_2.cpp base_alloc.cpp \
     48        check_simple_vector.cpp compare.cpp compare_change.cpp \
     49        cond_exp.cpp cond_exp_ad.cpp copy.cpp cos.cpp cosh.cpp \
     50        dbl_epsilon.cpp div.cpp div_eq.cpp div_zero_one.cpp erf.cpp \
     51        exp.cpp for_hess.cpp for_sparse_jac.cpp forward.cpp \
     52        from_base.cpp fun_check.cpp jacobian.cpp log.cpp log_10.cpp \
     53        mul.cpp mul_eq.cpp mul_level.cpp mul_zero_one.cpp ndebug.cpp \
     54        near_equal_ext.cpp neg.cpp ode_err_control.cpp optimize.cpp \
     55        parameter.cpp poly.cpp pow.cpp pow_int.cpp print_for.cpp \
     56        romberg_one.cpp rosen_34.cpp runge_45.cpp reverse.cpp \
     57        rev_sparse_hes.cpp rev_sparse_jac.cpp rev_two.cpp \
     58        simple_vector.cpp sin.cpp sin_cos.cpp sinh.cpp \
     59        sparse_hessian.cpp sparse_jacobian.cpp sparse_vec_ad.cpp \
     60        sqrt.cpp std_math.cpp sub.cpp sub_eq.cpp sub_zero.cpp tan.cpp \
     61        track_new_del.cpp value.cpp vec_ad.cpp vec_ad_par.cpp \
     62        vec_unary.cpp
    6263@CppAD_ADOLC_TRUE@am__objects_1 = base_adolc.$(OBJEXT)
    63 am_test_more_OBJECTS = $(am__objects_1) test_more.$(OBJEXT) \
    64         abs.$(OBJEXT) acos.$(OBJEXT) asin.$(OBJEXT) add.$(OBJEXT) \
    65         add_eq.$(OBJEXT) add_zero.$(OBJEXT) atan.$(OBJEXT) \
    66         atan_2.$(OBJEXT) base_alloc.$(OBJEXT) \
    67         check_simple_vector.$(OBJEXT) compare.$(OBJEXT) \
    68         compare_change.$(OBJEXT) cond_exp.$(OBJEXT) \
     64@CppAD_OPENMP_TRUE@am__objects_2 = alloc_openmp.$(OBJEXT)
     65am_test_more_OBJECTS = $(am__objects_1) $(am__objects_2) \
     66        test_more.$(OBJEXT) abs.$(OBJEXT) acos.$(OBJEXT) \
     67        asin.$(OBJEXT) add.$(OBJEXT) add_eq.$(OBJEXT) \
     68        add_zero.$(OBJEXT) atan.$(OBJEXT) atan_2.$(OBJEXT) \
     69        base_alloc.$(OBJEXT) check_simple_vector.$(OBJEXT) \
     70        compare.$(OBJEXT) compare_change.$(OBJEXT) cond_exp.$(OBJEXT) \
    6971        cond_exp_ad.$(OBJEXT) copy.$(OBJEXT) cos.$(OBJEXT) \
    7072        cosh.$(OBJEXT) dbl_epsilon.$(OBJEXT) div.$(OBJEXT) \
     
    9092test_more_OBJECTS = $(am_test_more_OBJECTS)
    9193test_more_LDADD = $(LDADD)
    92 am__DEPENDENCIES_1 =
    93 test_more_DEPENDENCIES = $(am__DEPENDENCIES_1)
    9494DEFAULT_INCLUDES =
    9595depcomp = $(SHELL) $(top_srcdir)/depcomp
     
    243243top_builddir = @top_builddir@
    244244top_srcdir = @top_srcdir@
     245@CppAD_OPENMP_FALSE@OPENMP_SRC_FILES =
     246#
     247@CppAD_OPENMP_TRUE@OPENMP_SRC_FILES = alloc_openmp.cpp
    245248@CppAD_ADOLC_FALSE@ADOLC_SRC_FILES =
    246 #
    247249@CppAD_ADOLC_TRUE@ADOLC_SRC_FILES = base_adolc.cpp
    248250@CppAD_ADOLC_FALSE@ADOLC_INCLUDE =
    249251@CppAD_ADOLC_TRUE@ADOLC_INCLUDE = -I$(ADOLC_DIR)/include
    250252@CppAD_ADOLC_FALSE@ADOLC_LIB =
    251 @CppAD_ADOLC_TRUE@ADOLC_LIB = -ladolc
    252 @CppAD_ADOLC_FALSE@ADOLC_LIB_DIRS =
    253 @CppAD_ADOLC_TRUE@ADOLC_LIB_DIRS = -L$(ADOLC_DIR)/lib -L$(ADOLC_DIR)/lib64
    254 @CppAD_ADOLC_FALSE@ADOLC_FLAGS =
    255 @CppAD_ADOLC_TRUE@ADOLC_FLAGS = -DCPPAD_ADOLC_TEST
     253@CppAD_ADOLC_TRUE@ADOLC_LIB = -ladolc -L$(ADOLC_DIR)/lib -L$(ADOLC_DIR)/lib64
    256254@CppAD_BOOST_DIR_FALSE@BOOST_INCLUDE =
    257255@CppAD_BOOST_DIR_TRUE@BOOST_INCLUDE = -I$(BOOST_DIR)
     
    267265        -I$(top_srcdir) \
    268266        $(BOOST_INCLUDE) \
    269         $(ADOLC_INCLUDE)
     267        $(ADOLC_INCLUDE) \
     268        $(OPENMP_FLAGS)
    270269
    271270#
    272271AM_CXXFLAGS = -g $(ADOLC_FLAGS) $(CXX_FLAGS)
    273272#
    274 LDADD = $(ADOLC_LIB)
    275 AM_LDFLAGS = $(ADOLC_LIB_DIRS)
     273AM_LDFLAGS = $(ADOLC_LIB) $(OPENMP_FLAGS)
    276274#
    277275test_more_SOURCES = \
    278276        $(ADOLC_SRC_FILES) \
     277        $(OPENMP_SRC_FILES) \
    279278        test_more.cpp \
    280279        abs.cpp \
     
    403402@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/add_eq.Po@am__quote@
    404403@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/add_zero.Po@am__quote@
     404@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/alloc_openmp.Po@am__quote@
    405405@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/asin.Po@am__quote@
    406406@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/atan.Po@am__quote@
  • trunk/test_more/test_more.cpp

    r2283 r2307  
    2323extern bool AddEq(void);
    2424extern bool AddZero(void);
     25extern bool alloc_openmp(void);
    2526extern bool Asin(void);
    2627extern bool Atan(void);
     
    196197        ok &= Run( base_adolc,      "base_adolc"     );
    197198# endif
     199# ifdef CPPAD_OPENMP_TEST
     200        ok &= Run( alloc_openmp,    "alloc_openmp"   );
     201# endif
    198202
    199203        // check for errors
  • trunk/test_more/test_one.sh.in

    r2237 r2307  
    11# $Id$
    22# -----------------------------------------------------------------------------
    3 # CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-11 Bradley M. Bell
     3# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-12 Bradley M. Bell
    44#
    55# CppAD is distributed under multiple licenses. This distribution is under
     
    3737        -o test_one.exe
    3838        -g -Wall -ansi -pedantic-errors -Wshadow
    39         -std=c++98 -DCPPAD_ADOLC_TEST
    40         -I.. -I/usr/include/boost-1_33_1
     39        -std=c++98
     40        -DCPPAD_ADOLC_TEST
     41        -DCPPAD_OPENMP_TEST
     42        @OPENMP_FLAGS@
     43        -I..
    4144"
    4245if [ -e @ADOLC_DIR@/include ]
Note: See TracChangeset for help on using the changeset viewer.