Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | # |
| 3 | # Copyright (c) 2011, Intel Corporation. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 4 | # |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 5 | # SPDX-License-Identifier: GPL-2.0-or-later |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 6 | # |
| 7 | # DESCRIPTION |
| 8 | # This script operates on the .dat file generated by bb-matrix.sh. It tolerates |
| 9 | # the header by skipping the first line, but error messages and bad data records |
| 10 | # need to be removed first. It will generate three views of the plot, and leave |
| 11 | # an interactive view open for further analysis. |
| 12 | # |
| 13 | # AUTHORS |
| 14 | # Darren Hart <dvhart@linux.intel.com> |
| 15 | # |
| 16 | |
| 17 | # Setup the defaults |
| 18 | DATFILE="bb-matrix.dat" |
| 19 | XLABEL="BB_NUMBER_THREADS" |
| 20 | YLABEL="PARALLEL_MAKE" |
| 21 | FIELD=3 |
| 22 | DEF_TITLE="Elapsed Time (seconds)" |
| 23 | PM3D_FRAGMENT="unset surface; set pm3d at s hidden3d 100" |
| 24 | SIZE="640,480" |
| 25 | |
| 26 | function usage { |
| 27 | CMD=$(basename $0) |
| 28 | cat <<EOM |
| 29 | Usage: $CMD [-d datfile] [-f field] [-h] [-t title] [-w] |
| 30 | -d datfile The data file generated by bb-matrix.sh (default: $DATFILE) |
| 31 | -f field The field index to plot as the Z axis from the data file |
| 32 | (default: $FIELD, "$DEF_TITLE") |
| 33 | -h Display this help message |
| 34 | -s W,H PNG and window size in pixels (default: $SIZE) |
| 35 | -t title The title to display, should describe the field (-f) and units |
| 36 | (default: "$DEF_TITLE") |
| 37 | -w Render the plot as wireframe with a 2D colormap projected on the |
| 38 | XY plane rather than as the texture for the surface |
| 39 | EOM |
| 40 | } |
| 41 | |
| 42 | # Parse and validate arguments |
| 43 | while getopts "d:f:hs:t:w" OPT; do |
| 44 | case $OPT in |
| 45 | d) |
| 46 | DATFILE="$OPTARG" |
| 47 | ;; |
| 48 | f) |
| 49 | FIELD="$OPTARG" |
| 50 | ;; |
| 51 | h) |
| 52 | usage |
| 53 | exit 0 |
| 54 | ;; |
| 55 | s) |
| 56 | SIZE="$OPTARG" |
| 57 | ;; |
| 58 | t) |
| 59 | TITLE="$OPTARG" |
| 60 | ;; |
| 61 | w) |
| 62 | PM3D_FRAGMENT="set pm3d at b" |
| 63 | W="-w" |
| 64 | ;; |
| 65 | *) |
| 66 | usage |
| 67 | exit 1 |
| 68 | ;; |
| 69 | esac |
| 70 | done |
| 71 | |
| 72 | # Ensure the data file exists |
| 73 | if [ ! -f "$DATFILE" ]; then |
| 74 | echo "ERROR: $DATFILE does not exist" |
| 75 | usage |
| 76 | exit 1 |
| 77 | fi |
| 78 | PLOT_BASENAME=${DATFILE%.*}-f$FIELD$W |
| 79 | |
| 80 | # Set a sane title |
| 81 | # TODO: parse the header and define titles for each format parameter for TIME(1) |
| 82 | if [ -z "$TITLE" ]; then |
| 83 | if [ ! "$FIELD" == "3" ]; then |
| 84 | TITLE="Field $FIELD" |
| 85 | else |
| 86 | TITLE="$DEF_TITLE" |
| 87 | fi |
| 88 | fi |
| 89 | |
| 90 | # Determine the dgrid3d mesh dimensions size |
| 91 | MIN=$(tail -n +2 "$DATFILE" | cut -d ' ' -f 1 | sed 's/^0*//' | sort -n | uniq | head -n1) |
| 92 | MAX=$(tail -n +2 "$DATFILE" | cut -d ' ' -f 1 | sed 's/^0*//' | sort -n | uniq | tail -n1) |
| 93 | BB_CNT=$[${MAX} - $MIN + 1] |
| 94 | MIN=$(tail -n +2 "$DATFILE" | cut -d ' ' -f 2 | sed 's/^0*//' | sort -n | uniq | head -n1) |
| 95 | MAX=$(tail -n +2 "$DATFILE" | cut -d ' ' -f 2 | sed 's/^0*//' | sort -n | uniq | tail -n1) |
| 96 | PM_CNT=$[${MAX} - $MIN + 1] |
| 97 | |
| 98 | |
| 99 | (cat <<EOF |
| 100 | set title "$TITLE" |
| 101 | set xlabel "$XLABEL" |
| 102 | set ylabel "$YLABEL" |
| 103 | set style line 100 lt 5 lw 1.5 |
| 104 | $PM3D_FRAGMENT |
| 105 | set dgrid3d $PM_CNT,$BB_CNT splines |
| 106 | set ticslevel 0.2 |
| 107 | |
| 108 | set term png size $SIZE |
| 109 | set output "$PLOT_BASENAME.png" |
| 110 | splot "$DATFILE" every ::1 using 1:2:$FIELD with lines ls 100 |
| 111 | |
| 112 | set view 90,0 |
| 113 | set output "$PLOT_BASENAME-bb.png" |
| 114 | replot |
| 115 | |
| 116 | set view 90,90 |
| 117 | set output "$PLOT_BASENAME-pm.png" |
| 118 | replot |
| 119 | |
| 120 | set view 60,30 |
| 121 | set term wxt size $SIZE |
| 122 | replot |
| 123 | EOF |
| 124 | ) | gnuplot --persist |