Skip to content

Commit a05e2af

Browse files
authored
vulkan: disable spirv-opt for coopmat shaders (#10763)
There are some bugs in the 1.3.296 SDK, so disable this. It isn't strictly necessary anyway. Add missing dependency on vulkan-shaders-gen, so shaders get recompiled when it changes. Fix coopmat support reporting when glslc doesn't support NV_coopmat2.
1 parent 26a8406 commit a05e2af

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

ggml/src/ggml-vulkan/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ if (Vulkan_FOUND)
8181
--target-cpp ${_ggml_vk_source}
8282
--no-clean
8383

84-
DEPENDS ${_ggml_vk_shader_deps}
84+
DEPENDS ${_ggml_vk_shader_deps} ${_ggml_vk_genshaders_cmd}
8585
COMMENT "Generate vulkan shaders"
8686
)
8787

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2425,9 +2425,11 @@ static void ggml_vk_print_gpu_info(size_t idx) {
24252425
} else if (strcmp("VK_KHR_cooperative_matrix", properties.extensionName) == 0 &&
24262426
!getenv("GGML_VK_DISABLE_COOPMAT")) {
24272427
coopmat_support = true;
2428+
#if defined(GGML_VULKAN_COOPMAT2_GLSLC_SUPPORT)
24282429
} else if (strcmp("VK_NV_cooperative_matrix2", properties.extensionName) == 0 &&
24292430
!getenv("GGML_VK_DISABLE_COOPMAT2")) {
24302431
coopmat2_support = true;
2432+
#endif
24312433
}
24322434
}
24332435

ggml/src/ggml-vulkan/vulkan-shaders/vulkan-shaders-gen.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,10 +206,13 @@ void string_to_spv_func(const std::string& _name, const std::string& in_fname, c
206206

207207
std::string target_env = (name.find("_cm2") != std::string::npos) ? "--target-env=vulkan1.3" : "--target-env=vulkan1.2";
208208

209+
// disable spirv-opt for coopmat shaders for https://github.com/ggerganov/llama.cpp/issues/10734
210+
std::string opt_level = coopmat ? "" : "-O";
211+
209212
#ifdef _WIN32
210-
std::vector<std::string> cmd = {GLSLC, "-fshader-stage=compute", target_env, "-O", "\"" + in_path + "\"", "-o", "\"" + out_fname + "\""};
213+
std::vector<std::string> cmd = {GLSLC, "-fshader-stage=compute", target_env, opt_level, "\"" + in_path + "\"", "-o", "\"" + out_fname + "\""};
211214
#else
212-
std::vector<std::string> cmd = {GLSLC, "-fshader-stage=compute", target_env, "-O", in_path, "-o", out_fname};
215+
std::vector<std::string> cmd = {GLSLC, "-fshader-stage=compute", target_env, opt_level, in_path, "-o", out_fname};
213216
#endif
214217

215218
#ifdef GGML_VULKAN_SHADER_DEBUG_INFO

0 commit comments

Comments
 (0)