Commit 72ac5b2e authored by Peter W. Draper's avatar Peter W. Draper
Browse files

Add a simple script to match the sends and recvs of a step for further analysis

parent 3b1cef15
......@@ -101,5 +101,5 @@ The stic values should be synchronized between ranks as all ranks have a
barrier in place to make sure they start the step together, so should be
suitable for matching between ranks. The unique keys to associate records
between ranks (so that the MPI_Isend and MPI_Irecv pairs can be identified)
are "rank/otherrank/type/subtype/tag/size" and
"otherrank/rank/type/subtype/tag/size".
are "otherrank/rank/subtype/tag/size" and "rank/otherrank/subtype/tag/size"
for send and recv respectively. When matching ignore step0.
#!/usr/bin/env python
"""
Usage:
match_mpireports.py [options] mpi-reports...
Match the rows that sends start and recvs complete from a set of mpi-reports
of a single step, and output the matched rows to standard output. If captured
the output can be analysed to see how long the send to recvs took to complete.
This file is part of SWIFT.
Copyright (C) 2019 Peter W. Draper (p.w.draper@durham.ac.uk)
All Rights Reserved.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation, either version 3 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 Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
"""
import sys
import argparse
# Handle the command line.
parser = argparse.ArgumentParser(description="Match MPI reports")
parser.add_argument("input",
nargs="+",
metavar="mpi-reports",
help="MPI reports")
parser.add_argument(
"-v",
"--verbose",
dest="verbose",
help="Verbose output",
default=False,
action="store_true",
)
args = parser.parse_args()
infiles = args.input
# Indices for words in a line.
sticcol=0
eticcol=1
dticcol=2
stepcol=3
rankcol=4
otherrankcol=5
typecol=6
itypecol=7
subtypecol=8
isubtypecol=9
activationcol=10
tagcol=11
sizecol=12
sum=13
# Keyed lines.
sends = {}
recvs = {}
# Gather keys from input files. We created dicts with matchable keys
# for when sends start and recvs end. Other pairings are possible...
# Note size of completion recv is negative.
for f in infiles:
if args.verbose:
print "Processing: " + f
with open(f, "r") as fp:
for line in fp:
if line[0] == '#':
continue
words = line.split()
if words[activationcol] == "1" and words[typecol] == "send":
key = words[otherrankcol] + "/" + \
words[rankcol] + "/" + \
words[subtypecol] + "/" + \
words[tagcol] + "/" + \
words[sizecol]
if not key in sends:
sends[key] = [line[:-1]]
else:
sends[key].append(line[:-1])
elif words[activationcol] == "0" and words[typecol] == "recv":
key = words[rankcol] + "/" + \
words[otherrankcol] + "/" + \
words[subtypecol] + "/" + \
words[tagcol] + "/" + \
words[sizecol][1:]
if not key in recvs:
recvs[key] = [line[:-1]]
else:
recvs[key].append(line[:-1])
# Now output. Note we could have unmatched recv keys, we don't check for that.
for key in sends:
if key in recvs:
if len(sends[key]) == 1 and len(recvs[key]) == 1:
print sends[key][0], recvs[key][0]
else:
print "# ERROR: found ", len(sends[key]), "/", len(recvs[key]), " matches for key: ", key, " should be 1/1"
else:
print "# ERROR: missing recv key: ", key
sys.exit(0)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment