Changeset 3370


Ignore:
Timestamp:
Sep 28, 2014 6:52:36 AM (6 years ago)
Author:
bradbell
Message:

Fix three more bugs related to optimizing conditional expressions.

whats_new_14.omh: see these changes for description of bugs.
opt_atomic.sh: Add printing OK or Error at end of test.
template.sh: Add printing OK or Error at end of test.

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/bug/opt_atomic.sh

    r3369 r3370  
    110110        ok &= y_before[0] == y_after[0];
    111111
     112        if( ok )
     113                std::cout << "OK" << std::endl;
     114        else
     115                std::cout << "Error" << std::endl;
     116
    112117        return( ! ok );
    113118}
  • trunk/bug/template.sh

    r3364 r3370  
    4141#
    4242echo "./$name"
    43 ./$name
     43if ./$name
     44then
     45        echo "OK"
     46else
     47        echo "Error"
     48fi
  • trunk/cppad/local/cskip_op.hpp

    r3301 r3370  
    121121        Base left, right;
    122122        if( arg[1] & 1 )
    123         {       CPPAD_ASSERT_UNKNOWN( size_t(arg[2]) <= i_z );
     123        {       // If varialbe arg[2] <= i_z, it has already been computed,
     124                // but it will be skipped for higher orders.
    124125                left = taylor[ arg[2] * cap_order + 0 ];
    125126                CPPAD_ASSERT_UNKNOWN( IdenticalPar(left) );
     
    131132        }
    132133        if( arg[1] & 2 )
    133         {       CPPAD_ASSERT_UNKNOWN( size_t(arg[3]) <= i_z );
     134        {       // If varialbe arg[3] <= i_z, it has already been computed,
     135                // but it will be skipped for higher orders.
    134136                right = taylor[ arg[3] * cap_order + 0 ];
    135137                CPPAD_ASSERT_UNKNOWN( IdenticalPar(right) );
  • trunk/cppad/local/optimize.hpp

    r3367 r3370  
    18471847                                }
    18481848                                else    user_info[user_curr].connect_type = yes_connected;
     1849                                user_r_set[user_i].insert(0);
     1850                                user_r_bool[user_i] = true;
    18491851                                break;
    18501852
     
    19581960                CppAD::index_sort(keys, cskip_info_order);
    19591961        }
    1960         size_t cskip_info_next = 0;
     1962        // index in sorted order
     1963        size_t cskip_order_next = 0;
     1964        // index in order during reverse sweep
     1965        size_t cskip_info_index = cskip_info.size();
    19611966
    19621967
     
    20342039
    20352040                // determine if we should insert a conditional skip here
    2036                 bool skip = cskip_info_next < cskip_info.size();
     2041                bool skip = cskip_order_next < cskip_info.size();
    20372042                skip     &= op != BeginOp;
    20382043                skip     &= op != InvOp;
    20392044                skip     &= user_state == user_start;
    20402045                if( skip )
    2041                 {       j     = cskip_info_order[cskip_info_next];
     2046                {       j     = cskip_info_order[cskip_order_next];
    20422047                        if( NumRes(op) > 0 )
    20432048                                skip &= cskip_info[j].max_left_right < i_var;
     
    20462051                }
    20472052                if( skip )
    2048                 {       cskip_info_next++;
     2053                {       cskip_order_next++;
    20492054                        skip &= cskip_info[j].skip_var_true.size() > 0 ||
    20502055                                        cskip_info[j].skip_var_false.size() > 0;
     
    23542359                        tape[i_var].new_op  = rec->num_op_rec();
    23552360                        tape[i_var].new_var = rec->PutOp(op);
     2361                        //
     2362                        // The new addresses for left and right are used during
     2363                        // fill in the arguments for the CSkip operations. This does not
     2364                        // affect max_left_right which is used during this sweep.
     2365                        CPPAD_ASSERT_UNKNOWN( cskip_info_index > 0 );
     2366                        cskip_info_index--;
     2367                        cskip_info[ cskip_info_index ].left  = new_arg[2];
     2368                        cskip_info[ cskip_info_index ].right = new_arg[3];
    23562369                        break;
    23572370                        // ---------------------------------------------------
     
    25862599
    25872600        // fill in the arguments for the CSkip operations
    2588         CPPAD_ASSERT_UNKNOWN( cskip_info_next == cskip_info.size() );
     2601        CPPAD_ASSERT_UNKNOWN( cskip_order_next == cskip_info.size() );
    25892602        for(i = 0; i < cskip_info.size(); i++)
    25902603        {       struct_cskip_info info = cskip_info[i];
  • trunk/omh/whats_new/whats_new_14.omh

    r3368 r3370  
    5555assist you in learning about changes between various versions of CppAD.
    5656
     57$head 09-28$$
     58Fix three more bugs related to optimizing condition conditional expressions.
     59$list number$$
     60Using old instead of new operator indices.
     61$lnext
     62Not properly following dependence back through atomic operations.
     63$lnext
     64Aborting during forward order zero, when skipping computation for a variable
     65that was already completed (the skip is still useful for higher orders
     66and for reverse mode).
     67$lend
     68
    5769$head 09-27$$
    5870Fix a bug that occurred when
Note: See TracChangeset for help on using the changeset viewer.