Fix the main library stop routine for timemory (#39)
* Fix the main library stop routine for timemory
- the main pop_timemory function was popping too many calls
- this primarily affected recursive calls
* Lengthen the timeout for the Configure CMake step
* Fix python tests
- new validate-timemory-json.py script
* Documentation update
- Call-counts in timemory output examples in documentation were affected by the changes
* Fix the per-thread metrics during finalization
- pthread_create_mutex starts/stops the per-thread data
- removed unintentional continue statement
* Docs tweaks
* Fix lap counter on per-thread metrics
[ROCm/rocprofiler-systems commit: a142b2029d]
This commit is contained in:
committed by
GitHub
parent
ad9fd4b7ec
commit
aeab36501a
@@ -886,12 +886,15 @@ foreach(_VERSION ${OMNITRACE_PYTHON_VERSIONS})
|
||||
|
||||
omnitrace_add_python_test(
|
||||
NAME python-source-check
|
||||
COMMAND ${OMNITRACE_CAT_COMMAND}
|
||||
COMMAND
|
||||
${_PYTHON_EXECUTABLE} ${CMAKE_CURRENT_LIST_DIR}/validate-timemory-json.py
|
||||
-l run fib fib fib fib fib inefficient _sum -c 5 5 10 20 30 10 5 5 -d 0 1
|
||||
2 3 4 5 1 2 -m trip_count -i
|
||||
PYTHON_VERSION ${_VERSION}
|
||||
FILE omnitrace-tests-output/python-source/${_VERSION}/trip_count.txt
|
||||
PASS_REGEX
|
||||
"(\\\| \\\|0>>> run \\\| 5).*(\\\| \\\|0>>> \\\|_fib \\\| 40).*(\\\| \\\|0>>> \\\|_fib \\\| 5).*(\\\| \\\|0>>> \\\|_inefficient \\\| 5).*(\\\| \\\|0>>> \\\|__sum \\\| 5)"
|
||||
FILE omnitrace-tests-output/python-source/${_VERSION}/trip_count.json
|
||||
DEPENDS python-source-${_VERSION}
|
||||
PASS_REGEX
|
||||
"omnitrace-tests-output/python-source/${_VERSION}/trip_count.json validated"
|
||||
ENVIRONMENT "${_python_environment}")
|
||||
else()
|
||||
omnitrace_message(
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import sys
|
||||
import json
|
||||
import argparse
|
||||
|
||||
|
||||
def validate_json(data, labels, counts, depths):
|
||||
expected = []
|
||||
for litr, citr, ditr in zip(labels, counts, depths):
|
||||
entry = []
|
||||
_label = litr
|
||||
if ditr > 0:
|
||||
_label = "{}|_{}".format(" " * (ditr - 1), litr)
|
||||
entry = [_label, citr, ditr]
|
||||
expected.append(entry)
|
||||
|
||||
for ditr, eitr in zip(data, expected):
|
||||
_prefix = ditr["prefix"]
|
||||
_depth = ditr["depth"]
|
||||
_count = ditr["entry"]["laps"]
|
||||
_idx = _prefix.find(">>>")
|
||||
if _idx is not None:
|
||||
_prefix = _prefix[(_idx + 4) :]
|
||||
if _prefix != eitr[0]:
|
||||
raise RuntimeError(f"Mismatched prefix: {_prefix} vs. {eitr[0]}")
|
||||
if _count != eitr[1]:
|
||||
raise RuntimeError(f"Mismatched depth: {_depth} vs. {eitr[2]}")
|
||||
if _depth != eitr[2]:
|
||||
raise RuntimeError(f"Mismatched depth: {_depth} vs. {eitr[2]}")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("-m", "--metric", type=str, help="JSON metric", required=True)
|
||||
parser.add_argument(
|
||||
"-l", "--labels", nargs="+", type=str, help="Expected labels", default=[]
|
||||
)
|
||||
parser.add_argument(
|
||||
"-c", "--counts", nargs="+", type=int, help="Expected counts", default=[]
|
||||
)
|
||||
parser.add_argument(
|
||||
"-d", "--depths", nargs="+", type=int, help="Expected depths", default=[]
|
||||
)
|
||||
parser.add_argument("-i", "--input", type=str, help="Input file", required=True)
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
if len(args.labels) != len(args.counts) or len(args.labels) != len(args.depths):
|
||||
raise RuntimeError(
|
||||
"The same number of labels, counts, and depths must be specified"
|
||||
)
|
||||
|
||||
ret = 0
|
||||
with open(args.input) as f:
|
||||
data = json.load(f)
|
||||
try:
|
||||
validate_json(
|
||||
data["timemory"][args.metric]["ranks"][0]["graph"],
|
||||
args.labels,
|
||||
args.counts,
|
||||
args.depths,
|
||||
)
|
||||
except RuntimeError as e:
|
||||
print(f"{e}")
|
||||
ret = 1
|
||||
if ret == 0:
|
||||
print(f"{args.input} validated")
|
||||
sys.exit(ret)
|
||||
Reference in New Issue
Block a user