Spaces:
Running
Running
Icenowy Zheng
bandoti
commited on
Commit
·
7585c4a
1
Parent(s):
1843f18
vulkan: fix coopmat shader generation when cross-compiling (llama/12272)
Browse files* vulkan: fix coopmat shader generation when cross-compiling
Previously the status of coopmat{,2} support isn't passed to the
vulkan-shaders-gen project building on the host, which leads to build
failure because of the cross-compiling code expecting coopmat{,2}
shaders that didn't get generated.
Fix this by passing the coopmat{,2} support status to vulkan-shaders
subproject.
Signed-off-by: Icenowy Zheng <[email protected]>
* Only call coop-mat shaders once
* Fix whitespace
---------
Signed-off-by: Icenowy Zheng <[email protected]>
Co-authored-by: bandoti <[email protected]>
ggml/src/ggml-vulkan/CMakeLists.txt
CHANGED
|
@@ -23,32 +23,40 @@ if (Vulkan_FOUND)
|
|
| 23 |
../../include/ggml-vulkan.h
|
| 24 |
)
|
| 25 |
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 38 |
endif()
|
| 39 |
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 52 |
endif()
|
| 53 |
|
| 54 |
target_link_libraries(ggml-vulkan PRIVATE Vulkan::Vulkan)
|
|
@@ -119,6 +127,8 @@ if (Vulkan_FOUND)
|
|
| 119 |
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/vulkan-shaders
|
| 120 |
CMAKE_ARGS -DCMAKE_TOOLCHAIN_FILE=${HOST_CMAKE_TOOLCHAIN_FILE}
|
| 121 |
-DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}
|
|
|
|
|
|
|
| 122 |
BUILD_COMMAND ${CMAKE_COMMAND} --build .
|
| 123 |
INSTALL_COMMAND ${CMAKE_COMMAND} --install .
|
| 124 |
INSTALL_DIR ${CMAKE_BINARY_DIR}
|
|
|
|
| 23 |
../../include/ggml-vulkan.h
|
| 24 |
)
|
| 25 |
|
| 26 |
+
if(NOT DEFINED GGML_VULKAN_COOPMAT_GLSLC_SUPPORT)
|
| 27 |
+
# Compile a test shader to determine whether GL_KHR_cooperative_matrix is supported.
|
| 28 |
+
# If it's not, there will be an error to stderr.
|
| 29 |
+
# If it's supported, set a define to indicate that we should compile those shaders
|
| 30 |
+
execute_process(COMMAND ${Vulkan_GLSLC_EXECUTABLE} -o - -fshader-stage=compute --target-env=vulkan1.3 "${CMAKE_CURRENT_SOURCE_DIR}/vulkan-shaders/test_coopmat_support.comp"
|
| 31 |
+
OUTPUT_VARIABLE glslc_output
|
| 32 |
+
ERROR_VARIABLE glslc_error)
|
| 33 |
+
|
| 34 |
+
if (${glslc_error} MATCHES ".*extension not supported: GL_KHR_cooperative_matrix.*")
|
| 35 |
+
message(STATUS "GL_KHR_cooperative_matrix not supported by glslc")
|
| 36 |
+
set(GGML_VULKAN_COOPMAT_GLSLC_SUPPORT OFF CACHE INTERNAL "Whether coopmat is supported by glslc")
|
| 37 |
+
else()
|
| 38 |
+
message(STATUS "GL_KHR_cooperative_matrix supported by glslc")
|
| 39 |
+
add_compile_definitions(GGML_VULKAN_COOPMAT_GLSLC_SUPPORT)
|
| 40 |
+
set(GGML_VULKAN_COOPMAT_GLSLC_SUPPORT ON CACHE INTERNAL "Whether coopmat is supported by glslc")
|
| 41 |
+
endif()
|
| 42 |
endif()
|
| 43 |
|
| 44 |
+
if(NOT DEFINED GGML_VULKAN_COOPMAT2_GLSLC_SUPPORT)
|
| 45 |
+
# Compile a test shader to determine whether GL_NV_cooperative_matrix2 is supported.
|
| 46 |
+
# If it's not, there will be an error to stderr.
|
| 47 |
+
# If it's supported, set a define to indicate that we should compile those shaders
|
| 48 |
+
execute_process(COMMAND ${Vulkan_GLSLC_EXECUTABLE} -o - -fshader-stage=compute --target-env=vulkan1.3 "${CMAKE_CURRENT_SOURCE_DIR}/vulkan-shaders/test_coopmat2_support.comp"
|
| 49 |
+
OUTPUT_VARIABLE glslc_output
|
| 50 |
+
ERROR_VARIABLE glslc_error)
|
| 51 |
+
|
| 52 |
+
if (${glslc_error} MATCHES ".*extension not supported: GL_NV_cooperative_matrix2.*")
|
| 53 |
+
message(STATUS "GL_NV_cooperative_matrix2 not supported by glslc")
|
| 54 |
+
set(GGML_VULKAN_COOPMAT2_GLSLC_SUPPORT OFF CACHE INTERNAL "Whether coopmat2 is supported by glslc")
|
| 55 |
+
else()
|
| 56 |
+
message(STATUS "GL_NV_cooperative_matrix2 supported by glslc")
|
| 57 |
+
add_compile_definitions(GGML_VULKAN_COOPMAT2_GLSLC_SUPPORT)
|
| 58 |
+
set(GGML_VULKAN_COOPMAT2_GLSLC_SUPPORT ON CACHE INTERNAL "Whether coopmat2 is supported by glslc")
|
| 59 |
+
endif()
|
| 60 |
endif()
|
| 61 |
|
| 62 |
target_link_libraries(ggml-vulkan PRIVATE Vulkan::Vulkan)
|
|
|
|
| 127 |
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/vulkan-shaders
|
| 128 |
CMAKE_ARGS -DCMAKE_TOOLCHAIN_FILE=${HOST_CMAKE_TOOLCHAIN_FILE}
|
| 129 |
-DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}
|
| 130 |
+
-DGGML_VULKAN_COOPMAT_GLSLC_SUPPORT=${GGML_VULKAN_COOPMAT_GLSLC_SUPPORT}
|
| 131 |
+
-DGGML_VULKAN_COOPMAT2_GLSLC_SUPPORT=${GGML_VULKAN_COOPMAT2_GLSLC_SUPPORT}
|
| 132 |
BUILD_COMMAND ${CMAKE_COMMAND} --build .
|
| 133 |
INSTALL_COMMAND ${CMAKE_COMMAND} --install .
|
| 134 |
INSTALL_DIR ${CMAKE_BINARY_DIR}
|
ggml/src/ggml-vulkan/vulkan-shaders/CMakeLists.txt
CHANGED
|
@@ -1,5 +1,11 @@
|
|
| 1 |
find_package (Threads REQUIRED)
|
| 2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
set(TARGET vulkan-shaders-gen)
|
| 4 |
add_executable(${TARGET} vulkan-shaders-gen.cpp)
|
| 5 |
install(TARGETS ${TARGET} RUNTIME)
|
|
|
|
| 1 |
find_package (Threads REQUIRED)
|
| 2 |
|
| 3 |
+
if (GGML_VULKAN_COOPMAT_GLSLC_SUPPORT)
|
| 4 |
+
add_compile_definitions(GGML_VULKAN_COOPMAT_GLSLC_SUPPORT)
|
| 5 |
+
endif()
|
| 6 |
+
if (GGML_VULKAN_COOPMAT2_GLSLC_SUPPORT)
|
| 7 |
+
add_compile_definitions(GGML_VULKAN_COOPMAT2_GLSLC_SUPPORT)
|
| 8 |
+
endif()
|
| 9 |
set(TARGET vulkan-shaders-gen)
|
| 10 |
add_executable(${TARGET} vulkan-shaders-gen.cpp)
|
| 11 |
install(TARGETS ${TARGET} RUNTIME)
|