Skip to content

Commit

Permalink
Fix use of zlib in pgo; make it possible to supply an external traini…
Browse files Browse the repository at this point in the history
…ng script
  • Loading branch information
mattgodbolt committed Apr 4, 2016
1 parent 2fed84e commit b2109fc
Showing 1 changed file with 23 additions and 14 deletions.
37 changes: 23 additions & 14 deletions scripts/pgo.sh
Expand Up @@ -6,13 +6,15 @@
set -e

ROOT_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )/.." > /dev/null && pwd )
GCC_ROOT=$1

if [[ $# -ne 1 ]]; then
echo "Usage: pgo.sh <path to gcc root>"
if [[ $# -ne 1 ]] && [[ $# -ne 2 ]]; then
echo "Usage: pgo.sh <path to gcc root> [<pgo exercise script>]"
exit 1
fi

GCC_ROOT=$1
EXERCISE_SCRIPT=$2

export LIBRARY_PATH=/usr/lib/$(gcc -print-multiarch)
export C_INCLUDE_PATH=/usr/include/$(gcc -print-multiarch)
export CPLUS_INCLUDE_PATH=/usr/include/$(gcc -print-multiarch)
Expand All @@ -31,22 +33,29 @@ cmake ${ROOT_DIR} -DStatic:BOOL=Yes -DUseLTO:BOOL=Yes -DCMAKE_AR=${CMAKE_AR} -DC
make zq zindex
popd

# TODO more test cases here!
if [[ ! -e testfile.gz ]]; then
echo "Creating a test file"
seq 1000000 > testfile
echo "Gzipping test file"
gzip -f -9 testfile
pushd pgo-gen
if [[ -z "${EXERCISE_SCRIPT}" ]]; then
echo "Using built-in exercise script"
if [[ ! -e testfile.gz ]]; then
echo "Creating a test file"
seq 1000000 > testfile
echo "Gzipping test file"
gzip -f -9 testfile
fi
echo "Indexing test file"
./zindex --regex '([0-9]+)' testfile.gz
echo "Querying test file"
for i in $(seq 1 12345 1000000); do ./zq testfile.gz $i $((i + 100)) $((i + 200)); done
else
echo "Using external exercise script"
${EXERCISE_SCRIPT}
fi
echo "Indexing test file"
pgo-gen/zindex --regex '([0-9]+)' testfile.gz
echo "Querying test file"
for i in $(seq 1 12345 1000000); do pgo-gen/zq testfile.gz $i $((i + 100)) $((i + 200)); done
popd

echo "Making PGO executables"

mkdir -p pgo
cd pgo
cmake ${ROOT_DIR} -DStatic:BOOL=Yes -DUseLTO:BOOL=Yes -DCMAKE_AR=${CMAKE_AR} -DCMAKE_RANLIB=${CMAKE_RANLIB} -DArchNative:BOOL=yes -DCMAKE_BUILD_TYPE=Release -DPGO="-fprofile-use=${PGO_GEN}"
cmake ${ROOT_DIR} -DStatic:BOOL=Yes -DUseLTO:BOOL=Yes -DCMAKE_AR=${CMAKE_AR} -DCMAKE_RANLIB=${CMAKE_RANLIB} -DArchNative:BOOL=yes -DCMAKE_BUILD_TYPE=Release -DPGO="-fprofile-use=${PGO_GEN}" -DCMAKE_PREFIX_PATH=${ROOT_DIR}/build/zlib
make zq zindex
echo "Done!"

0 comments on commit b2109fc

Please sign in to comment.