tmp: diagnostics for register_host pinning path

This commit is contained in:
2026-07-15 01:57:07 +02:00
parent ad3e8a3dc3
commit 9b0e7052fb
+8 -1
View File
@@ -3173,6 +3173,7 @@ static vk_buffer ggml_vk_create_buffer(vk_device& device, size_t size, const std
import_info.setPNext(&mem_flags_info); import_info.setPNext(&mem_flags_info);
buf->device_memory = device->device.allocateMemory({ size, memory_type_idx, &import_info }); buf->device_memory = device->device.allocateMemory({ size, memory_type_idx, &import_info });
} catch (const vk::SystemError& e) { } catch (const vk::SystemError& e) {
fprintf(stderr, "PROBE import allocateMemory threw: %s\n", e.what());
} }
} else { } else {
for (auto it = req_flags_list.begin(); it != req_flags_list.end(); it++) { for (auto it = req_flags_list.begin(); it != req_flags_list.end(); it++) {
@@ -17812,14 +17813,17 @@ static void ggml_backend_vk_device_event_synchronize(ggml_backend_dev_t dev, ggm
static vk_buffer ggml_vk_buffer_from_host_ptr(vk_device & device, void * ptr, size_t size) { static vk_buffer ggml_vk_buffer_from_host_ptr(vk_device & device, void * ptr, size_t size) {
if (!device->external_memory_host) { if (!device->external_memory_host) {
fprintf(stderr, "PROBE from_host_ptr: ext_mem_host disabled\n");
return {}; return {};
} }
uintptr_t uptr = reinterpret_cast<uintptr_t>(ptr); uintptr_t uptr = reinterpret_cast<uintptr_t>(ptr);
if (uptr & (device->min_imported_host_pointer_alignment - 1)) { if (uptr & (device->min_imported_host_pointer_alignment - 1)) {
fprintf(stderr, "PROBE from_host_ptr: ptr %p not aligned to %zu\n", ptr, device->min_imported_host_pointer_alignment);
return {}; return {};
} }
if (size & (device->min_imported_host_pointer_alignment - 1)) { if (size & (device->min_imported_host_pointer_alignment - 1)) {
fprintf(stderr, "PROBE from_host_ptr: size %zu not aligned to %zu\n", size, device->min_imported_host_pointer_alignment);
return {}; return {};
} }
@@ -17829,9 +17833,10 @@ static vk_buffer ggml_vk_buffer_from_host_ptr(vk_device & device, void * ptr, si
try { try {
buf = ggml_vk_create_buffer(device, size, { property_flags }, ptr); buf = ggml_vk_create_buffer(device, size, { property_flags }, ptr);
} catch (vk::SystemError& e) { } catch (vk::SystemError& e) {
GGML_LOG_WARN("ggml_vulkan: Failed ggml_vk_create_buffer (%s)\n", e.what()); fprintf(stderr, "PROBE from_host_ptr: create_buffer threw (%s)\n", e.what());
} }
fprintf(stderr, "PROBE from_host_ptr: ptr=%p size=%zu -> buf=%p buf->buffer=%p\n", ptr, size, buf.get(), buf ? (void*)buf->buffer.operator VkBuffer() : nullptr);
return buf; return buf;
} }
@@ -17923,6 +17928,8 @@ static ggml_backend_dev_t ggml_backend_vk_reg_get_device(ggml_backend_reg_t reg,
// GGML_CUDA_REGISTER_HOST path; populates device->pinned_memory, which the // GGML_CUDA_REGISTER_HOST path; populates device->pinned_memory, which the
// existing pinned fast path in ggml_vk_buffer_write_2d_async looks up. // existing pinned fast path in ggml_vk_buffer_write_2d_async looks up.
static bool ggml_backend_vk_register_host_buffer(void * buffer, size_t size) { static bool ggml_backend_vk_register_host_buffer(void * buffer, size_t size) {
fprintf(stderr, "PROBE register_host CALLED buffer=%p size=%zu cuda_env=%d vk_env=%d\n", buffer, size,
getenv("GGML_CUDA_REGISTER_HOST") != nullptr, getenv("GGML_VK_REGISTER_HOST") != nullptr);
if (getenv("GGML_CUDA_REGISTER_HOST") == nullptr && getenv("GGML_VK_REGISTER_HOST") == nullptr) { if (getenv("GGML_CUDA_REGISTER_HOST") == nullptr && getenv("GGML_VK_REGISTER_HOST") == nullptr) {
return false; return false;
} }