Skip to content

Commit

Permalink
#9956: Device only perf report smoke test
Browse files Browse the repository at this point in the history
  • Loading branch information
mo-tenstorrent committed Nov 5, 2024
1 parent 3861156 commit b9c2089
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 7 deletions.
11 changes: 11 additions & 0 deletions tests/scripts/run_profiler_regressions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,21 @@ run_tracing_async_mode_T3000_test(){
else
echo "Verifying test results"
runDate=$(ls $PROFILER_OUTPUT_DIR/)
echo $runDate
LINE_COUNT=4100 # Smoke test to see at least 4100 ops are reported
res=$(verify_perf_line_count_floor "$PROFILER_OUTPUT_DIR/$runDate/ops_perf_results_$runDate.csv" "$LINE_COUNT")
echo $res
fi

#Testing device only report on the same artifacts
rm -rf $PROFILER_OUTPUT_DIR/
./tt_metal/tools/profiler/process_ops_logs.py --device-only --date
echo "Verifying device-only results"
runDate=$(ls $PROFILER_OUTPUT_DIR/)
echo $runDate
LINE_COUNT=3600 # Smoke test to see at least 4100 ops are reported
res=$(verify_perf_line_count_floor "$PROFILER_OUTPUT_DIR/$runDate/ops_perf_results_$runDate.csv" "$LINE_COUNT")
echo $res
fi
}

Expand Down
18 changes: 11 additions & 7 deletions tt_metal/tools/profiler/process_ops_logs.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def import_tracy_op_logs(logFolder):
tracyOpDataLog = os.path.join(logFolder, TRACY_OPS_DATA_FILE_NAME)

if not os.path.isfile(tracyOpTimesLog) or not os.path.isfile(tracyOpDataLog):
return ops, signposts
return ops, signposts, None

with open(tracyOpDataLog, "r", newline="") as csvFile:
opDataDicts = csv.DictReader(csvFile, delimiter=";", quotechar="`")
Expand Down Expand Up @@ -425,11 +425,15 @@ def get_device_data_generate_report(
devicePreOpTime[device] = analysisData[0]["end_cycle"]
rowDicts.append(rowDict)

rowDictHeaders = set()
for row in rowDicts:
for k in row.keys():
rowDictHeaders.add(k)
if export_csv:
with open(allOpsCSVPath, "w") as allOpsCSV:
allHeaders = []
for header in OPS_CSV_HEADER:
if header in rowDicts[-1].keys():
if header in rowDictHeaders:
allHeaders.append(header)
writer = csv.DictWriter(allOpsCSV, fieldnames=allHeaders)
writer.writeheader()
Expand Down Expand Up @@ -668,18 +672,17 @@ def row_compare(row):
logger.info(f"OPs csv generated at: {allOpsCSVPath}")


def process_ops(output_folder, name_append, date):
def process_ops(output_folder, name_append, date, device_only=False):
if not output_folder:
output_folder = PROFILER_ARTIFACTS_DIR
logFolder = generate_logs_folder(output_folder)
reportFolder = generate_reports_folder(output_folder)

ops, signposts, traceReplays = import_tracy_op_logs(logFolder)

if ops:
if ops and not device_only:
deviceOps, traceOps = append_device_data(ops, traceReplays, logFolder)
generate_reports(ops, deviceOps, traceOps, signposts, logFolder, reportFolder, date, name_append)

else:
deviceOps = get_device_data_generate_report(logFolder, reportFolder, date, name_append)

Expand All @@ -688,10 +691,11 @@ def process_ops(output_folder, name_append, date):
@click.option("-o", "--output-folder", type=click.Path(), help="Output folder for artifacts")
@click.option("-n", "--name-append", type=str, help="Name to be appended to default csv name")
@click.option("--date", default=False, is_flag=True, help="Append date to output files")
def main(output_folder, name_append, date):
@click.option("--device-only", default=False, is_flag=True, help="Only generate a device data report")
def main(output_folder, name_append, date, device_only):
if output_folder:
output_folder = Path(output_folder)
process_ops(output_folder, name_append, date)
process_ops(output_folder, name_append, date, device_only)


if __name__ == "__main__":
Expand Down

0 comments on commit b9c2089

Please sign in to comment.