| 1 | #!/bin/bash
|
|---|
| 2 | # Copyright (c) 2017, Lawrence Livermore National Security, LLC.
|
|---|
| 3 | # Produced at the Lawrence Livermore National Laboratory
|
|---|
| 4 | # Written by Chunhua Liao, Pei-Hung Lin, Joshua Asplund,
|
|---|
| 5 | # Markus Schordan, and Ian Karlin
|
|---|
| 6 | # (email: liao6@llnl.gov, lin32@llnl.gov, asplund1@llnl.gov,
|
|---|
| 7 | # schordan1@llnl.gov, karlin1@llnl.gov)
|
|---|
| 8 | # LLNL-CODE-732144
|
|---|
| 9 | # All rights reserved.
|
|---|
| 10 | #
|
|---|
| 11 | # This file is part of DataRaceBench. For details, see
|
|---|
| 12 | # https://github.com/LLNL/dataracebench. Please also see the LICENSE file
|
|---|
| 13 | # for our additional BSD notice
|
|---|
| 14 | #
|
|---|
| 15 | # Redistribution of Backstroke and use in source and binary forms, with
|
|---|
| 16 | # or without modification, are permitted provided that the following
|
|---|
| 17 | # conditions are met:
|
|---|
| 18 | #
|
|---|
| 19 | # * Redistributions of source code must retain the above copyright
|
|---|
| 20 | # notice, this list of conditions and the disclaimer below.
|
|---|
| 21 | #
|
|---|
| 22 | # * Redistributions in binary form must reproduce the above copyright
|
|---|
| 23 | # notice, this list of conditions and the disclaimer (as noted below)
|
|---|
| 24 | # in the documentation and/or other materials provided with the
|
|---|
| 25 | # distribution.
|
|---|
| 26 | #
|
|---|
| 27 | # * Neither the name of the LLNS/LLNL nor the names of its contributors
|
|---|
| 28 | # may be used to endorse or promote products derived from this
|
|---|
| 29 | # software without specific prior written permission.
|
|---|
| 30 | #
|
|---|
| 31 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
|---|
| 32 | # CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
|---|
| 33 | # INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|---|
| 34 | # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|---|
| 35 | # DISCLAIMED. IN NO EVENT SHALL LAWRENCE LIVERMORE NATIONAL
|
|---|
| 36 | # SECURITY, LLC, THE U.S. DEPARTMENT OF ENERGY OR CONTRIBUTORS BE
|
|---|
| 37 | # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
|---|
| 38 | # OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|---|
| 39 | # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|---|
| 40 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|---|
| 41 | # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|---|
| 42 | # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
|---|
| 43 | # IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
|---|
| 44 | # THE POSSIBILITY OF SUCH DAMAGE.
|
|---|
| 45 |
|
|---|
| 46 | #----------------------------------------------------------------
|
|---|
| 47 | # copy& paste the two tables in https://github.com/LLNL/dataracebench/blob/master/README.md
|
|---|
| 48 | # save to a benchmark_list.txt file
|
|---|
| 49 | # then run thisScript benchmark_list.txt to count Y and N labels.
|
|---|
| 50 | #example output:
|
|---|
| 51 | # ./count_drb_labels.sh benchmark_list.txt
|
|---|
| 52 | # ----1: Y1, N1-----
|
|---|
| 53 | # 26
|
|---|
| 54 | # 14
|
|---|
| 55 | # ----2: Y2, N2-----
|
|---|
| 56 | # 17
|
|---|
| 57 | # 19
|
|---|
| 58 | # ----3: Y3, N3-----
|
|---|
| 59 | # 8
|
|---|
| 60 | # 9
|
|---|
| 61 | # ----4: Y4, N4-----
|
|---|
| 62 | # 3
|
|---|
| 63 | # 4
|
|---|
| 64 | # ----5: Y5, N5-----
|
|---|
| 65 | # 1
|
|---|
| 66 | # 2
|
|---|
| 67 | # ----6: Y6, N6-----
|
|---|
| 68 | # 4
|
|---|
| 69 | # 7
|
|---|
| 70 | # ----7: Y7, N7-----
|
|---|
| 71 | # 4
|
|---|
| 72 | # 9
|
|---|
| 73 | # Total Y label count=63
|
|---|
| 74 | # Total N label count=64
|
|---|
| 75 | ##----------------------------------------------------------------
|
|---|
| 76 | set -u
|
|---|
| 77 |
|
|---|
| 78 | # expect an argument for the text file storing benchmarks and labels
|
|---|
| 79 | # $# means the number of arguments passed to a function, or to the script itself
|
|---|
| 80 | if [ $# -eq 1 ]; then
|
|---|
| 81 | INPUT_FILE=$1
|
|---|
| 82 | else
|
|---|
| 83 | echo This script needs one argument while there is $# arguments.
|
|---|
| 84 | echo Usage:$0 inputfile
|
|---|
| 85 | echo Exampe:$0 benchmark_list.txt
|
|---|
| 86 | exit 1
|
|---|
| 87 | fi
|
|---|
| 88 |
|
|---|
| 89 | if [ ! -f "$INPUT_FILE" ]; then
|
|---|
| 90 | echo "Error: cannot find $INPUT_FILE. Please make sure it exists!"
|
|---|
| 91 | exit 1
|
|---|
| 92 | fi
|
|---|
| 93 |
|
|---|
| 94 | ysum=0
|
|---|
| 95 | nsum=0
|
|---|
| 96 |
|
|---|
| 97 | for var in 1 2 3 4 5 6 7; do
|
|---|
| 98 | YLABEL="Y$var"
|
|---|
| 99 | NLABEL="N$var"
|
|---|
| 100 |
|
|---|
| 101 | echo "----$var: $YLABEL, $NLABEL-----"
|
|---|
| 102 | ycount=`grep $YLABEL $INPUT_FILE | wc | awk '{print $1}'`
|
|---|
| 103 | echo $ycount
|
|---|
| 104 | let "ysum+=$ycount"
|
|---|
| 105 | ncount=`grep $NLABEL $INPUT_FILE | wc | awk '{print $1}'`
|
|---|
| 106 | echo $ncount
|
|---|
| 107 | let "nsum+=$ncount"
|
|---|
| 108 | done
|
|---|
| 109 |
|
|---|
| 110 | echo "Total Y label count=$ysum"
|
|---|
| 111 | echo "Total N label count=$nsum"
|
|---|