summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul E. McKenney <paulmck@kernel.org>2024-01-21 06:23:28 -0800
committerPaul E. McKenney <paulmck@kernel.org>2024-01-22 12:20:09 -0800
commit042f1792f4416b0f18d228d380ff85b29ab7a7f5 (patch)
treeead4bdc152d9873fef9993ee2902b86cc49490fe
parentdf6c566bfe8b87bddeaabcb8f239bbd8f8a2b74e (diff)
downloadperfbook-042f1792f4416b0f18d228d380ff85b29ab7a7f5.tar.gz
CodeSamples/cpu: Add scripts to process coe values
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
-rwxr-xr-xCodeSamples/cpu/coe2dot.sh55
-rw-r--r--CodeSamples/cpu/coe2first.sh53
-rwxr-xr-xCodeSamples/cpu/coereduce.sh68
3 files changed, 176 insertions, 0 deletions
diff --git a/CodeSamples/cpu/coe2dot.sh b/CodeSamples/cpu/coe2dot.sh
new file mode 100755
index 00000000..912401db
--- /dev/null
+++ b/CodeSamples/cpu/coe2dot.sh
@@ -0,0 +1,55 @@
+#!/bin/bash
+#
+# Produce digraph from temporal coe data that has been previously
+# collected, for example, using: "./temporal --coe --nthreads 15"
+#
+# Usage: bash coe2dot.sh
+#
+# Takes the temporal coe data as standard input and produces on standard
+# output a graphviz .dot file that shows the partial ordering of stores.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, you can access it online at
+# http://www.gnu.org/licenses/gpl-2.0.html.
+#
+# Copyright (C) Meta Platform Inc., 2023
+#
+# Authors: Paul E. McKenney <paulmck@kernel.org>
+
+grep '^[0-9][0-9]* ' | awk '
+BEGIN {
+ lastthread = -1;
+}
+
+{
+ if ($1 != lastthread) {
+ lastthread = $1;
+ } else {
+ print "\t" lastval " -> " $3;
+ }
+ lastval = $3;
+}' | sort -u |
+awk '
+BEGIN {
+ print "digraph PartialOrder {";
+ print "\trankdir=\"LR\";";
+ lastthread = -1;
+}
+
+{
+ print $0;
+}
+
+END {
+ print "}";
+}' | tred
diff --git a/CodeSamples/cpu/coe2first.sh b/CodeSamples/cpu/coe2first.sh
new file mode 100644
index 00000000..ad220718
--- /dev/null
+++ b/CodeSamples/cpu/coe2first.sh
@@ -0,0 +1,53 @@
+#!/bin/bash
+#
+# Produce first thread/value reads from temporal coe data that has been
+# previously collected, for example, using: "./temporal --coe --nthreads 15"
+#
+# Usage: bash coe2dot.sh
+#
+# Takes the temporal coe data as standard input and produces on standard
+# output a table of numbers in thread order, when that thread first started
+# a read and when the first read that returned its value started.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, you can access it online at
+# http://www.gnu.org/licenses/gpl-2.0.html.
+#
+# Copyright (C) Meta Platform Inc., 2023
+#
+# Authors: Paul E. McKenney <paulmck@kernel.org>
+
+grep '^[0-9][0-9]* ' | sort -k2n | awk '
+BEGIN {
+ timeoffset = "";
+}
+
+timeoffset == "" {
+ timeoffset = $2 - 25;
+}
+
+{
+ if (ft[$1] == "") {
+ ft[$1] = $2 - timeoffset;
+ }
+ if (fv[$3] == "") {
+ fv[$3] = $2 - timeoffset;
+ }
+}
+
+END {
+ printf "%4s %8s %8s\n", "", "FT", "FV";
+ for (i in ft) {
+ printf "%4d %8d %8d %s\n", i, ft[i], fv[i], ft[i] != fv[i] ? "<-" : "";
+ }
+}'
diff --git a/CodeSamples/cpu/coereduce.sh b/CodeSamples/cpu/coereduce.sh
new file mode 100755
index 00000000..f54c0213
--- /dev/null
+++ b/CodeSamples/cpu/coereduce.sh
@@ -0,0 +1,68 @@
+#!/bin/bash
+#
+# Reduce temporal coe data that has been previously collected, for
+# example, using: "./temporal --coe --nthreads 15". Note that the
+# output of coe.sh is -not- suitable.
+#
+# Usage: bash coereduce.sh
+#
+# Takes the temporal coe data as standard input and produces on standard
+# output a gnuplot .dat file that plots the number of distinct opinions
+# on the value of the shared variable as a function of time.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, you can access it online at
+# http://www.gnu.org/licenses/gpl-2.0.html.
+#
+# Copyright (C) Meta Platform Inc., 2023
+#
+# Authors: Paul E. McKenney <paulmck@kernel.org>
+
+awk '
+/^[0-9][0-9]* / {
+ print $3, $2, +1;
+ print $3, $6, -1;
+}' | sort -k2n |
+awk '
+BEGIN {
+ max = -1;
+ xmin="";
+}
+
+{
+ if (xmin == "")
+ xmin = $2 - 25;
+ if ($3 > 0) {
+ if (nv[$1]++ == 0) {
+ n = n + 1;
+ print $2 - xmin, n - 1;
+ print $2 - xmin, n;
+ if (n > max)
+ max = n;
+ }
+ } else {
+ if (--nv[$1] == 0) {
+ n = n - 1;
+ print $2 - xmin, n + 1;
+ print $2 - xmin, n;
+ }
+ }
+}
+
+END {
+ if (n != 0) {
+ print "# Ending value of n = ", n "!!!";
+ exit 1;
+ }
+ print "# Maximum number of values: " max;
+}'