Skip to content

Commit 10d2f66

Browse files
jeffbolznvMinh141120
authored andcommitted
vulkan: lock accesses of pinned_memory vector (ggml-org#14333)
1 parent 2ae4c3b commit 10d2f66

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4487,7 +4487,7 @@ static void ggml_vk_buffer_write_2d(vk_buffer& dst, size_t offset, const void *
44874487
memcpy((uint8_t *)dst->ptr + offset + i * width, (const uint8_t *) src + i * spitch, width);
44884488
}
44894489
} else {
4490-
std::lock_guard<std::mutex> guard(dst->device->mutex);
4490+
std::lock_guard<std::recursive_mutex> guard(dst->device->mutex);
44914491

44924492
vk_context subctx = ggml_vk_create_temporary_context(dst->device->transfer_queue.cmd_pool);
44934493
ggml_vk_ctx_begin(dst->device, subctx);
@@ -4578,7 +4578,7 @@ static void ggml_vk_buffer_read(vk_buffer& src, size_t offset, void * dst, size_
45784578

45794579
memcpy(dst, (uint8_t *) src->ptr + offset, size);
45804580
} else {
4581-
std::lock_guard<std::mutex> guard(src->device->mutex);
4581+
std::lock_guard<std::recursive_mutex> guard(src->device->mutex);
45824582

45834583
vk_context subctx = ggml_vk_create_temporary_context(src->device->transfer_queue.cmd_pool);
45844584
ggml_vk_ctx_begin(src->device, subctx);
@@ -4608,7 +4608,7 @@ static void ggml_vk_buffer_copy_async(vk_context& ctx, vk_buffer& dst, size_t ds
46084608

46094609
static void ggml_vk_buffer_copy(vk_buffer& dst, size_t dst_offset, vk_buffer& src, size_t src_offset, size_t size) {
46104610
if (src->device == dst->device) {
4611-
std::lock_guard<std::mutex> guard(src->device->mutex);
4611+
std::lock_guard<std::recursive_mutex> guard(src->device->mutex);
46124612
VK_LOG_DEBUG("ggml_vk_buffer_copy(SINGLE_DEVICE, " << size << ")");
46134613
// Copy within the device
46144614
vk_context subctx = ggml_vk_create_temporary_context(src->device->transfer_queue.cmd_pool);
@@ -4644,7 +4644,7 @@ static void ggml_vk_buffer_memset_async(vk_context& ctx, vk_buffer& dst, size_t
46444644
static void ggml_vk_buffer_memset(vk_buffer& dst, size_t offset, uint32_t c, size_t size) {
46454645
VK_LOG_DEBUG("ggml_vk_buffer_memset(" << offset << ", " << c << ", " << size << ")");
46464646

4647-
std::lock_guard<std::mutex> guard(dst->device->mutex);
4647+
std::lock_guard<std::recursive_mutex> guard(dst->device->mutex);
46484648
vk_context subctx = ggml_vk_create_temporary_context(dst->device->transfer_queue.cmd_pool);
46494649
ggml_vk_ctx_begin(dst->device, subctx);
46504650
subctx->s->buffer.fillBuffer(dst->buffer, offset, size, c);

0 commit comments

Comments
 (0)