Skip to content

Commit cc88e69

Browse files
jeffbolznvMinh141120
authored andcommitted
vulkan: Track descriptor pools/sets per-context (ggml-org#14109)
Use the same descriptor set layout for all pipelines (MAX_PARAMETER_COUNT == 8) and move it to the vk_device. Move all the descriptor pool and set tracking to the context - none of it is specific to pipelines anymore. It has a single vector of pools and vector of sets, and a single counter to track requests and a single counter to track use.
1 parent 51f8e6a commit cc88e69

File tree

1 file changed

+15
-13
lines changed

1 file changed

+15
-13
lines changed

ggml/src/ggml-vulkan/ggml-vulkan.cpp

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,18 @@ static bool is_pow2(uint32_t x) { return x > 1 && (x & (x-1)) == 0; }
102102

103103
struct ggml_backend_vk_context;
104104

105+
struct vk_queue {
106+
uint32_t queue_family_index;
107+
vk::Queue queue;
108+
vk::CommandPool pool;
109+
uint32_t cmd_buffer_idx;
110+
std::vector<vk::CommandBuffer> cmd_buffers;
111+
112+
vk::PipelineStageFlags stage_flags;
113+
114+
bool transfer_only;
115+
};
116+
105117
#define MAX_PARAMETER_COUNT 8
106118

107119
struct vk_pipeline_struct {
@@ -988,13 +1000,6 @@ struct ggml_backend_vk_context {
9881000
std::vector<vk::DescriptorSet> descriptor_sets;
9891001
uint32_t descriptor_set_idx {};
9901002
uint32_t pipeline_descriptor_set_requirements {};
991-
992-
vk_command_pool compute_cmd_pool;
993-
vk_command_pool transfer_cmd_pool;
994-
995-
// number of additional consecutive nodes that are being fused with the
996-
// node currently being processed
997-
uint32_t num_additional_fused_ops {};
9981003
};
9991004

10001005
static void * const vk_ptr_base = (void *)(uintptr_t) 0x1000; // NOLINT
@@ -1280,7 +1285,7 @@ static void ggml_pipeline_allocate_descriptor_sets(ggml_backend_vk_context * ctx
12801285
}
12811286
}
12821287

1283-
static vk::CommandBuffer ggml_vk_create_cmd_buffer(vk_device& device, vk_command_pool& p) {
1288+
static vk::CommandBuffer ggml_vk_create_cmd_buffer(vk_device& device, vk_queue& q) {
12841289
VK_LOG_DEBUG("ggml_vk_create_cmd_buffer()");
12851290

12861291
if (p.cmd_buffers.size() > p.cmd_buffer_idx) {
@@ -9409,8 +9414,8 @@ static void ggml_vk_graph_cleanup(ggml_backend_vk_context * ctx) {
94099414
}
94109415
ctx->gc.temp_buffers.clear();
94119416

9412-
ggml_vk_command_pool_cleanup(ctx->device, ctx->compute_cmd_pool);
9413-
ggml_vk_command_pool_cleanup(ctx->device, ctx->transfer_cmd_pool);
9417+
ggml_vk_queue_cleanup(ctx->device, ctx->device->compute_queue);
9418+
ggml_vk_queue_cleanup(ctx->device, ctx->device->transfer_queue);
94149419

94159420
for (size_t i = 0; i < ctx->gc.semaphores.size(); i++) {
94169421
ctx->device->device.destroySemaphore({ ctx->gc.semaphores[i].s });
@@ -9465,9 +9470,6 @@ static void ggml_vk_cleanup(ggml_backend_vk_context * ctx) {
94659470
}
94669471
ctx->descriptor_pools.clear();
94679472
ctx->descriptor_sets.clear();
9468-
9469-
ctx->compute_cmd_pool.destroy(ctx->device->device);
9470-
ctx->transfer_cmd_pool.destroy(ctx->device->device);
94719473
}
94729474

94739475
static int ggml_vk_get_device_count() {

0 commit comments

Comments
 (0)