Skip to content

Commit 37a74c7

Browse files
authored
[SYCL] Fix sycl-prof JSON output (#7128)
This patch fixes a problem related to the JSON output. Every element of `"traceEvents"` has a comma appended, this is a problem in the case of the last element, e.g., ``` { "traceEvents": [ ... {"name": "piTearDown", ... , "ts": "16..81"}, <-- here is ], "displayTimeUnit":"ns" } ``` This comma prevents the display of the JSON output in `chrome://tracing/` or [speedscope](https://www.speedscope.app/) due to its invalid format. This patch solves the problem by adding an empty element before finalizing the JSON output.
1 parent 0c541bd commit 37a74c7

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

sycl/tools/sycl-prof/writer.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,10 @@ class JSONWriter : public Writer {
7272
if (!MOutFile.is_open())
7373
return;
7474

75+
// add an empty element for not ending with '}, ]'
76+
MOutFile << "{\"name\": \"\", \"cat\": \"\", \"ph\": \"\", \"pid\": \"\", "
77+
"\"tid\": \"\", \"ts\": \"\"}\n";
78+
7579
MOutFile << "],\n";
7680
MOutFile << "\"displayTimeUnit\":\"ns\"\n}\n";
7781
MOutFile.close();

0 commit comments

Comments
 (0)