STREAM has a separate license that must be accepted by the user which is why the tool requires that it be downloaded. This patch provides the option of the tool being automatically downloaded and built for the user. As part of that, the software license is displayed so it can be optionally accepted or rejected. The patch also renames the stream binary to STREAM as "stream" is an unrelated binary packaged with ImageMagick that might be commonly installed.
Signed-off-by: Mel Gorman <m...@csn.ul.ie> --- tlbmiss_cost.sh | 76 +++++++++++++++++++++++++++++++++++++++++++++++++----- 1 files changed, 69 insertions(+), 7 deletions(-) diff --git a/tlbmiss_cost.sh b/tlbmiss_cost.sh index dbdd023..3bb5532 100755 --- a/tlbmiss_cost.sh +++ b/tlbmiss_cost.sh @@ -186,17 +186,64 @@ calibrator_calc() # This method uses the stream memory benchmark which can be found here: # http://www.cs.virginia.edu/stream/FTP/Code/stream.c # and should be compiled with this command line: -# gcc -O3 -DN=44739240 stream.c -o stream +# gcc -O3 -DN=44739240 stream.c -o STREAM # and then placed in the same directory as this script +stream_fetch() +{ + # STREAM binary is in caps as there is a commonly-available binary + # called stream that is packaged with ImageMagick. This avoids some + # confusion + if [ "`which STREAM`" != "" -o -e ./STREAM ]; then + echo STREAM is already in path or in current directory + return + fi + + TMPFILE=`mktemp`.c + if [ "$TMPFILE" = "" ]; then + die Failed to create tmpfile + fi + trap "rm $TMPFILE; exit" INT + + WGET=`which wget 2> /dev/null` + if [ "$WGET" = "" ]; then + rm $TMPFILE + die wget is not installed, cannot fetch stream.c + fi + + wget http://www.cs.virginia.edu/stream/FTP/Code/stream.c -O $TMPFILE || die Failed to download stream.c + + LICENSE_END=`grep -n "^/\*--" $TMPFILE | tail -1 | cut -f1 -d:` + echo Displaying STREAM license + head -$LICENSE_END $TMPFILE + echo + echo STREAM is an external tool used by tlbmiss_cost.sh. The license + echo for this software is displayed above. Are you willing to accept the + echo -n "terms of this license [Y/N]? " + read INPUT + + if [ "$INPUT" != "Y" -a "$INPUT" != "y" ]; then + rm $TMPFILE + echo Bailing... + return + fi + echo Building... + gcc -O3 -w -DN=44739240 $TMPFILE -o STREAM || die Failed to compile STREAM + echo STREAM is available at ./stream. For future use, run tlbmiss_cost.sh + echo from current directory or copy STREAM into your PATH + echo + + rm $TMPFILE +} + oprofile_calc() { if [ "$STREAM" = "" ]; then - STREAM="./stream" + STREAM="./STREAM" fi if [[ ! -x $STREAM ]]; then - die "Unable to locate stream." + die "Unable to locate STREAM." fi OPST=`which oprofile_start.sh` @@ -208,26 +255,36 @@ oprofile_calc() die "Unable to locate oprofile_start.sh." fi + print_trace Beginning TLB measurement using STREAM and oprofile + + # First we run without hugepages to get a baseline + print_trace Starting oprofile_start --event dtlb_miss --event tablewalk_cycles $OPST --event dtlb_miss --event tablewalk_cycles >/dev/null 2>&1 if [ "$?" -ne "0" ]; then die "Error starting oprofile, check oprofile_map_event.pl for appropriate dtlb_miss and tablewalk_cycles events." fi + + print_trace Gathering baseline of STREAM performance $STREAM >/dev/null 2>&1 + + print_trace Stopping profile opcontrol --stop >/dev/null 2>&1 opcontrol --dump >/dev/null 2>&1 + + print_trace Dumping profile RESULTS=`opreport | grep "_MISS_" | head -1` MISS_SCALE=`echo $RESULTS | sed 's/.* count \([0-9]*\).*/\1/'` RESULTS=`opreport | grep "_TABLEWALK_" | head -1` WALK_SCALE=`echo $RESULTS | sed 's/.* count \([0-9]*\).*/\1/'` - RESULTS=`opreport | grep " stream" | head -1` + RESULTS=`opreport | grep " STREAM" | head -1` + # This grabs the first whole number on the line which will be the # number of table walk cycles, the second will be TLB misses + print_trace Analysing profile TABLE_WALK=`echo "$RESULTS" | sed 's/[[:space:]]*\([0-9]*\).*/\1/'` TLB_MISS=`echo "$RESULTS" | sed 's/[[:space:]]*[0-9]*[[:space:]]*[[:graph:]]*[[:space:]]*\([0-9]*\).*/\1/'` RESULTS=`opreport | grep " vmlinux" | head -1` - opcontrol --shutdown >/dev/null 2>&1 - opcontrol --deinit >/dev/null 2>&1 KERN_TABLE_WALK=`echo "$RESULTS" | sed 's/[[:space:]]*\([0-9]*\).*/\1/'` KERN_TLB_MISS=`echo "$RESULTS" | sed 's/[[:space:]]*[0-9]*[[:space:]]*[[:graph:]]*[[:space:]]*\([0-9]*\).*/\1/'` if [[ "$KERN_TLB_MISS" != "" ]]; then @@ -237,13 +294,17 @@ oprofile_calc() TABLE_WALK=$(($TABLE_WALK+$KERN_TABLE_WALK)) fi + print_trace Shutting down oprofile + opcontrol --shutdown >/dev/null 2>&1 + opcontrol --deinit >/dev/null 2>&1 + TLB_MISS=$(($TLB_MISS*$MISS_SCALE)) TABLE_WALK=$(($TABLE_WALK*$WALK_SCALE)) LAST_LATENCY_CYCLES=$(($TABLE_WALK/$TLB_MISS)) } -ARGS=`getopt -o c:s:vq --long calibrator:,stream:,verbose,quiet,fetch-calibrator -n 'tlbmiss_cost.sh' -- "$@"` +ARGS=`getopt -o c:s:vq --long calibrator:,stream:,verbose,quiet,fetch-calibrator,fetch-stream -n 'tlbmiss_cost.sh' -- "$@"` eval set -- "$ARGS" @@ -254,6 +315,7 @@ while true ; do -v|--verbose) VERBOSE=$(($VERBOSE+1)); shift;; -q|--quiet) VERBOSE=$(($VERBOSE-1)); shift;; --fetch-calibrator) calibrator_fetch; shift;; + --fetch-stream) stream_fetch; shift;; "") shift ; break ;; "--") shift ; break ;; *) die "Unrecognized option $1" ;; -- 1.6.3.3 ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ Libhugetlbfs-devel mailing list Libhugetlbfs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/libhugetlbfs-devel