summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul E. McKenney <paulmck@kernel.org>2024-01-12 16:28:19 -0800
committerPaul E. McKenney <paulmck@kernel.org>2024-01-20 12:40:11 -0800
commit94795ce73fbcb48056f077a8f207b932d85c71c6 (patch)
treee4439a97e9ba19c7ef4110f13fcf5849f4986a07
parent715741db8e14fda5ded59afc7af1a2c9ea16da74 (diff)
downloadperfbook-94795ce73fbcb48056f077a8f207b932d85c71c6.tar.gz
CodeSamples/cpu: Add a coe.sh script
The new coe.sh script is similar to fre.sh and rfe.sh, designed to run tests showing that the coe relation (C++ modification order) can be counter-temporal. Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
-rwxr-xr-xCodeSamples/cpu/coe.sh64
1 files changed, 64 insertions, 0 deletions
diff --git a/CodeSamples/cpu/coe.sh b/CodeSamples/cpu/coe.sh
new file mode 100755
index 00000000..49833709
--- /dev/null
+++ b/CodeSamples/cpu/coe.sh
@@ -0,0 +1,64 @@
+#!/bin/bash
+#
+# Produce and reduce temporal coe data.
+#
+# Usage: bash coe.sh [ nthreads ]
+#
+# 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 Platforms Inc., 2024
+#
+# Authors: Paul E. McKenney <paulmck@kernel.org>
+
+./temporal --coe --nthreads ${1-15} |
+awk '
+BEGIN {
+ lastentry = "";
+ maxtime = "";
+ winningcpu = -1;
+}
+
+/^COE-write / {
+ if (lastentry != "") # @@@
+ print "Last entry: " lastentry; # @@@
+ st[$2] = $3;
+ et[$2] = $5;
+ print "Input line: " $0 # @@@
+}
+
+$1 ~ /^[0-9][0-9]*$/ {
+ if (maxtime == "" || maxtime < $2) {
+ maxtime = $2;
+ winningcpu = $3;
+ # lastentry = $0; # @@@
+ }
+}
+
+END {
+ # print "Winning CPU: " winningcpu; # @@@
+ mindelta = "";
+ for (i in st) {
+ if (i == winningcpu)
+ continue;
+ delta = et[winningcpu] - st[i];
+ # print "Delta for CPU " i ": " et[winningcpu] " - " st[i] " = " delta; # @@@
+ if (mindelta == "" || mindelta > delta) {
+ mindelta = delta;
+ min_et = et[winningcpu];
+ min_st = st[i];
+ }
+ }
+ print winningcpu, min_et, min_st, mindelta, mindelta < 0 ? "!!!" : "";
+}'