Skip to content

Commit 8138de5

Browse files
pytorchbotjorgep31415
authored andcommitted
[ET-VK] Print op breakdown in tsv format
[ET-VK] Print op breakdown in tsv format Pull Request resolved: #7740 Use boolean flag to switch between nicely-formatted space separator and spreadsheet-ready tab operator. Motiviation is similar to #7035 in facilitating copy-paste of results to a gsheet. ghstack-source-id: 262309623 Differential Revision: [D68345444](https://our.internmc.facebook.com/intern/diff/D68345444/) --------- Co-authored-by: jorgep31415 <[email protected]>
1 parent c138bce commit 8138de5

File tree

2 files changed

+42
-4
lines changed

2 files changed

+42
-4
lines changed

backends/vulkan/runtime/vk_api/QueryPool.cpp

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,9 +233,44 @@ std::string QueryPool::generate_string_report() {
233233
return ss.str();
234234
}
235235

236-
void QueryPool::print_results() {
236+
std::string QueryPool::generate_tsv_string_report() {
237+
std::lock_guard<std::mutex> lock(mutex_);
238+
239+
std::stringstream ss;
240+
241+
ss << "Kernel Name\t";
242+
ss << "Global Workgroup Size\t";
243+
ss << "Local Workgroup Size\t";
244+
ss << "Duration (ns)\t";
245+
ss << std::endl;
246+
247+
ss << "===========\t";
248+
ss << "=====================\t";
249+
ss << "====================\t";
250+
ss << "=============\t";
251+
ss << std::endl;
252+
253+
for (ShaderDuration& entry : shader_durations_) {
254+
std::chrono::duration<size_t, std::nano> exec_duration_ns(
255+
entry.execution_duration_ns);
256+
257+
ss << entry.kernel_name << "\t";
258+
ss << stringize(entry.global_workgroup_size) << "\t";
259+
ss << stringize(entry.local_workgroup_size) << "\t";
260+
ss << exec_duration_ns.count() << "\t";
261+
ss << std::endl;
262+
}
263+
264+
return ss.str();
265+
}
266+
267+
void QueryPool::print_results(const bool tsv_format) {
237268
EARLY_RETURN_IF_UNINITIALIZED();
238-
std::cout << generate_string_report() << std::endl;
269+
if (tsv_format) {
270+
std::cout << generate_tsv_string_report() << std::endl;
271+
} else {
272+
std::cout << generate_string_report() << std::endl;
273+
}
239274
}
240275

241276
unsigned long QueryPool::get_total_shader_ns(std::string kernel_name) {

backends/vulkan/runtime/vk_api/QueryPool.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,14 +99,17 @@ class QueryPool final {
9999

100100
std::vector<std::tuple<std::string, uint32_t, uint64_t, uint64_t>>
101101
get_shader_timestamp_data();
102-
std::string generate_string_report();
103-
void print_results();
102+
void print_results(const bool tsv_format = false);
104103
unsigned long get_total_shader_ns(std::string kernel_name);
105104
unsigned long get_mean_shader_ns(std::string kernel_name);
106105

107106
operator bool() const {
108107
return querypool_ != VK_NULL_HANDLE;
109108
}
109+
110+
private:
111+
std::string generate_string_report();
112+
std::string generate_tsv_string_report();
110113
};
111114

112115
} // namespace vkapi

0 commit comments

Comments
 (0)