Skip to content

Commit

Permalink
[ET-VK] Print op breakdown with tab separator
Browse files Browse the repository at this point in the history
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: 261985673

Differential Revision: [D68345444](https://our.internmc.facebook.com/intern/diff/D68345444/)
  • Loading branch information
jorgep31415 committed Jan 17, 2025
1 parent 1370755 commit d0c33dd
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 4 deletions.
40 changes: 38 additions & 2 deletions backends/vulkan/runtime/vk_api/QueryPool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,9 +233,45 @@ std::string QueryPool::generate_string_report() {
return ss.str();
}

void QueryPool::print_results() {

std::string QueryPool::generate_tsv_string_report() {
std::lock_guard<std::mutex> lock(mutex_);

std::stringstream ss;

ss << "Kernel Name\t";
ss << "Global Workgroup Size\t";
ss << "Local Workgroup Size\t";
ss << "Duration (ns)\t";
ss << std::endl;

ss << "===========\t";
ss << "=====================\t";
ss << "====================\t";
ss << "=============\t";
ss << std::endl;

for (ShaderDuration& entry : shader_durations_) {
std::chrono::duration<size_t, std::nano> exec_duration_ns(
entry.execution_duration_ns);

ss << entry.kernel_name << "\t";
ss << stringize(entry.global_workgroup_size) << "\t";
ss << stringize(entry.local_workgroup_size) << "\t";
ss << exec_duration_ns.count() << "\t";
ss << std::endl;
}

return ss.str();
}

void QueryPool::print_results(const bool tsv_format) {
EARLY_RETURN_IF_UNINITIALIZED();
std::cout << generate_string_report() << std::endl;
if (tsv_format) {
std::cout << generate_tsv_string_report() << std::endl;
} else {
std::cout << generate_string_report() << std::endl;
}
}

unsigned long QueryPool::get_total_shader_ns(std::string kernel_name) {
Expand Down
6 changes: 4 additions & 2 deletions backends/vulkan/runtime/vk_api/QueryPool.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,16 @@ class QueryPool final {

std::vector<std::tuple<std::string, uint32_t, uint64_t, uint64_t>>
get_shader_timestamp_data();
std::string generate_string_report();
void print_results();
void print_results(const bool tsv_format = false);
unsigned long get_total_shader_ns(std::string kernel_name);
unsigned long get_mean_shader_ns(std::string kernel_name);

operator bool() const {
return querypool_ != VK_NULL_HANDLE;
}
private:
std::string generate_string_report();
std::string generate_tsv_string_report();
};

} // namespace vkapi
Expand Down

0 comments on commit d0c33dd

Please sign in to comment.