Overview
Comment: | Rationalised local and global optimisations. Fixes presentation of locally optimised code (ode view). Much more elegant :-) |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | origin/global-optimisation | trunk |
Files: | files | file ages | folders |
SHA3-256: |
f9dbeacd23bbd756322a3bc55c562b32 |
User & Date: | geraint@users.sourceforge.net on 2002-09-10 23:24:19 |
Other Links: | branch diff | manifest | tags |
Context
2002-09-12
| ||
18:50:50 | Uncommented cse optimisations - they seem to work ok. check-in: b96c667293 user: geraint@users.sourceforge.net tags: origin/global-optimisation, trunk | |
2002-09-10
| ||
23:24:19 |
Rationalised local and global optimisations. Fixes presentation of locally optimised code (ode view). Much more elegant :-) check-in: f9dbeacd23 user: geraint@users.sourceforge.net tags: origin/global-optimisation, trunk | |
22:09:14 | Fixed presentation of globally optimised equations (ode view). check-in: 39aff6de49 user: geraint@users.sourceforge.net tags: origin/global-optimisation, trunk | |
Changes
Modified mttroot/mtt/bin/trans/cse2ode_r from [70c1f00663] to [5f6e4ff143].
︙ | ︙ | |||
10 11 12 13 14 15 16 17 18 19 20 21 22 23 | # Copyright (c) P.J.Gawthrop, 1991, 1994. ############################################################### ## Version control history ############################################################### ## $Id$ ## $Log$ ## Revision 1.3 2001/07/27 23:29:10 geraint ## Optimises only when requested (-opt). ## ## Revision 1.2 2001/07/13 04:54:04 geraint ## Branch merge: numerical-algebraic-solution back to main. ## ## Revision 1.1.4.1 2001/05/04 04:07:24 geraint | > > > | 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | # Copyright (c) P.J.Gawthrop, 1991, 1994. ############################################################### ## Version control history ############################################################### ## $Id$ ## $Log$ ## Revision 1.3.4.1 2002/09/03 23:44:43 geraint ## adding global optimisation (-optg). ## ## Revision 1.3 2001/07/27 23:29:10 geraint ## Optimises only when requested (-opt). ## ## Revision 1.2 2001/07/13 04:54:04 geraint ## Branch merge: numerical-algebraic-solution back to main. ## ## Revision 1.1.4.1 2001/05/04 04:07:24 geraint |
︙ | ︙ | |||
48 49 50 51 52 53 54 | *) echo "$1 is an invalid argument - ignoring" ;; esac shift done # Create the reduce output code | | | | 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 | *) echo "$1 is an invalid argument - ignoring" ;; esac shift done # Create the reduce output code def2write_r $1 ode def2write_r $1 odeo #Inform user echo Creating $1_ode.r $optimise_msg echo Creating $1_odeo.r $optimise_msg # Remove the old log file rm -f cse2ode_r.log |
︙ | ︙ | |||
132 133 134 135 136 137 138 | in ("$1_odeo_write.r"); write "END;"; SHUT "$1_odeo.r"; quit; EOF if [ ${optimise:-""} = "-optimise_global" ]; then | | | > > > | 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 | in ("$1_odeo_write.r"); write "END;"; SHUT "$1_odeo.r"; quit; EOF if [ ${optimise:-""} = "-optimise_global" ]; then mtt_optimise global $1 ode mtt_optimise global $1 odeo elif [ ${optimise:-""} = "-optimise_local" ]; then mtt_optimise local $1 ode mtt_optimise local $1 odeo fi # Now invoke the standard error handling. mtt_error_r cse2ode_r.log |
Modified mttroot/mtt/bin/trans/csm2sm_r from [9197d41677] to [2241332550].
︙ | ︙ | |||
10 11 12 13 14 15 16 17 18 19 20 21 22 23 | # Copyright (c) P.J.Gawthrop, 1991, 1994, 1996 ############################################################### ## Version control history ############################################################### ## $Id$ ## $Log$ ## Revision 1.2 2001/07/27 23:29:10 geraint ## Optimises only when requested (-opt). ## ## Revision 1.1 2000/12/28 12:24:03 peterg ## Put under RCS ## ## Revision 1.2 1996/08/25 10:11:32 peter | > > > | 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | # Copyright (c) P.J.Gawthrop, 1991, 1994, 1996 ############################################################### ## Version control history ############################################################### ## $Id$ ## $Log$ ## Revision 1.2.4.1 2002/09/03 23:44:43 geraint ## adding global optimisation (-optg). ## ## Revision 1.2 2001/07/27 23:29:10 geraint ## Optimises only when requested (-opt). ## ## Revision 1.1 2000/12/28 12:24:03 peterg ## Put under RCS ## ## Revision 1.2 1996/08/25 10:11:32 peter |
︙ | ︙ | |||
41 42 43 44 45 46 47 | * ) echo "$1 is an invalid argument - ignoring" ;; esac shift done # Create the reduce output code | | | 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | * ) echo "$1 is an invalid argument - ignoring" ;; esac shift done # Create the reduce output code def2write_r $1 $2 # Inform user echo Creating $1_$2.r $optimise_msg case $2 in sm) rep=csm; |
︙ | ︙ | |||
141 142 143 144 145 146 147 | quit; EOF cat $1_$2.r1 $1_$2.r2 > $1_$2.r if [ ${optimise:-""} = "-optimise_global" ]; then | > > | | 144 145 146 147 148 149 150 151 152 153 154 155 156 157 | quit; EOF cat $1_$2.r1 $1_$2.r2 > $1_$2.r if [ ${optimise:-""} = "-optimise_global" ]; then mtt_optimise global $1 $2 elif [ ${optimise:-""} = "-optimise_local" ]; then mtt_optimise local $1 $2 fi # Now invoke the standard error handling. mtt_error_r csm2sm_r.log |
Modified mttroot/mtt/bin/trans/dae2cse_r from [4b9ab23fb1] to [a205b54e0b].
︙ | ︙ | |||
11 12 13 14 15 16 17 18 19 20 21 22 23 24 | # Copyright (c) P.J.Gawthrop 1991, 1992, 1994. ############################################################### ## Version control history ############################################################### ## $Id$ ## $Log$ ## Revision 1.23 2002/07/10 17:43:05 geraint ## Added feature [ 562453 ] Optimisation of algebraic equations. ## ## Revision 1.22 2002/06/28 15:35:47 geraint ## Commented out aej.r generation (not used yet). ## ## Revision 1.21 2002/06/28 10:13:40 geraint | > > > | 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | # Copyright (c) P.J.Gawthrop 1991, 1992, 1994. ############################################################### ## Version control history ############################################################### ## $Id$ ## $Log$ ## Revision 1.23.2.1 2002/09/03 23:44:43 geraint ## adding global optimisation (-optg). ## ## Revision 1.23 2002/07/10 17:43:05 geraint ## Added feature [ 562453 ] Optimisation of algebraic equations. ## ## Revision 1.22 2002/06/28 15:35:47 geraint ## Commented out aej.r generation (not used yet). ## ## Revision 1.21 2002/06/28 10:13:40 geraint |
︙ | ︙ | |||
146 147 148 149 150 151 152 | *) echo "$1 is an invalid argument - ignoring" ;; esac shift done # Create the reduce output code | | | | | | 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 | *) echo "$1 is an invalid argument - ignoring" ;; esac shift done # Create the reduce output code def2write_r $fixcc $1 ae def2write_r $fixcc $1 cse def2write_r $fixcc $1 csex # Version without E matrix def2write_r $fixcc $1 cseo echo "Creating $1_ae.r $optimise_msg" echo "Creating $1_cse.r $solve_msg $optimise_msg $fix_msg" echo "Creating $1_csex.r $optimise_msg" echo "Creating $1_cseo.r $optimise_msg" # Remove the old log file |
︙ | ︙ | |||
476 477 478 479 480 481 482 | touch $1_cseo.r2 cat $1_ae.r1 $1_ae.r2 > $1_ae.r cat $1_cse.r1 $1_cse.r2 > $1_cse.r cat $1_csex.r1 $1_csex.r2 > $1_csex.r cat $1_cseo.r1 $1_cseo.r2 > $1_cseo.r if [ ${optimise:-""} = "-optimise_global" ]; then | > > > > > | | | | | 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 | touch $1_cseo.r2 cat $1_ae.r1 $1_ae.r2 > $1_ae.r cat $1_cse.r1 $1_cse.r2 > $1_cse.r cat $1_csex.r1 $1_csex.r2 > $1_csex.r cat $1_cseo.r1 $1_cseo.r2 > $1_cseo.r if [ ${optimise:-""} = "-optimise_global" ]; then mtt_optimise global $1 ae # TODO: mtt_optimise global $1 cse # TODO: mtt_optimise global $1 cseo # TODO: mtt_optimise global $1 csex elif [ ${optimise:-""} = "-optimise_local" ]; then mtt_optimise local $1 ae # TODO: mtt_optimise local $1 cse # TODO: mtt_optimise local $1 cseo # TODO: mtt_optimise local $1 csex fi if [ "$solve" = "1" ]; then echo "Setting MTTNyz=0 in $1_def.r and updating other $1_def files" gawk '{ if ($1=="MTTNyz") print "MTTNyz := 0;" |
︙ | ︙ |
Modified mttroot/mtt/bin/trans/dae2lde_r from [23baf7d704] to [e4375dbdcc].
︙ | ︙ | |||
9 10 11 12 13 14 15 16 17 18 19 20 21 22 | # Copyright (C) 2000 by Peter J. Gawthrop ############################################################### ## Version control history ############################################################### ## $Id$ ## $Log$ ## Revision 1.2 2001/07/27 23:29:10 geraint ## Optimises only when requested (-opt). ## ## Revision 1.1 2000/12/28 12:25:13 peterg ## Initial revision ## ############################################################### | > > > | 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | # Copyright (C) 2000 by Peter J. Gawthrop ############################################################### ## Version control history ############################################################### ## $Id$ ## $Log$ ## Revision 1.2.4.1 2002/09/03 23:44:43 geraint ## adding global optimisation (-optg). ## ## Revision 1.2 2001/07/27 23:29:10 geraint ## Optimises only when requested (-opt). ## ## Revision 1.1 2000/12/28 12:25:13 peterg ## Initial revision ## ############################################################### |
︙ | ︙ | |||
33 34 35 36 37 38 39 | *) echo "$1 is an invalid argument - ignoring" ;; esac shift done # Create the reduce output code | | | | 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | *) echo "$1 is an invalid argument - ignoring" ;; esac shift done # Create the reduce output code def2write_r $1 lde def2write_r $1 ldeo #Inform user echo Creating $1_lde.r $optimise_msg echo Creating $1_ldeo.r $optimise_msg # Remove the old log file rm -f cse2lde_r.log |
︙ | ︙ | |||
122 123 124 125 126 127 128 | in ("$1_ldeo_write.r"); write "END;"; SHUT "$1_ldeo.r"; quit; EOF if [ ${optimise:-""} = "-optimise_global" ]; then | > > > | | | 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 | in ("$1_ldeo_write.r"); write "END;"; SHUT "$1_ldeo.r"; quit; EOF if [ ${optimise:-""} = "-optimise_global" ]; then # TODO: mtt_optimise global $1 lde # TODO: mtt_optimise global $1 ldeo elif [ ${optimise:-""} = "-optimise_local" ]; then # TODO: mtt_optimise local $1 lde # TODO: mtt_optimise local $1 ldeo fi # Now invoke the standard error handling. mtt_error_r cse2lde_r.log |
Modified mttroot/mtt/bin/trans/def2write_r from [f2349eb5aa] to [3eb9390062].
︙ | ︙ | |||
9 10 11 12 13 14 15 16 17 18 19 20 21 22 | # Copyright (C) 2000 by Peter J. Gawthrop ############################################################### ## Version control history ############################################################### ## $Id$ ## $Log$ ## Revision 1.16.2.1 2002/09/03 23:44:43 geraint ## adding global optimisation (-optg). ## ## Revision 1.16 2002/09/03 19:34:15 geraint ## Write EdX regardless - csex is needed to create ode when not optimised. ## ## Revision 1.15 2002/08/29 15:45:20 geraint | > > > | 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | # Copyright (C) 2000 by Peter J. Gawthrop ############################################################### ## Version control history ############################################################### ## $Id$ ## $Log$ ## Revision 1.16.2.2 2002/09/10 22:09:14 geraint ## Fixed presentation of globally optimised equations (ode view). ## ## Revision 1.16.2.1 2002/09/03 23:44:43 geraint ## adding global optimisation (-optg). ## ## Revision 1.16 2002/09/03 19:34:15 geraint ## Write EdX regardless - csex is needed to create ode when not optimised. ## ## Revision 1.15 2002/08/29 15:45:20 geraint |
︙ | ︙ | |||
78 79 80 81 82 83 84 | ## Initial revision ## ############################################################### optimise='' while [ -n "`echo $1 | grep '^-'`" ]; do case $1 in | < < < < < < | | 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 | ## Initial revision ## ############################################################### optimise='' while [ -n "`echo $1 | grep '^-'`" ]; do case $1 in -fixcc ) include=`echo 'in "'$MTT_LIB'/reduce/fix_c.r";'` ;; *) echo "$1 is an invalid argument - ignoring" ;; esac shift done sys=$1 # System name rep=$2 # System representation # Inform User echo Creating $1_$2_write.r # Find system constants Nx=`mtt_getsize $sys x` # States Nxx=`mtt_getsize $sys xx` # States x States Nu=`mtt_getsize $sys u` # Inputs Ny=`mtt_getsize $sys y` # Outputs Nyz=`mtt_getsize $sys yz` # Zero outputs |
︙ | ︙ | |||
157 158 159 160 161 162 163 164 | ns="$Nx $Nx $Ny $Ny" ms="$Nx $Nu $Nx $Nu" ;; *) echo def2write_r: representation $rep not recognised exit esac | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | | < < < < < < | | | < | | 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 | ns="$Nx $Nx $Ny $Ny" ms="$Nx $Nu $Nx $Nu" ;; *) echo def2write_r: representation $rep not recognised exit esac # Remove log files rm -f def2write_r1.log def2write_r2.log # Write out the code echo "" > $1_$2_write.r echo 'off echo$' >> $1_$2_write.r echo 'load gentran$' >> $1_$2_write.r for matrix in $matrices; do matrix_exists=`grep -i MTT${matrix} ${sys}_dae.r | wc -l | gawk '{print $1}'` if [ "$matrix" = "EdX" -o $matrix_exists -gt 0 ]; then n=`first "$ns"`; ns=`rest "$ns"` m=`first "$ms"`; ms=`rest "$ms"` is=`n2m 1 $n`; js=`n2m 1 $m`; echo "write \"% Begin Matrix MTT${matrix}\"$" >> $1_$2_write.r if [ $n -ge 1 ]; then for i in $is; do for j in $js; do echo 'write' name=`echo MTT$matrix'('$i','$j')'` echo ' '$comma$name ':=' $name '$' done done fi >> $1_$2_write.r echo "write \"% End Matrix MTT${matrix}\"$" >> $1_$2_write.r fi done echo ';END;' >>$1_$2_write.r |
Added mttroot/mtt/bin/trans/mtt_optimise version [c438ecdefe].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 | #! /bin/sh # script uses Reduce + Scope to optimise a vector # either global (an entire vector) or local (line-by-line) extent=$1 # global or local system=$2 representation=$3 # error codes E_REP_NOT_SUPPORTED=-19 E_FILE_NOT_EXIST=-20 case $representation in ae) matrix=yz ; nmatrix=`mtt_getsize $system yz` ;; ode) matrix=dx ; nmatrix=`mtt_getsize $system x` ;; cseo | odeo) matrix=y ; nmatrix=`mtt_getsize $system y` ;; *) exit $E_REP_NOT_SUPPORTED;; esac # Global optimisation: Generate a command of the form # optimise mtt?(1,1) :=: mtt?(1,1), mtt?(2,1) :=: mtt?(2,1), ..., INAME mtt_tmp$ # # Local optimisation: Generate a command of the form # optimise mtt?(1,1) :=: mtt?(1,1) INAME mtt_tmp$ \ # optimise mtt?(2,1) :=: mtt?(2,1) INAME mtt_tmp$ ... case $extent in "global" ) delimiter=", " terminate="INAME mtt_tmp$" ;; "local" ) delimiter=" INAME mtt_tmp$ optimize" terminate="$" ;; * ) echo "*** unknown scope for optimisation" echo "*** should be global or local" exit -1 ;; esac if [ $nmatrix -gt 0 ]; then command="optimize" counter=1 while [ $counter -le $nmatrix ]; do command="$command mtt$matrix($counter,1) :=: mtt$matrix($counter,1)$delimiter" counter=`expr $counter + 1` done command="$command $terminate" else command="" fi logfile=${system}_${representation}_optimisation.log tmpfile=${system}_${representation}_optimisation.tmp outfile=${system}_${representation}.r if [ ! -f $outfile ]; then exit $E_FILE_NOT_EXIST fi find_code () { file_in=${1:-${IN}} portion=${2:-"body"} head=`cat ${file_in} | gawk '($2 == "Begin" && $3 == "Matrix") { print NR }'` foot=`cat ${file_in} | gawk '($2 == "End" && $3 == "Matrix") { print NR }'` case ${portion} in head) start=0 end=${head} ;; body) start=${head} end=${foot} ;; foot) start=${foot} end=end ;; *) echo "Error in find_code: portion unknown" return -1 ;; esac cat ${file_in} |\ gawk --assign start=${start} --assign end=${end} ' (start < NR && NR < end) { print $0 }' }; # Use Reduce to perform the optimisation ${SYMBOLIC:-reduce} <<EOF > $logfile 2>&1 off nat; in "${system}_def.r"; in "$outfile"; load scope; out "$tmpfile"; $command; shut "$tmpfile"; $end; EOF cp $outfile $outfile.unoptimised cp $tmpfile $outfile.tmp find_code $outfile head > $tmpfile.head cat $tmpfile | mtt_fix_integers > $tmpfile.body find_code $outfile foot > $tmpfile.foot cat $tmpfile.head $tmpfile.body $tmpfile.foot > $outfile echo ";end;" >> $outfile mtt_error_r $logfile |
Deleted mttroot/mtt/bin/trans/mtt_optimise_global version [2e6c7a680f].
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |