michael@0: #!/bin/sh michael@0: michael@0: # Simple timing test for the MPI library. Basically, we use prime michael@0: # generation as a timing test, since it exercises most of the pathways michael@0: # of the library fairly heavily. The 'primegen' tool outputs a line michael@0: # summarizing timing results. We gather these and process them for michael@0: # statistical information, which is collected into a file. michael@0: michael@0: # This Source Code Form is subject to the terms of the Mozilla Public michael@0: # License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: # file, You can obtain one at http://mozilla.org/MPL/2.0/. michael@0: michael@0: # Avoid using built-in shell echoes michael@0: ECHO=/bin/echo michael@0: MAKE=gmake michael@0: PERL=perl michael@0: michael@0: # Use a fixed seed so timings will be more consistent michael@0: # This one is the 11th-18th decimal digits of 'e' michael@0: #export SEED=45904523 michael@0: SEED=45904523; export SEED michael@0: michael@0: #------------------------------------------------------------------------ michael@0: michael@0: $ECHO "\n** Running timing tests for MPI library\n" michael@0: michael@0: $ECHO "Bringing 'metime' up to date ... " michael@0: if $MAKE metime ; then michael@0: : michael@0: else michael@0: $ECHO "\nMake failed to build metime.\n" michael@0: exit 1 michael@0: fi michael@0: michael@0: if [ ! -x ./metime ] ; then michael@0: $ECHO "\nCannot find 'metime' program, testing cannot continue.\n" michael@0: exit 1 michael@0: fi michael@0: michael@0: #------------------------------------------------------------------------ michael@0: michael@0: $ECHO "Bringing 'primegen' up to date ... " michael@0: if $MAKE primegen ; then michael@0: : michael@0: else michael@0: $ECHO "\nMake failed to build primegen.\n" michael@0: exit 1 michael@0: fi michael@0: michael@0: if [ ! -x ./primegen ] ; then michael@0: $ECHO "\nCannot find 'primegen' program, testing cannot continue.\n" michael@0: exit 1 michael@0: fi michael@0: michael@0: #------------------------------------------------------------------------ michael@0: michael@0: rm -f timing-results.txt michael@0: touch timing-results.txt michael@0: michael@0: sizes="256 512 1024 2048" michael@0: ntests=10 michael@0: michael@0: trap 'echo "oop!";rm -f tt*.tmp timing-results.txt;exit 0' INT HUP michael@0: michael@0: $ECHO "\n-- Modular exponentiation\n" michael@0: $ECHO "Modular exponentiation:" >> timing-results.txt michael@0: michael@0: $ECHO "Running $ntests modular exponentiations per test:" michael@0: for size in $sizes ; do michael@0: $ECHO "- Gathering statistics for $size bits ... " michael@0: secs=`./metime $ntests $size | tail -1 | awk '{print $2}'` michael@0: $ECHO "$size: " $secs " seconds per op" >> timing-results.txt michael@0: tail -1 timing-results.txt michael@0: done michael@0: michael@0: $ECHO ""; michael@0: michael@0: sizes="256 512 1024" michael@0: ntests=1 michael@0: michael@0: $ECHO "\n-- Prime generation\n" michael@0: $ECHO "Prime generation:" >> timing-results.txt michael@0: michael@0: $ECHO "Generating $ntests prime values per test:" michael@0: for size in $sizes ; do michael@0: $ECHO "- Gathering statistics for $size bits ... " michael@0: ./primegen $size $ntests | grep ticks | awk '{print $7}' | tr -d '(' > tt$$.tmp michael@0: $ECHO "$size:" >> timing-results.txt michael@0: $PERL stats tt$$.tmp >> timing-results.txt michael@0: tail -1 timing-results.txt michael@0: rm -f tt$$.tmp michael@0: done michael@0: michael@0: $ECHO "" michael@0: michael@0: trap 'rm -f tt*.tmp timing-results.txt' INT HUP michael@0: michael@0: exit 0 michael@0: