Changeset 2005


Ignore:
Timestamp:
Jul 12, 2011 11:00:51 AM (9 years ago)
Author:
bradbell
Message:
  1. Fix bug: all threads were using the same parameter static hash table.
  2. In output stream, change Ok: to OK: to be consistent.
  3. Add parameter.cpp, a test that the parameter hash coding works well.
  4. Reduce hash table size and use a different one for each possible thread.
Location:
trunk
Files:
1 added
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/AUTHORS

    r1988 r2005  
    22             ===========================================
    33
    4 To date, 2011-06-19, Bradley M. Bell is the sole author of CppAD.
     4To date, 2011-07-12, Bradley M. Bell is the sole author of CppAD.
    55While Bradley M. Bell worked for the University of Washington during
    66the development of CppAD, the following are also true:
  • trunk/configure

    r1988 r2005  
    11#! /bin/sh
    22# Guess values for system-dependent variables and create Makefiles.
    3 # Generated by GNU Autoconf 2.66 for CppAD 20110619.
     3# Generated by GNU Autoconf 2.66 for CppAD 20110712.
    44#
    55# Report bugs to <cppad@list.coin-or.org>.
     
    553553PACKAGE_NAME='CppAD'
    554554PACKAGE_TARNAME='cppad'
    555 PACKAGE_VERSION='20110619'
    556 PACKAGE_STRING='CppAD 20110619'
     555PACKAGE_VERSION='20110712'
     556PACKAGE_STRING='CppAD 20110712'
    557557PACKAGE_BUGREPORT='cppad@list.coin-or.org'
    558558PACKAGE_URL=''
     
    13161316  # This message is too long to be a string in the A/UX 3.1 sh.
    13171317  cat <<_ACEOF
    1318 \`configure' configures CppAD 20110619 to adapt to many kinds of systems.
     1318\`configure' configures CppAD 20110712 to adapt to many kinds of systems.
    13191319
    13201320Usage: $0 [OPTION]... [VAR=VALUE]...
     
    13821382if test -n "$ac_init_help"; then
    13831383  case $ac_init_help in
    1384      short | recursive ) echo "Configuration of CppAD 20110619:";;
     1384     short | recursive ) echo "Configuration of CppAD 20110712:";;
    13851385   esac
    13861386  cat <<\_ACEOF
     
    14971497if $ac_init_version; then
    14981498  cat <<\_ACEOF
    1499 CppAD configure 20110619
     1499CppAD configure 20110712
    15001500generated by GNU Autoconf 2.66
    15011501
     
    20752075running configure, to aid debugging if configure makes a mistake.
    20762076
    2077 It was created by CppAD $as_me 20110619, which was
     2077It was created by CppAD $as_me 20110712, which was
    20782078generated by GNU Autoconf 2.66.  Invocation command line was
    20792079
     
    46994699# Define the identity of the package.
    47004700 PACKAGE='cppad'
    4701  VERSION='20110619'
     4701 VERSION='20110712'
    47024702
    47034703
     
    69286928# values after options handling.
    69296929ac_log="
    6930 This file was extended by CppAD $as_me 20110619, which was
     6930This file was extended by CppAD $as_me 20110712, which was
    69316931generated by GNU Autoconf 2.66.  Invocation command line was
    69326932
     
    69856985ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
    69866986ac_cs_version="\\
    6987 CppAD config.status 20110619
     6987CppAD config.status 20110712
    69886988configured by $0, generated by GNU Autoconf 2.66,
    69896989  with options \\"\$ac_cs_config\\"
  • trunk/configure.ac

    r1988 r2005  
    1313dnl Process this file with autoconf to produce a configure script.
    1414dnl   package   version              bug-report
    15 AC_INIT(CppAD, 20110619, cppad@list.coin-or.org)
     15AC_INIT(CppAD, 20110712, cppad@list.coin-or.org)
    1616AC_SUBST(PACKAGE_URL, "http://www.coin-or.org/CppAD")
    1717AC_SUBST(PACKAGE_DESCRIPTION, "Differentiation of C++ Algorithms")
  • trunk/cppad/configure.hpp

    r1999 r2005  
    4343cppad-yyyymmdd as a C string where yyyy is year, mm is month, and dd is day.
    4444*/
    45 # define CPPAD_PACKAGE_STRING "cppad-20110709"
     45# define CPPAD_PACKAGE_STRING "cppad-20110712"
    4646
    4747/*!
  • trunk/cppad/local/hash_code.hpp

    r1997 r2005  
    2525minus one.
    2626*/
    27 # define CPPAD_HASH_TABLE_SIZE 65536
     27# define CPPAD_HASH_TABLE_SIZE 10000
    2828
    2929/*!
     
    4343
    4444\par Checked Assertions
    45 \li \c std::numeric_limits<unsigned short>::max() == CPPAD_HASH_TABLE_SIZE - 1
     45\li \c std::numeric_limits<unsigned short>::max() >= CPPAD_HASH_TABLE_SIZE
    4646\li \c sizeof(value) is even
    4747\li \c sizeof(unsigned short)  == 2
     
    5252{       CPPAD_ASSERT_UNKNOWN(
    5353                std::numeric_limits<unsigned short>::max()
    54                 ==
    55                 (CPPAD_HASH_TABLE_SIZE-1)
     54                >=
     55                CPPAD_HASH_TABLE_SIZE
    5656        );
    5757        CPPAD_ASSERT_UNKNOWN( sizeof(unsigned short) == 2 );
     
    6969                code += v[i];
    7070
    71         return code;
     71        return code % CPPAD_HASH_TABLE_SIZE;
    7272}
    7373
     
    112112\par Checked Assertions
    113113\c op must be one of the operators specified above. In addition,
    114 \li \c std::numeric_limits<unsigned short>::max() == CPPAD_HASH_TABLE_SIZE - 1
     114\li \c std::numeric_limits<unsigned short>::max() >= CPPAD_HASH_TABLE_SIZE
    115115\li \c sizeof(size_t) is even
    116116\li \c sizeof(Base) is even
     
    128128{       CPPAD_ASSERT_UNKNOWN(
    129129                std::numeric_limits<unsigned short>::max()
    130                 ==
    131                 (CPPAD_HASH_TABLE_SIZE-1)
     130                >=
     131                CPPAD_HASH_TABLE_SIZE
    132132        );
    133133        CPPAD_ASSERT_UNKNOWN( size_t (op) <= size_t(SubvvOp) );
     
    229229        }
    230230
    231         return code;
     231        return code % CPPAD_HASH_TABLE_SIZE;
    232232}
    233233
  • trunk/cppad/local/recorder.hpp

    r1986 r2005  
    5252        /// Character strings ('\\0' terminated) in the recording.
    5353        pod_vector<char> rec_text_;
     54
     55        /// offset for this thread in the static hash table
     56        const size_t thread_offset_;
    5457
    5558// ---------------------- Public Functions -----------------------------------
     
    6265        rec_op_arg_( std::numeric_limits<addr_t>::max() )    ,
    6366        rec_par_( std::numeric_limits<addr_t>::max() )       ,
    64         rec_text_( std::numeric_limits<addr_t>::max() )
     67        rec_text_( std::numeric_limits<addr_t>::max() )      ,
     68        thread_offset_( omp_alloc::get_thread_num() * CPPAD_MAX_NUM_THREADS )
    6569        { }
    6670
     
    203207template <class Base>
    204208size_t recorder<Base>::PutPar(const Base &par)
    205 {       static size_t   hash_table[CPPAD_HASH_TABLE_SIZE];
    206         static bool     init = true;
     209{       static size_t   hash_table[CPPAD_HASH_TABLE_SIZE * CPPAD_MAX_NUM_THREADS];
    207210        size_t          i;
    208         unsigned short  code;
    209 
    210         if( init )
    211         {       // initialize hash table
    212                 for(i = 0; i < CPPAD_HASH_TABLE_SIZE; i++)
    213                         hash_table[i] = 0;
    214                 init = false;
    215         }
    216        
     211        size_t          code;
     212
     213        CPPAD_ASSERT_UNKNOWN(
     214                thread_offset_ / CPPAD_HASH_TABLE_SIZE
     215                ==
     216                omp_alloc::get_thread_num()
     217        );
     218
    217219        // get hash code for this value
    218         code = hash_code(par);
     220        code = static_cast<size_t>( hash_code(par) );
     221        CPPAD_ASSERT_UNKNOWN( code < CPPAD_HASH_TABLE_SIZE );
    219222
    220223        // If we have a match, return the parameter index
    221         i = hash_table[code];
    222         if( i < rec_par_.size() )
    223         {       if( IdenticalEqualPar(rec_par_[i], par) )
     224        i = hash_table[code + thread_offset_];
     225        if( i < rec_par_.size() && IdenticalEqualPar(rec_par_[i], par) )
    224226                        return i;
    225         }
    226227       
    227228        // place a new value in the table
     
    231232
    232233        // make the hash code point to this new value
    233         hash_table[code] = i;
     234        hash_table[code + thread_offset_] = i;
    234235
    235236        // return the parameter index
  • trunk/cppad_ipopt/example/example.cpp

    r1949 r2005  
    3333                ok &= TestOk();
    3434                if( ok )
    35                 {       std::cout << "Ok:    " << name << std::endl;
     35                {       std::cout << "OK:    " << name << std::endl;
    3636                        Run_ok_count++;
    3737                }
     
    6464        else
    6565        {       Run_ok_count++;
    66                 cout << "Ok:    " << "No memory leak detected" << endl;
     66                cout << "OK:    " << "No memory leak detected" << endl;
    6767        }
    6868        // convert int(size_t) to avoid warning on _MSC_VER systems
  • trunk/cppad_ipopt/test/test_more.cpp

    r1949 r2005  
    3434                ok &= TestOk();
    3535                if( ok )
    36                 {       std::cout << "Ok:    " << name << std::endl;
     36                {       std::cout << "OK:    " << name << std::endl;
    3737                        Run_ok_count++;
    3838                }
     
    6767        else
    6868        {       Run_ok_count++;
    69                 cout << "Ok:    " << "No memory leak detected" << endl;
     69                cout << "OK:    " << "No memory leak detected" << endl;
    7070        }
    7171        // convert int(size_t) to avoid warning on _MSC_VER systems
  • trunk/example/example.cpp

    r1953 r2005  
    323323        else
    324324        {       Run_ok_count++;
    325                 cout << "Ok:    " << "No memory leak detected" << endl;
     325                cout << "OK:    " << "No memory leak detected" << endl;
    326326        }
    327327        // convert int(size_t) to avoid warning on _MSC_VER systems
  • trunk/omh/whats_new_11.omh

    r2004 r2005  
    5858assist you in learning about changes between various versions of CppAD.
    5959
     60$head 07-12$$
     61There was one static hash code table that was used by multiple threads
     62during $cref/in_parallel/$$ execution mode.
     63This bug has been fixed.
     64
    6065$head 07-11$$
    6166$list number$$
  • trunk/test_more/makefile.am

    r1986 r2005  
    9191        ode_err_control.cpp \
    9292        optimize.cpp \
     93        parameter.cpp \
    9394        poly.cpp \
    9495        pow.cpp \
  • trunk/test_more/makefile.in

    r1986 r2005  
    5252        jacobian.cpp log.cpp log_10.cpp mul.cpp mul_eq.cpp \
    5353        mul_level.cpp mul_zero_one.cpp ndebug.cpp near_equal_ext.cpp \
    54         neg.cpp ode_err_control.cpp optimize.cpp poly.cpp pow.cpp \
    55         pow_int.cpp romberg_one.cpp rosen_34.cpp runge_45.cpp \
    56         reverse.cpp rev_sparse_hes.cpp rev_sparse_jac.cpp rev_two.cpp \
    57         simple_vector.cpp sin.cpp sin_cos.cpp sinh.cpp \
     54        neg.cpp ode_err_control.cpp optimize.cpp parameter.cpp \
     55        poly.cpp pow.cpp pow_int.cpp romberg_one.cpp rosen_34.cpp \
     56        runge_45.cpp reverse.cpp rev_sparse_hes.cpp rev_sparse_jac.cpp \
     57        rev_two.cpp simple_vector.cpp sin.cpp sin_cos.cpp sinh.cpp \
    5858        sparse_hessian.cpp sparse_jacobian.cpp sparse_vec_ad.cpp \
    5959        sqrt.cpp std_math.cpp sub.cpp sub_eq.cpp sub_zero.cpp \
     
    7575        mul_zero_one.$(OBJEXT) ndebug.$(OBJEXT) \
    7676        near_equal_ext.$(OBJEXT) neg.$(OBJEXT) \
    77         ode_err_control.$(OBJEXT) optimize.$(OBJEXT) poly.$(OBJEXT) \
    78         pow.$(OBJEXT) pow_int.$(OBJEXT) romberg_one.$(OBJEXT) \
    79         rosen_34.$(OBJEXT) runge_45.$(OBJEXT) reverse.$(OBJEXT) \
    80         rev_sparse_hes.$(OBJEXT) rev_sparse_jac.$(OBJEXT) \
    81         rev_two.$(OBJEXT) simple_vector.$(OBJEXT) sin.$(OBJEXT) \
    82         sin_cos.$(OBJEXT) sinh.$(OBJEXT) sparse_hessian.$(OBJEXT) \
     77        ode_err_control.$(OBJEXT) optimize.$(OBJEXT) \
     78        parameter.$(OBJEXT) poly.$(OBJEXT) pow.$(OBJEXT) \
     79        pow_int.$(OBJEXT) romberg_one.$(OBJEXT) rosen_34.$(OBJEXT) \
     80        runge_45.$(OBJEXT) reverse.$(OBJEXT) rev_sparse_hes.$(OBJEXT) \
     81        rev_sparse_jac.$(OBJEXT) rev_two.$(OBJEXT) \
     82        simple_vector.$(OBJEXT) sin.$(OBJEXT) sin_cos.$(OBJEXT) \
     83        sinh.$(OBJEXT) sparse_hessian.$(OBJEXT) \
    8384        sparse_jacobian.$(OBJEXT) sparse_vec_ad.$(OBJEXT) \
    8485        sqrt.$(OBJEXT) std_math.$(OBJEXT) sub.$(OBJEXT) \
     
    309310        ode_err_control.cpp \
    310311        optimize.cpp \
     312        parameter.cpp \
    311313        poly.cpp \
    312314        pow.cpp \
     
    426428@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ode_err_control.Po@am__quote@
    427429@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/optimize.Po@am__quote@
     430@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/parameter.Po@am__quote@
    428431@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/poly.Po@am__quote@
    429432@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pow.Po@am__quote@
  • trunk/test_more/test_more.cpp

    r1949 r2005  
    5858extern bool ode_err_control(void);
    5959extern bool optimize(void);
     60extern bool parameter(void);
    6061extern bool Poly(void);
    6162extern bool Pow(void);
     
    157158        ok &= Run( ode_err_control, "ode_err_control");
    158159        ok &= Run( optimize,        "optimize"       );
     160        ok &= Run( parameter,       "parameter"      );
    159161        ok &= Run( Poly,            "Poly"           );
    160162        ok &= Run( Pow,             "Pow"            );
     
    200202        else
    201203        {       Run_ok_count++;
    202                 cout << "Ok:    " << "No memory leak detected" << endl;
     204                cout << "OK:    " << "No memory leak detected" << endl;
    203205        }
    204206        // convert int(size_t) to avoid warning on _MSC_VER systems
Note: See TracChangeset for help on using the changeset viewer.