| 1 | #!/usr/bin/env python3
|
|---|
| 2 |
|
|---|
| 3 | # Copyright (c) 2017, Lawrence Livermore National Security, LLC.
|
|---|
| 4 | # Produced at the Lawrence Livermore National Laboratory
|
|---|
| 5 | # Written by Chunhua Liao, Pei-Hung Lin, Joshua Asplund,
|
|---|
| 6 | # Markus Schordan, and Ian Karlin
|
|---|
| 7 | # (email: liao6@llnl.gov, lin32@llnl.gov, asplund1@llnl.gov,
|
|---|
| 8 | # schordan1@llnl.gov, karlin1@llnl.gov)
|
|---|
| 9 | # LLNL-CODE-732144
|
|---|
| 10 | # All rights reserved.
|
|---|
| 11 | #
|
|---|
| 12 | # This file is part of DataRaceBench. For details, see
|
|---|
| 13 | # https://github.com/LLNL/dataracebench. Please also see the LICENSE file
|
|---|
| 14 | # for our additional BSD notice
|
|---|
| 15 | #
|
|---|
| 16 | # Redistribution of Backstroke and use in source and binary forms, with
|
|---|
| 17 | # or without modification, are permitted provided that the following
|
|---|
| 18 | # conditions are met:
|
|---|
| 19 | #
|
|---|
| 20 | # * Redistributions of source code must retain the above copyright
|
|---|
| 21 | # notice, this list of conditions and the disclaimer below.
|
|---|
| 22 | #
|
|---|
| 23 | # * Redistributions in binary form must reproduce the above copyright
|
|---|
| 24 | # notice, this list of conditions and the disclaimer (as noted below)
|
|---|
| 25 | # in the documentation and/or other materials provided with the
|
|---|
| 26 | # distribution.
|
|---|
| 27 | #
|
|---|
| 28 | # * Neither the name of the LLNS/LLNL nor the names of its contributors
|
|---|
| 29 | # may be used to endorse or promote products derived from this
|
|---|
| 30 | # software without specific prior written permission.
|
|---|
| 31 | #
|
|---|
| 32 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
|---|
| 33 | # CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
|---|
| 34 | # INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|---|
| 35 | # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|---|
| 36 | # DISCLAIMED. IN NO EVENT SHALL LAWRENCE LIVERMORE NATIONAL
|
|---|
| 37 | # SECURITY, LLC, THE U.S. DEPARTMENT OF ENERGY OR CONTRIBUTORS BE
|
|---|
| 38 | # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
|---|
| 39 | # OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|---|
| 40 | # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|---|
| 41 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|---|
| 42 | # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|---|
| 43 | # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
|---|
| 44 | # IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
|---|
| 45 | # THE POSSIBILITY OF SUCH DAMAGE.
|
|---|
| 46 |
|
|---|
| 47 | import numpy as np
|
|---|
| 48 | import pandas as pd
|
|---|
| 49 |
|
|---|
| 50 | def result_type(row):
|
|---|
| 51 | result = ""
|
|---|
| 52 | if (row['haverace']) and (row['races-max'] > 0):
|
|---|
| 53 | result += '\\truepositive'
|
|---|
| 54 | if (row['haverace']) and (row['races-min'] == 0):
|
|---|
| 55 | result += '\\falsenegative'
|
|---|
| 56 | if (not row['haverace']) and (row['races-max'] > 0):
|
|---|
| 57 | result += '\\falsepositive'
|
|---|
| 58 | if (not row['haverace']) and (row['races-min'] == 0):
|
|---|
| 59 | result += '\\truenegative'
|
|---|
| 60 | return result
|
|---|
| 61 |
|
|---|
| 62 | datasets = {
|
|---|
| 63 | 'archer': ['results/archer-4.0.1-polyhedral.csv', 'results/archer-4.0.1-Quartz.csv']
|
|---|
| 64 | , 'helgrind': ['results/helgrind-polyhedral-Quartz.csv', 'results/helgrind-Quartz.csv']
|
|---|
| 65 | , 'inspector': ['results/inspector-polyhedral.csv', 'results/inspector-ti3-Quartz.csv']
|
|---|
| 66 | , 'tsan': ['results/tsan-4.0.1-Quartz.csv', 'results/tsan-4.0.1-polyhedral.csv']
|
|---|
| 67 | }
|
|---|
| 68 |
|
|---|
| 69 | summary = pd.DataFrame(index=datasets.keys())
|
|---|
| 70 | summary.index.name = 'tool'
|
|---|
| 71 |
|
|---|
| 72 | for tool, dfs in datasets.items():
|
|---|
| 73 | dfs = [pd.read_csv(x) for x in dfs]
|
|---|
| 74 | results = pd.concat(dfs)
|
|---|
| 75 |
|
|---|
| 76 | tp = len(results[((results['haverace'] > 0) & (results['races'] > 0))])
|
|---|
| 77 | fn = len(results[((results['haverace'] > 0) & (results['races'] == 0))])
|
|---|
| 78 | fp = len(results[((results['haverace'] == 0) & (results['races'] > 0))])
|
|---|
| 79 | tn = len(results[((results['haverace'] == 0) & (results['races'] == 0))])
|
|---|
| 80 |
|
|---|
| 81 | summary.set_value(tool, 'recall', tp / (tp + fn))
|
|---|
| 82 | summary.set_value(tool, 'precision', tp / (tp + fp))
|
|---|
| 83 | summary.set_value(tool, 'accuracy', (tp + tn) / (tp + fp + fn + tn))
|
|---|
| 84 |
|
|---|
| 85 | race_min = results.groupby(['tool', 'filename', 'haverace']).min()
|
|---|
| 86 | race_max = results.groupby(['tool', 'filename', 'haverace']).max()
|
|---|
| 87 | output = race_min.join(race_max, lsuffix='-min', rsuffix='-max').reset_index()
|
|---|
| 88 | output[['races-min','races-max']] = output[['races-min','races-max']].astype(int)
|
|---|
| 89 |
|
|---|
| 90 | output['filename'] = output['filename'].str.split('/').str.get(1)
|
|---|
| 91 | output['haverace'] = output['haverace'] > 0
|
|---|
| 92 | output['found-race'] = output['races-max'] > 0
|
|---|
| 93 | output['type'] = output.apply(result_type, axis=1)
|
|---|
| 94 |
|
|---|
| 95 | outfile_local = 'results/{}-finished.csv'.format(tool)
|
|---|
| 96 | with open(outfile_local, "w") as f:
|
|---|
| 97 | output.to_csv(f, index=False)
|
|---|
| 98 |
|
|---|
| 99 | outfile = '../publications/sc17/{}-finished.csv'.format(tool)
|
|---|
| 100 | with open(outfile, "w") as f:
|
|---|
| 101 | output.to_csv(f, index=False)
|
|---|
| 102 |
|
|---|
| 103 | with open('results/summary.csv', "w") as f:
|
|---|
| 104 | summary.to_csv(f)
|
|---|