[svn] / ecrypt / trunk / scripts / run  

svn: ecrypt/trunk/scripts/run

Diff for /ecrypt/trunk/scripts/run between version 50 and 61

version 50, Thu Aug 4 20:12:18 2005 UTC version 61, Mon Aug 15 21:50:35 2005 UTC
Line 1 
Line 1 
 #!/bin/sh  #!/bin/sh
   
   [ -z "$BASH_VERSION" ] && (which bash > /dev/null 2>&1) && exec bash $0;
   
   # -----------------------------------------------------------------------------
   
   root=$(cd $(dirname $(which "$0"))/.. && pwd);
   
   . $root/scripts/tools.sh;
   
   # -----------------------------------------------------------------------------
   
   dir=$1;
   
   [ -n "$dir" ] || dir=.;
   
 vectors=unverified.test-vectors;  vectors=unverified.test-vectors;
   cpu_speed=$(tail -n 1 "$root/config/cpuinfo");
   
 mk ()  if [ -r "/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq" ]; then
 {      status 1 "warming up CPU";
     make comp="$comp" opt="$opt" arch="$arch" var="$var" $1;  
 }  
   
 run ()      i=0;
 {      while [ $i -lt 10000 ]; do ((i++));
     if [ -e ./reports/info_$id ]; then          curr_speed=$(awk '/^cpu MHz/ { print $4; exit; }' /proc/cpuinfo);
         echo "info_$id exists. continuing";  
         return;  
     fi  
   
     if [ -e ./reports/errors_$id ]; then          [ $((${cpu_speed%.*} - ${curr_speed%.*})) -gt 10 ] \
         echo "errors_$id exists. continuing";              || break;
         return;      done
     fi  
   
     if [ -e ./reports/speed_$id ]; then      status 1;
         echo "speed_$id exists. continuing";  
         return;  
     fi      fi
   
     echo "compiling $id";  # -----------------------------------------------------------------------------
   
   run ()
   {
       conf=$1;
       name=$(make name);
   
       status 1 "compiling $name under $conf";
   
     make comp="$comp" clean &> /dev/null;      make conf="$conf" clean &> /dev/null;
   
     cat > ./reports/info_current <<EOF      cat > ./reports/info_current <<EOF
 DATE:  DATE:
Line 35 
Line 49 
   
 CPU:  CPU:
 -------------------------------------------------------------------------------  -------------------------------------------------------------------------------
 $(cat /proc/cpuinfo)  $(head -n -1 "$root/config/cpuinfo")
   
 COMPILER:  COMPILER:
 -------------------------------------------------------------------------------  -------------------------------------------------------------------------------
 $(mk version 2>&1)  $(make conf="$conf" version 2>&1)
   
 COMPILATION:  COMPILATION:
 -------------------------------------------------------------------------------  -------------------------------------------------------------------------------
 make comp="$comp" opt="$opt" arch="$arch" var="$var"  make conf="$conf"
   
 $(mk 2>&1)  $(make conf="$conf" 2>&1)
   
 EXECUTABLE:  EXECUTABLE:
 -------------------------------------------------------------------------------  -------------------------------------------------------------------------------
 EOF  EOF
   
     if mk -q &> /dev/null; then      status 1;
         hash=$(mk hash 2> /dev/null);  
       if make conf="$conf" -q &> /dev/null; then
           hash=$(make conf="$conf" hash 2> /dev/null);
     else      else
         echo "none" >> ./reports/info_current;          echo "none" >> ./reports/info_current;
         mv ./reports/info_current ./reports/errors_$id;          mv ./reports/info_current ./reports/errors_$conf;
         echo "compilation failed (see ./reports/errors_$id)";          error 0 "compilation failed (see ./reports/errors_$conf).";
   
         return;          return;
     fi      fi
   
     matches=$(cd ./reports; grep -l "$hash" {info,speed}_*-*-* 2> /dev/null);      status 1 "checking for duplicates";
   
       matches=$(cd ./reports; grep -l "$hash" {info,speed}_*_* 2> /dev/null);
   
       status 1;
   
     echo "$hash" >> ./reports/info_current;      echo "$hash" >> ./reports/info_current;
   
     if [ -n "$matches" ]; then      if [ -n "$matches" ]; then
         echo "executable has been checked before (see $(echo $matches))";          info 1 "executable has been checked before (see $(echo $matches))";
         mv ./reports/info_current ./reports/info_$id;          mv ./reports/info_current ./reports/info_$conf;
   
         return;          return;
     fi      fi
   
     test=$(mk command);      test=$(make conf="$conf" command);
   
       status 1 "generating test vectors";
   
       error=$($test -v -q > ./reports/vectors_$conf 2> /dev/null; echo "$?");
   
     echo "generating test vectors";      status 1;
   
     $test -v | grep -v "Elapsed time\|There were" > ./reports/vectors_$id;      if [ "$error" -gt "1" ]; then
           mv ./reports/vectors_$conf ./reports/errors_$conf;
           error 0 "execution failed.";
   
     if diff -waq ./reports/vectors_$id $vectors > /dev/null; then          return;
         echo "vectors match. deleting vectors_$id";      fi
         rm -f ./reports/vectors_$id;  
       status 1 "verifying test vectors";
   
       if diff -waq ./reports/vectors_$conf $vectors > /dev/null; then
           status 1;
           rm -f ./reports/vectors_$conf;
     else      else
         if diff -wad ./reports/vectors_$id $vectors \          if diff -wad ./reports/vectors_$conf $vectors \
             | grep '<' > /dev/null; then              | grep '<' > /dev/null; then
             echo "error: vectors do not match. check ./reports/vectors_$id";              status 1;
             mv ./reports/info_current ./reports/info_$id;              mv ./reports/info_current ./reports/info_$conf;
               error 0 "vectors do not match. check ./reports/vectors_$conf.";
   
             return;              return;
         else          else
             echo "warning: vectors are incomplete but match";              status 1;
             rm -f ./reports/vectors_$id;              warning 1 "vectors are incomplete but match.";
               rm -f ./reports/vectors_$conf;
         fi          fi
     fi      fi
   
     while true; do      status 1 "running speed measurements on $cpu_speed MHz CPU";
         cpu_speed=$(awk '/cpu MHz/ { print $4; exit; }' /proc/cpuinfo);  
   
         echo "running speed measurements on $cpu_speed MHz CPU";      cat > ./reports/speed_$conf <<EOF
   $($test -c $cpu_speed -s -k -p 2> /dev/null)
         cat > ./reports/speed_$id <<EOF  
 $($test -c $cpu_speed -s -k -p)  
   
 *******************************************************************************  *******************************************************************************
   
 $(cat ./reports/info_current)  $(cat ./reports/info_current)
 EOF  EOF
   
         current_speed=$(awk '/cpu MHz/ { print $4; exit; }' /proc/cpuinfo);      status 1;
   
         if [ "$cpu_speed" = "$current_speed" ]; then      make conf="$conf" clean &> /dev/null;
             break;  
         else      cycles=$(awk '{ sub(/\r/, ""); } /cycles\/byte/ { print $4; exit; }' \
             echo "warning: CPU speed changed. restarting";          ./reports/speed_$conf);
         fi  
     done      info 1 "Current compilation of $name encrypts at $cycles cycles/byte."
   
     rm -f ./reports/info_current      rm -f ./reports/info_current
 }  }
   
 dir=$1;  # -----------------------------------------------------------------------------
   
 if [ -z "$dir" ]; then  
     dir=.;  
 fi  
   
 echo "entering directory $dir";  process_dir ()
   {
       dir=$1;
       conf=$2;
   
 # first recursively process all subdirectories      info 1 "Entering directory $dir";
   
 for i in "$dir"/*; do      for subdir in "$dir"/*; do
     if [ -d "$i" ]; then          if [ -d "$subdir" -a "$(basename $subdir)" != "reports" ]; then
         $0 "$i";              (process_dir "$subdir" "$conf");
     fi      fi
 done  done
   
 cd "$dir";  cd "$dir";
   
 if [ ! -e unverified.test-vectors ]; then      [ -e $vectors ] || return 1;
     exit;  
 fi  
   
 mkdir -p reports;  mkdir -p reports;
   
 if true; then      errors=$(ls ./reports/{errors,vectors}_${conf%%_*}* 2> /dev/null | wc -l);
     comp=gcc;  
   
     for cpu in \  
         i386 i486 i586 pentium-mmx i686 pentium2 pentium3 \  
         pentium-m pentium4 prescott nocona \  
         k6 k6-2 athlon athlon-4 k8; do  
       arch="-march=$cpu"; opt=; var=;  
   
       if mk check &> /dev/null; then  
           for level in 0 1 2 3 s; do  
               opt="-fomit-frame-pointer -O$level"; var=;  
   
               if mk check &> /dev/null; then  
                   for variant in 1 2 3 4 5 6 7 8 9 10; do  
                       var="$variant";  
   
                       if mk check &> /dev/null; then  
                           id="$comp-$variant-$level-$cpu";  
                           run;  
                       fi  
                   done  
               fi  
           done  
       fi  
     done  
   
     mk clean;  
 fi  
   
 if true; then  
     comp=icc;  
   
     for cpu in K W N P B; do  
         arch="-x$cpu"; opt=; var=;  
   
         if mk check &> /dev/null; then      if [ "$errors" -ge "5" ]; then
             for level in 0 1 2 3 s; do          error 0 "This implementation seems to be buggy. Please fix it first.";
                 opt="-O$level"; var=;          return;
   
                 if mk check &> /dev/null; then  
                     for variant in 1 2 3 4 5 6 7 8 9 10; do  
                         var="$variant";  
   
                         if mk check &> /dev/null; then  
                             id="$comp-$variant-$level-$cpu";  
                             run;  
                         fi  
                     done  
                 fi  
             done  
         fi  
     done  
   
     mk clean;  
 fi  fi
   
 if true; then      ls ./reports/*_$conf &> /dev/null || run $conf;
     comp=msvc;  }
   
     for cpu in 3 4 5 6 7 B; do  
         arch="/G$cpu"; opt=; var=;  
   
         if mk check &> /dev/null; then  # -----------------------------------------------------------------------------
             for variant in 1 2 3 4 5 6 7 8 9 10; do  
                 var="$variant"; opt=;  
   
                 if mk check &> /dev/null; then  for conf in $(cd "$root/config/configs"; ls *.mk); do
                     opt="/Ox";      tag=$(awk '/tag = / { print $3; exit; }' "$root/config/configs/$conf");
       score=$(awk '/'$tag'/ { print $1; exit; }' "$root/config/shortlist");
   
                     if mk check &> /dev/null; then      echo $((score + 0)) ${conf%.mk};
                         id="$comp-$variant-x-$cpu";  done | sort -rn | while read score conf; do
                         run;      info 1 "Testing $conf configuration (score: $score).";
                     fi  
   
                     opt="/Ox /Gr";      process_dir "$dir" $conf;
   
                     if mk check &> /dev/null; then  
                         id="$comp-$variant-xr-$cpu";  
                         run;  
                     fi  
                 fi  
             done  
         fi  
     done      done
   
     make comp="$comp" clean;  # -----------------------------------------------------------------------------
 fi  


Generate output suitable for use with a patch program
Legend:
Removed from v.50  
changed lines
  Added in v.61

eSTREAM Project

Powered by ViewCVS 1.0-dev
(Powered by Apache)

ViewCVS and CVS Help