@@ -23,32 +23,40 @@ if (Vulkan_FOUND)
23
23
../../include /ggml-vulkan.h
24
24
)
25
25
26
- # Compile a test shader to determine whether GL_KHR_cooperative_matrix is supported.
27
- # If it's not, there will be an error to stderr.
28
- # If it's supported, set a define to indicate that we should compile those shaders
29
- execute_process (COMMAND ${Vulkan_GLSLC_EXECUTABLE} -o - -fshader-stage=compute --target -env=vulkan1.3 "${CMAKE_CURRENT_SOURCE_DIR} /vulkan-shaders/test_coopmat_support.comp"
30
- OUTPUT_VARIABLE glslc_output
31
- ERROR_VARIABLE glslc_error)
32
-
33
- if (${glslc_error} MATCHES ".*extension not supported: GL_KHR_cooperative_matrix.*" )
34
- message (STATUS "GL_KHR_cooperative_matrix not supported by glslc" )
35
- else ()
36
- message (STATUS "GL_KHR_cooperative_matrix supported by glslc" )
37
- add_compile_definitions (GGML_VULKAN_COOPMAT_GLSLC_SUPPORT)
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 ()
38
42
endif ()
39
43
40
- # Compile a test shader to determine whether GL_NV_cooperative_matrix2 is supported.
41
- # If it's not, there will be an error to stderr.
42
- # If it's supported, set a define to indicate that we should compile those shaders
43
- execute_process (COMMAND ${Vulkan_GLSLC_EXECUTABLE} -o - -fshader-stage=compute --target -env=vulkan1.3 "${CMAKE_CURRENT_SOURCE_DIR} /vulkan-shaders/test_coopmat2_support.comp"
44
- OUTPUT_VARIABLE glslc_output
45
- ERROR_VARIABLE glslc_error)
46
-
47
- if (${glslc_error} MATCHES ".*extension not supported: GL_NV_cooperative_matrix2.*" )
48
- message (STATUS "GL_NV_cooperative_matrix2 not supported by glslc" )
49
- else ()
50
- message (STATUS "GL_NV_cooperative_matrix2 supported by glslc" )
51
- add_compile_definitions (GGML_VULKAN_COOPMAT2_GLSLC_SUPPORT)
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 ()
52
60
endif ()
53
61
54
62
target_link_libraries (ggml-vulkan PRIVATE Vulkan::Vulkan)
@@ -119,6 +127,8 @@ if (Vulkan_FOUND)
119
127
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR} /vulkan-shaders
120
128
CMAKE_ARGS -DCMAKE_TOOLCHAIN_FILE=${HOST_CMAKE_TOOLCHAIN_FILE}
121
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}
122
132
BUILD_COMMAND ${CMAKE_COMMAND} --build .
123
133
INSTALL_COMMAND ${CMAKE_COMMAND} --install .
124
134
INSTALL_DIR ${CMAKE_BINARY_DIR}
0 commit comments