Skip to content

Commit 50f774a

Browse files
pytorchbotjorgep31415
authored andcommitted
[ET-VK] Add workgroup sizes to ShaderData
Pull Request resolved: #7875 Information is critical for shader optimization. ghstack-source-id: 262751884 @exported-using-ghexport Differential Revision: [D68534950](https://our.internmc.facebook.com/intern/diff/D68534950/) Co-authored-by: jorgep31415 <[email protected]>
1 parent f461a54 commit 50f774a

File tree

3 files changed

+20
-2
lines changed

3 files changed

+20
-2
lines changed

backends/vulkan/runtime/VulkanBackend.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -602,7 +602,9 @@ class VulkanBackend final : public ::executorch::runtime::BackendInterface {
602602
event_name.c_str(),
603603
/* delegate_debug_id = */ -1,
604604
r.start_time_ns,
605-
r.end_time_ns);
605+
r.end_time_ns,
606+
(void*)(&r.metadata),
607+
sizeof(r.metadata));
606608
}
607609
#endif // ET_EVENT_TRACER_ENABLED
608610

backends/vulkan/runtime/vk_api/QueryPool.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ std::string stringize(const VkExtent3D& extents) {
176176
<< "}";
177177
return ss.str();
178178
}
179+
179180
std::vector<ShaderResult> QueryPool::get_shader_timestamp_data() {
180181
if (querypool_ == VK_NULL_HANDLE) {
181182
return {};
@@ -188,7 +189,16 @@ std::vector<ShaderResult> QueryPool::get_shader_timestamp_data() {
188189
.dispatch_id = entry.dispatch_id,
189190
.start_time_ns = entry.start_time_ns,
190191
.end_time_ns = entry.end_time_ns,
191-
});
192+
.metadata = ShaderMetadata{
193+
.global_workgroup_size =
194+
{entry.global_workgroup_size.width,
195+
entry.global_workgroup_size.height,
196+
entry.global_workgroup_size.depth},
197+
.local_workgroup_size =
198+
{entry.local_workgroup_size.width,
199+
entry.local_workgroup_size.height,
200+
entry.local_workgroup_size.depth},
201+
}});
192202
}
193203
return shader_result;
194204
}

backends/vulkan/runtime/vk_api/QueryPool.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,17 @@
2626
namespace vkcompute {
2727
namespace vkapi {
2828

29+
struct ShaderMetadata final {
30+
const uint32_t global_workgroup_size[3];
31+
const uint32_t local_workgroup_size[3];
32+
};
33+
2934
struct ShaderResult final {
3035
const std::string kernel_name;
3136
const uint32_t dispatch_id;
3237
const uint64_t start_time_ns;
3338
const uint64_t end_time_ns;
39+
const ShaderMetadata metadata;
3440
};
3541

3642
struct QueryPoolConfig final {

0 commit comments

Comments
 (0)