tlbmiss_cost.sh is the only user of the cpumhz script. Integrate the two
together. If it turns out later multiple scripts need it, we can figure
a way of including helper functions into monolithic scripts at build
time as opposed to littering the install with small helpers.

Signed-off-by: Mel Gorman <m...@csn.ul.ie>
---
 contrib/tlbmiss_cost.sh |   59 +++++++++++++++++++++++++++++++++++++++--------
 cpumhz                  |   48 --------------------------------------
 2 files changed, 49 insertions(+), 58 deletions(-)

diff --git a/contrib/tlbmiss_cost.sh b/contrib/tlbmiss_cost.sh
index 4d54e8d..42d7514 100755
--- a/contrib/tlbmiss_cost.sh
+++ b/contrib/tlbmiss_cost.sh
@@ -21,6 +21,54 @@
 # info  == 2 (default, should remain quiet in practicet)
 # error == 1
 VERBOSE=2
+MHZ=0
+
+cpumhz() {
+       MAX_MHZ=0
+       
SYSFS_SCALING=/sys/devices/system/cpu/cpu0/cpufreq/scaling_available_frequencies
+
+       # Use sysfs if available
+       if [ -e $SYSFS_SCALING ]; then
+               for CURR_MHZ in `cat $SYSFS_SCALING`; do
+                       CURR_MHZ=$(($CURR_MHZ/1000))
+                       if [ $CURR_MHZ -gt $MAX_MHZ ]; then
+                               MAX_MHZ=$CURR_MHZ
+                       fi
+               done
+               MHZ=$MAX_MHZ
+               return
+       fi
+
+       # Otherwise, use /proc/cpuinfo. Guess what field name is needed.
+       # In most cases, it's cpu MHz but there will be exceptions
+       FNAME="cpu MHz"
+       FINDEX=4
+       case "`uname -m`" in
+               ppc64)
+                       FNAME="clock"
+                       FINDEX=3
+                       ;;
+       esac
+
+       # Take a hundred samples in case of CPU frequency scaling artifically
+       # returning a low value. The multiple samples should wake up the CPU
+       for SAMPLE in `seq 1 100`; do
+               for CURR_MHZ in `grep "$FNAME" /proc/cpuinfo | awk "{print 
\\\$$FINDEX}"`; do
+                       CURR_MHZ=${CURR_MHZ/.*}
+                       if [ "$CURR_MHZ" = "" ]; then
+                               echo ERROR: Unable to extract CPU speed from 
/proc
+                               exit -1
+                       fi
+
+                       if [ $CURR_MHZ -gt $MAX_MHZ ]; then
+                               MAX_MHZ=$CURR_MHZ
+                       fi
+               done
+       done
+
+       MHZ=$MAX_MHZ
+       return
+}
 
 # Print help message
 usage() {
@@ -206,16 +254,7 @@ calibrator_calc()
                die "Unable to locate calibrator."
        fi
 
-       CPUMHZ=`which cpumhz 2>/dev/null`
-       if [ "$CPUMHZ" = "" ]; then
-               CPUMHZ="../cpumhz"
-       fi
-
-       if [[ ! -x $CPUMHZ ]]; then
-               die "Unable to locate cpumhz."
-       fi
-
-       MHZ=`$CPUMHZ`
+       cpumhz
        SIZE=$((13*1048576))
        STRIDE=3932160
        PREFIX=tlbmiss-cost-results
diff --git a/cpumhz b/cpumhz
deleted file mode 100755
index da84543..0000000
--- a/cpumhz
+++ /dev/null
@@ -1,48 +0,0 @@
-#!/bin/bash
-# Simple script to print out the max MHz
-# Licensed under LGPL 2.1 as packaged with libhugetlbfs
-# (c) Mel Gorman 2009
-
-MAX_MHZ=0
-SYSFS_SCALING=/sys/devices/system/cpu/cpu0/cpufreq/scaling_available_frequencies
-
-# Use sysfs if available
-if [ -e $SYSFS_SCALING ]; then
-       for CURR_MHZ in `cat $SYSFS_SCALING`; do
-               CURR_MHZ=$(($CURR_MHZ/1000))
-               if [ $CURR_MHZ -gt $MAX_MHZ ]; then
-                       MAX_MHZ=$CURR_MHZ
-               fi
-       done
-       echo $MAX_MHZ
-       exit 0
-fi
-
-# Otherwise, use /proc/cpuinfo. Guess what field name is needed. In most cases,
-# it's cpu MHz but there will be exceptions
-FNAME="cpu MHz"
-FINDEX=4
-case "`uname -m`" in
-       ppc64)
-               FNAME="clock"
-               FINDEX=3
-               ;;
-esac
-
-# Take a hundred samples in case of CPU frequency scaling artifically returning
-# a low value. The multiple samples should wake up the CPU
-for SAMPLE in `seq 1 100`; do
-       for CURR_MHZ in `grep "$FNAME" /proc/cpuinfo | awk "{print 
\\\$$FINDEX}"`; do
-               CURR_MHZ=${CURR_MHZ/.*}
-               if [ "$CURR_MHZ" = "" ]; then
-                       echo ERROR: Unable to extract CPU speed from /proc
-                       exit -1
-               fi
-
-               if [ $CURR_MHZ -gt $MAX_MHZ ]; then
-                       MAX_MHZ=$CURR_MHZ
-               fi
-       done
-done
-echo $MAX_MHZ
-exit 0

------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Libhugetlbfs-devel mailing list
Libhugetlbfs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libhugetlbfs-devel

Reply via email to