diff --git a/CMakeLists.txt b/CMakeLists.txt index e0436acd999..527603c0002 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -90,6 +90,9 @@ option(LLAMA_MTMD "llama: multimodal support" ${LLAMA_BUILD_TOOLS}) option(LLAMA_CURL "llama: use libcurl to download model from an URL" ON) option(LLAMA_LLGUIDANCE "llama-common: include LLGuidance library for structured output in common utils" OFF) +# profiling +option(FORCE_GGML_VK_PERF_LOGGER "Force vk performance logging in ggml" OFF) + # Required for relocatable CMake package include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/build-info.cmake) include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/common.cmake) diff --git a/ggml/src/ggml-vulkan/CMakeLists.txt b/ggml/src/ggml-vulkan/CMakeLists.txt index 519c93c9cc8..67007bdb693 100644 --- a/ggml/src/ggml-vulkan/CMakeLists.txt +++ b/ggml/src/ggml-vulkan/CMakeLists.txt @@ -92,6 +92,9 @@ if (Vulkan_FOUND) target_include_directories(ggml-vulkan PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) target_include_directories(ggml-vulkan PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/vulkan_cpp_wrapper/include") + if (FORCE_GGML_VK_PERF_LOGGER) + add_compile_definitions(FORCE_GGML_VK_PERF_LOGGER) + endif() # Workaround to the "can't dereference invalidated vector iterator" bug in clang-cl debug build # Posssibly relevant: https://stackoverflow.com/questions/74748276/visual-studio-no-displays-the-correct-length-of-stdvector if (MSVC AND CMAKE_CXX_COMPILER_ID STREQUAL "Clang") diff --git a/ggml/src/ggml-vulkan/ggml-vulkan.cpp b/ggml/src/ggml-vulkan/ggml-vulkan.cpp index 540254f31da..264d0867c24 100644 --- a/ggml/src/ggml-vulkan/ggml-vulkan.cpp +++ b/ggml/src/ggml-vulkan/ggml-vulkan.cpp @@ -4486,7 +4486,11 @@ static void ggml_vk_instance_init() { vk_instance.pfn_vkCmdInsertDebugUtilsLabelEXT = (PFN_vkCmdInsertDebugUtilsLabelEXT) vkGetInstanceProcAddr(vk_instance.instance, "vkCmdInsertDebugUtilsLabelEXT"); } +#ifndef FORCE_GGML_VK_PERF_LOGGER vk_perf_logger_enabled = getenv("GGML_VK_PERF_LOGGER") != nullptr; +#else + vk_perf_logger_enabled = true; +#endif std::vector devices = vk_instance.instance.enumeratePhysicalDevices();