blob: e7bd129e9ed838e50197261554db3e0103cb5fa5 [file] [log] [blame]
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001#!/bin/bash
2#
3# Copyright (c) 2011, Intel Corporation.
Patrick Williamsc124f4f2015-09-15 14:41:29 -05004#
Brad Bishopc342db32019-05-15 21:57:59 -04005# SPDX-License-Identifier: GPL-2.0-or-later
Patrick Williamsc124f4f2015-09-15 14:41:29 -05006#
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
18DATFILE="bb-matrix.dat"
19XLABEL="BB_NUMBER_THREADS"
20YLABEL="PARALLEL_MAKE"
21FIELD=3
22DEF_TITLE="Elapsed Time (seconds)"
23PM3D_FRAGMENT="unset surface; set pm3d at s hidden3d 100"
24SIZE="640,480"
25
26function usage {
27CMD=$(basename $0)
28cat <<EOM
29Usage: $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
39EOM
40}
41
42# Parse and validate arguments
43while 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
70done
71
72# Ensure the data file exists
73if [ ! -f "$DATFILE" ]; then
74 echo "ERROR: $DATFILE does not exist"
75 usage
76 exit 1
77fi
78PLOT_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)
82if [ -z "$TITLE" ]; then
83 if [ ! "$FIELD" == "3" ]; then
84 TITLE="Field $FIELD"
85 else
86 TITLE="$DEF_TITLE"
87 fi
88fi
89
90# Determine the dgrid3d mesh dimensions size
91MIN=$(tail -n +2 "$DATFILE" | cut -d ' ' -f 1 | sed 's/^0*//' | sort -n | uniq | head -n1)
92MAX=$(tail -n +2 "$DATFILE" | cut -d ' ' -f 1 | sed 's/^0*//' | sort -n | uniq | tail -n1)
93BB_CNT=$[${MAX} - $MIN + 1]
94MIN=$(tail -n +2 "$DATFILE" | cut -d ' ' -f 2 | sed 's/^0*//' | sort -n | uniq | head -n1)
95MAX=$(tail -n +2 "$DATFILE" | cut -d ' ' -f 2 | sed 's/^0*//' | sort -n | uniq | tail -n1)
96PM_CNT=$[${MAX} - $MIN + 1]
97
98
99(cat <<EOF
100set title "$TITLE"
101set xlabel "$XLABEL"
102set ylabel "$YLABEL"
103set style line 100 lt 5 lw 1.5
104$PM3D_FRAGMENT
105set dgrid3d $PM_CNT,$BB_CNT splines
106set ticslevel 0.2
107
108set term png size $SIZE
109set output "$PLOT_BASENAME.png"
110splot "$DATFILE" every ::1 using 1:2:$FIELD with lines ls 100
111
112set view 90,0
113set output "$PLOT_BASENAME-bb.png"
114replot
115
116set view 90,90
117set output "$PLOT_BASENAME-pm.png"
118replot
119
120set view 60,30
121set term wxt size $SIZE
122replot
123EOF
124) | gnuplot --persist