Skip to content

Commit 1991346

Browse files
liuk22facebook-github-bot
authored andcommitted
Default construct QueryPool with nonzero values (#3721)
Summary: Pull Request resolved: #3721 **We must bugfix this first to unblock either dumping querypool directly after inference or SDK development** Currently, if you try to init QueryPool during inference, it will crash at `vkCreateQueryPool`. Some debugging revealed in the test binary, it will crash only on VulkanComputeGraphTest but not VulkanComputeAPITest. It is because the `Context` instance is initialized in two different ways and then `QueryPoolConfig` is then initialized in two different ways. 1. Static singleton https://fburl.com/code/iqo8xcg2 with above nonzero max query count and the compile time flag to change the query pool. We don't use this for model inference. 2. Explicit constructor https://fburl.com/code/m1xga4ra, invoked in `VulkanBackend::Init()` https://fburl.com/code/4j8y3pzu which goes through default construction of `GraphConfig`, default construction of `QueryPoolConfig`, leading to zero max query count and crash. We use this for model inference. 3. This should be probably be unified, as it was extremely confusing to have the compile time flag work in non inference cases but not in inference case, and explicit const struct construction happens in the former vs completely default struct construction in the latter. 4. A quick solution to unblock. `QueryPoolConfig` has default init values of the compile time flags. Reviewed By: SS-JIA Differential Revision: D57735873 fbshipit-source-id: e04325f34f68576db462b3003ddfffefee7fc7f0
1 parent c28ca18 commit 1991346

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

backends/vulkan/runtime/api/QueryPool.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,16 @@
1818
#include <executorch/backends/vulkan/runtime/api/Command.h>
1919
#include <executorch/backends/vulkan/runtime/api/Pipeline.h>
2020

21+
#ifndef VULKAN_QUERY_POOL_SIZE
22+
#define VULKAN_QUERY_POOL_SIZE 4096u
23+
#endif
24+
2125
namespace vkcompute {
2226
namespace api {
2327

2428
struct QueryPoolConfig final {
25-
uint32_t max_query_count;
26-
uint32_t initial_reserve_size;
29+
uint32_t max_query_count = VULKAN_QUERY_POOL_SIZE;
30+
uint32_t initial_reserve_size = 256u;
2731
};
2832

2933
struct ShaderDuration final {

0 commit comments

Comments
 (0)