OLD | NEW |
(Empty) | |
| 1 #!/bin/bash |
| 2 # Copyright (c) 2012 The Native Client Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. |
| 5 |
| 6 #@ This script is used to update the archive of canned nexes |
| 7 #@ Note, it does not recreate every nexe from scratch but will |
| 8 #@ update those it can (currently: spec and translator nexes). |
| 9 set -o nounset |
| 10 set -o errexit |
| 11 |
| 12 readonly UP_DOWN_LOAD_SCRIPT=buildbot/file_up_down_load.sh |
| 13 |
| 14 readonly CANNED_DIR=CannedNexes |
| 15 |
| 16 readonly SPEC_BASE="tests/spec2k" |
| 17 readonly SPEC_HARNESS=${SPEC_HARNESS:-${HOME}/cpu2000-redhat64-ia32}/ |
| 18 |
| 19 readonly SPEC_SETUPS_ARM=SetupPnaclArmOpt |
| 20 readonly SPEC_SETUPS_X8632=SetupPnaclX8632Opt |
| 21 readonly SPEC_SETUPS_X8664=SetupPnaclX8664Opt |
| 22 |
| 23 # for ./run_all.sh invocation |
| 24 readonly MAKEOPTS=-j8 |
| 25 export MAKEOPTS |
| 26 |
| 27 ###################################################################### |
| 28 # Helpers |
| 29 ###################################################################### |
| 30 |
| 31 Banner() { |
| 32 echo "######################################################################" |
| 33 echo $* |
| 34 echo "######################################################################" |
| 35 } |
| 36 |
| 37 help() { |
| 38 egrep "^#@" $0 | cut --bytes=3- |
| 39 } |
| 40 |
| 41 DownloadCannedNexes() { |
| 42 local arch=$1 |
| 43 local rev=$2 |
| 44 Banner "Downloading rev: ${rev} arch: ${arch}" |
| 45 ${UP_DOWN_LOAD_SCRIPT} DownloadArchivedNexes \ |
| 46 ${rev} "${arch}_giant" giant_nexe.tar.bz2 |
| 47 # Untaring the tarball will generate "${CANNED_DIR}/" in the current directory |
| 48 rm -rf ${CANNED_DIR} |
| 49 tar jxf giant_nexe.tar.bz2 |
| 50 } |
| 51 |
| 52 UploadCannedNexes() { |
| 53 local arch=$1 |
| 54 local rev=$2 |
| 55 Banner "Uploading rev: ${rev} arch: ${arch}" |
| 56 rm giant_nexe.tar.bz2 |
| 57 tar jcf giant_nexe.tar.bz2 ${CANNED_DIR} |
| 58 |
| 59 ${UP_DOWN_LOAD_SCRIPT} UploadArchivedNexes \ |
| 60 ${rev} "${arch}_giant" giant_nexe.tar.bz2 |
| 61 } |
| 62 |
| 63 AddTranslatorNexes() { |
| 64 local arch=$1 |
| 65 local sysarch="" |
| 66 if [[ ${arch} == "arm" ]] ; then |
| 67 sysarch=armv7 |
| 68 elif [[ ${arch} == "x86-32" ]] ; then |
| 69 sysarch=i686 |
| 70 elif [[ ${arch} == "x86-64" ]] ; then |
| 71 sysarch=x86_64 |
| 72 else |
| 73 echo "Error: unknown arch ${arch}" |
| 74 fi |
| 75 |
| 76 Banner "Updating Translator Nexes arch: ${arch}" |
| 77 cp toolchain/pnacl_translator/${sysarch}/bin/*.nexe ${CANNED_DIR} |
| 78 } |
| 79 |
| 80 AddSpecNexes() { |
| 81 local arch=$1 |
| 82 local setups= |
| 83 local fext= |
| 84 |
| 85 if [[ ${arch} == "arm" ]] ; then |
| 86 setups="${SPEC_SETUPS_ARM}" |
| 87 fext=arm |
| 88 elif [[ ${arch} == "x86-32" ]] ; then |
| 89 setups="${SPEC_SETUPS_X8632}" |
| 90 fext=x8632 |
| 91 elif [[ ${arch} == "x86-64" ]] ; then |
| 92 setups="${SPEC_SETUPS_X8664}" |
| 93 fext=x8664 |
| 94 else |
| 95 echo "Error: unknown arch ${arch}" |
| 96 fi |
| 97 |
| 98 Banner "Updating Spec Nexes arch: ${arch} setups: ${setups}" |
| 99 |
| 100 pushd ${SPEC_BASE} |
| 101 ./run_all.sh BuildPrerequisites "$@" bitcode |
| 102 ./run_all.sh CleanBenchmarks |
| 103 ./run_all.sh PopulateFromSpecHarness "${SPEC_HARNESS}" |
| 104 |
| 105 for setup in ${setups}; do |
| 106 ./run_all.sh BuildBenchmarks 0 ${setup} |
| 107 done |
| 108 popd |
| 109 |
| 110 cp tests/spec2k/*/*.${fext} ${CANNED_DIR} |
| 111 # we chop of the arch extension so that benchmark names |
| 112 # are the same across architectures |
| 113 rename 's/[.](arm|x8664|x8632)$//' ${CANNED_DIR}/*.${fext} |
| 114 } |
| 115 |
| 116 Update() { |
| 117 local arch=$1 |
| 118 local rev_in=$2 |
| 119 local rev_out=$3 |
| 120 DownloadCannedNexes ${arch} ${rev_in} |
| 121 AddTranslatorNexes ${arch} |
| 122 AddSpecNexes ${arch} |
| 123 UploadCannedNexes ${arch} ${rev_out} |
| 124 } |
| 125 |
| 126 ###################################################################### |
| 127 # "main" |
| 128 ###################################################################### |
| 129 |
| 130 if [ "$(type -t $1)" != "function" ]; then |
| 131 echo "ERROR: unknown function '$1'." >&2 |
| 132 echo "For help, try:" |
| 133 echo " $0 help" |
| 134 exit 1 |
| 135 fi |
| 136 |
| 137 "$@" |
OLD | NEW |