Changeset 1627


Ignore:
Timestamp:
Jan 19, 2010 7:44:18 AM (10 years ago)
Author:
bradbell
Message:

trunk: Create an extendable driver for the ipopt_cppad speed tests.

speed.cpp: new driver for ipopt_cppad speed tests.
*/makefile.in: update version for corresponding makefile.am
ode_speed.cpp: change from main program to a subroutine; improve time function.
makefile.am: add driver to makefile.
configure.hpp: update version of CppAD.
check_svn_dist.sh: fix bug in check of ipopt_cppad/speed/speed execution.

Location:
trunk
Files:
1 added
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/check_svn_dist.sh

    r1626 r1627  
    11#! /bin/bash
    22#
    3 program="check_svn_dist.sh"
     3script="check_svn_dist.sh"
    44repository="https://projects.coin-or.org/svn/CppAD"
    55branch=`pwd | sed -e 's|.*/CppAD/||'`
     
    1010        if ! rm -rf svn_dist
    1111        then
    12                 echo "$program: cannot remove old svn_dist directory"
     12                echo "$script: cannot remove old svn_dist directory"
    1313                exit 1
    1414        fi
     
    2121if ! cd svn_dist
    2222then
    23         echo "$program: cannot change into svn_dist directory"
     23        echo "$script: cannot change into svn_dist directory"
    2424        exit 1
    2525fi
     
    2828if ! ./build.sh config_test
    2929then
    30         echo "$program: error durring ./build.sh config_test in ./svn_dist"
     30        echo "$script: error durring ./build.sh config_test in ./svn_dist"
    3131        exit 1
    3232fi
     
    3535for name in example test_more ipopt_cppad/example ipopt_cppad/speed
    3636do
    37         echo "cd $name"
    38         if ! cd $name
     37        echo "cd $dir/$name"
     38        if ! cd $dir/$name
    3939        then
    40                 echo "$program: cannot change into $dir/$name directory"
     40                echo "$script: cannot change into $dir/$name directory"
    4141                exit 1
    4242        fi
     
    4444        if ! make
    4545        then
    46                 echo "$program: $dir/$name/make failed"
     46                echo "$script: $dir/$name/make failed"
    4747                exit 1
    4848        fi
    49         echo "./$name"
    50         if ! ./$name
     49        program=`echo $name | sed -e 's|.*/||'`
     50        echo "./$program"
     51        if ! ./$program
    5152        then
    52                 echo "$program: $dir/$name/$name failed"
     53                echo "$script: $dir/$name/$program failed"
    5354                exit 1
    5455        fi
    55         echo "cd .."
    56         cd ..
     56        echo "cd $dir"
     57        cd $dir
    5758done
  • trunk/ipopt_cppad/example/makefile.in

    r1626 r1627  
    8989CYGPATH_W = @CYGPATH_W@
    9090
    91 # $Id: makefile.am -1  $
     91# $Id: makefile.am 1626 2010-01-18 19:27:35Z bradbell $
    9292# -----------------------------------------------------------------------------
    93 # CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-09 Bradley M. Bell
     93# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-10 Bradley M. Bell
    9494#
    9595# CppAD is distributed under multiple licenses. This distribution is under
  • trunk/ipopt_cppad/speed/makefile.am

    r1626 r1627  
    2121endif
    2222#
    23 noinst_PROGRAMS   = ode_speed
     23noinst_PROGRAMS   = speed
    2424#
    2525AM_CXXFLAGS       = -O2 -DNDEBUG $(CXX_FLAGS)
     
    3333AM_LDFLAGS        = -L$(IPOPT_DIR)/lib
    3434#
    35 ode_speed_SOURCES   = \
     35speed_SOURCES   = \
     36        speed.cpp \
    3637        ode_speed.cpp \
    3738        ../src/ipopt_cppad_nlp.cpp \
  • trunk/ipopt_cppad/speed/makefile.in

    r1626 r1627  
    3333PRE_UNINSTALL = :
    3434POST_UNINSTALL = :
    35 noinst_PROGRAMS = ode_speed$(EXEEXT)
     35noinst_PROGRAMS = speed$(EXEEXT)
    3636subdir = ipopt_cppad/speed
    3737DIST_COMMON = $(srcdir)/makefile.am $(srcdir)/makefile.in
     
    4545CONFIG_CLEAN_VPATH_FILES =
    4646PROGRAMS = $(noinst_PROGRAMS)
    47 am_ode_speed_OBJECTS = ode_speed.$(OBJEXT) ipopt_cppad_nlp.$(OBJEXT)
    48 ode_speed_OBJECTS = $(am_ode_speed_OBJECTS)
    49 ode_speed_LDADD = $(LDADD)
     47am_speed_OBJECTS = speed.$(OBJEXT) ode_speed.$(OBJEXT) \
     48        ipopt_cppad_nlp.$(OBJEXT)
     49speed_OBJECTS = $(am_speed_OBJECTS)
     50speed_LDADD = $(LDADD)
    5051am__DEPENDENCIES_1 =
    51 ode_speed_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
     52speed_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
    5253        $(am__DEPENDENCIES_1)
    5354DEFAULT_INCLUDES =
     
    6465CCLD = $(CC)
    6566LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
    66 SOURCES = $(ode_speed_SOURCES)
    67 DIST_SOURCES = $(ode_speed_SOURCES)
     67SOURCES = $(speed_SOURCES)
     68DIST_SOURCES = $(speed_SOURCES)
    6869ETAGS = etags
    6970CTAGS = ctags
     
    8889CYGPATH_W = @CYGPATH_W@
    8990
    90 # $Id: makefile.am -1  $
     91# $Id: makefile.am 1626 2010-01-18 19:27:35Z bradbell $
    9192# -----------------------------------------------------------------------------
    92 # CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-09 Bradley M. Bell
     93# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-10 Bradley M. Bell
    9394#
    9495# CppAD is distributed under multiple licenses. This distribution is under
     
    201202AM_LDFLAGS = -L$(IPOPT_DIR)/lib
    202203#
    203 ode_speed_SOURCES = \
     204speed_SOURCES = \
     205        speed.cpp \
    204206        ode_speed.cpp \
    205207        ../src/ipopt_cppad_nlp.cpp \
     
    246248clean-noinstPROGRAMS:
    247249        -test -z "$(noinst_PROGRAMS)" || rm -f $(noinst_PROGRAMS)
    248 ode_speed$(EXEEXT): $(ode_speed_OBJECTS) $(ode_speed_DEPENDENCIES)
    249         @rm -f ode_speed$(EXEEXT)
    250         $(CXXLINK) $(ode_speed_OBJECTS) $(ode_speed_LDADD) $(LIBS)
     250speed$(EXEEXT): $(speed_OBJECTS) $(speed_DEPENDENCIES)
     251        @rm -f speed$(EXEEXT)
     252        $(CXXLINK) $(speed_OBJECTS) $(speed_LDADD) $(LIBS)
    251253
    252254mostlyclean-compile:
     
    258260@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ipopt_cppad_nlp.Po@am__quote@
    259261@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ode_speed.Po@am__quote@
     262@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/speed.Po@am__quote@
    260263
    261264.cpp.o:
  • trunk/ipopt_cppad/speed/ode_speed.cpp

    r1626 r1627  
    2323
    2424// BEGIN PROGRAM
    25 // system include files used for I/O
    26 # include <iostream>
    2725# include "../example/ode_run.hpp"
     26# include <cassert>
    2827
     28# if CPPAD_GETTIMEOFDAY & CPPAD_NO_MICROSOFT
     29# include <sys/time.h>
     30# else
     31# include <ctime>
     32# endif
    2933
    3034namespace {
    3135        double current_second(void)
    32         {       return (double) clock() / (double) CLOCKS_PER_SEC;
    33         }
    34         void output(
    35                 bool        simple          ,
    36                 size_t      retape          ,
    37                 double      s0              ,
    38                 double      s1              )
    39         {       using std::cout;
    40                 if( simple )
    41                         cout << "representation simple";
    42                 else    cout << "representation fast  ";
    43                 if( retape )
    44                         cout << " retape yes,";
    45                 else    cout << " retape no, ";
    46                 cout << " seconds = " << s1 - s0;
    47                 cout << std::endl;
     36        {
     37# if CPPAD_GETTIMEOFDAY & CPPAD_NOT_MICOROSOFT
     38                struct timeval value;
     39                gettimeofday(&value, 0);
     40                return double(value.tv_sec) + double(value.tv_usec) * 1e-6;
     41# else
     42                return (double) clock() / (double) CLOCKS_PER_SEC;
     43# endif
    4844        }
    4945}
    5046
     47double ode_speed(const std::string& name)
     48{
     49        // determine simple and retape flags
     50        bool simple = true, retape = true;
     51        if( name == "simple_retape_no" )
     52        {       simple = true; retape = false; }
     53        else if( name == "simple_retape_yes" )
     54        {       simple = true; retape = true; }
     55        else if( name == "fast_retape_no" )
     56        {       simple = false; retape = false; }
     57        else if( name == "fast_retape_yes" )
     58        {       simple = false; retape = true; }
     59        else    assert(false);
    5160
    52 int main(void)
    53 {       bool simple, retape;
    5461        size_t i;
    5562        double s0, s1;
     
    5966
    6067        // number of time grid intervals between measurement values
    61         size_t n = 0;
    6268        SizeVector N(Nz + 1);
    6369        N[0] = 0;
    6470        for(i = 1; i <= Nz; i++)
    6571        {       N[i] = 7;
    66                 n   += N[i] * Ny;
     72                // n   += N[i] * Ny;
    6773        }
    68         n += Na;
    69         std::cout << "ipopt_ode: number of variables = " << n << std::endl;
     74        // n += Na;
    7075
    7176        s0              = current_second();
    72         simple          = false;
    73         retape          = false;
    74         ipopt_ode_case<FG_fast>(retape, N, x);
     77        if( simple )
     78                ipopt_ode_case<FG_simple>(retape, N, x);
     79        else    ipopt_ode_case<FG_fast>(retape, N, x);
    7580        s1              = current_second();
    76         output(simple, retape, s0, s1);
    77 
    78         s0              = current_second();
    79         simple          = false;
    80         retape          = true;
    81         ipopt_ode_case<FG_fast>(retape, N, x);
    82         s1              = current_second();
    83         output(simple, retape, s0, s1);
    84 
    85         s0              = current_second();
    86         simple          = true;
    87         retape          = false;
    88         ipopt_ode_case<FG_simple>(retape, N, x);
    89         s1              = current_second();
    90         output(simple, retape, s0, s1);
    91 
    92         s0              = current_second();
    93         simple          = true;
    94         retape          = true;
    95         ipopt_ode_case<FG_simple>(retape, N, x);
    96         s1              = current_second();
    97         output(simple, retape, s0, s1);
    98  
    99  
    100  
    101         return 0;
     81        return s1 - s0;
    10282}
    10383// END PROGRAM
  • trunk/makefile.in

    r1626 r1627  
    236236@CppAD_POSTFIX_FALSE@postfix_dir = .
    237237
    238 # $Id: makefile.am 1612 2009-12-22 13:51:29Z bradbell $
     238# $Id: makefile.am 1626 2010-01-18 19:27:35Z bradbell $
    239239# -----------------------------------------------------------------------------
    240 # CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-09 Bradley M. Bell
     240# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-10 Bradley M. Bell
    241241#
    242242# CppAD is distributed under multiple licenses. This distribution is under
  • trunk/test_more/makefile.in

    r1626 r1627  
    130130CYGPATH_W = @CYGPATH_W@
    131131
    132 # $Id: makefile.am 1611 2009-12-20 15:50:31Z bradbell $
     132# $Id: makefile.am 1626 2010-01-18 19:27:35Z bradbell $
    133133# -----------------------------------------------------------------------------
    134 # CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-09 Bradley M. Bell
     134# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-10 Bradley M. Bell
    135135#
    136136# CppAD is distributed under multiple licenses. This distribution is under
Note: See TracChangeset for help on using the changeset viewer.