1+ #ifndef GGML_VULKAN_COOPMAT_GLSLC_SUPPORT
2+ #define GGML_VULKAN_COOPMAT_GLSLC_SUPPORT
3+ #endif
4+
15#include " ggml-vulkan.h"
26#include < vulkan/vulkan_core.h>
37#if defined(GGML_VULKAN_RUN_TESTS) || defined(GGML_VULKAN_PERF) || defined(GGML_VULKAN_CHECK_RESULTS)
@@ -1645,6 +1649,7 @@ static void ggml_vk_load_shaders(vk_device& device) {
16451649#undef CREATE_MM2
16461650 } else
16471651#endif // defined(VK_NV_cooperative_matrix2) && defined(GGML_VULKAN_COOPMAT2_GLSLC_SUPPORT)
1652+ #if defined(VK_KHR_cooperative_matrix) && defined(GGML_VULKAN_COOPMAT_GLSLC_SUPPORT)
16481653 if (device->coopmat_support ) {
16491654 // Create 6 variants, {s,m,l}x{unaligned,aligned}
16501655#define CREATE_MM (PIPELINE_NAME, NAMELC, F16ACC, WG_DENOMS, WARPTILE, PUSHCONST, PARAMCOUNT, ID ) \
@@ -1739,7 +1744,9 @@ static void ggml_vk_load_shaders(vk_device& device) {
17391744 }
17401745#undef CREATE_MM2
17411746#undef CREATE_MM
1742- } else if (device->fp16 ) {
1747+ } else
1748+ #endif // defined(VK_KHR_cooperative_matrix) && defined(GGML_VULKAN_COOPMAT_GLSLC_SUPPORT)
1749+ if (device->fp16 ) {
17431750 // Create 6 variants, {s,m,l}x{unaligned,aligned}
17441751#define CREATE_MM (PIPELINE_NAME, NAMELC, F16ACC, WG_DENOMS, WARPTILE, PUSHCONST, PARAMCOUNT, ID ) \
17451752 if (device->mul_mat ## ID ## _l) \
@@ -2242,6 +2249,7 @@ static vk_device ggml_vk_get_device(size_t idx) {
22422249 last_struct = (VkBaseOutStructure *)&subgroup_size_control_features;
22432250 }
22442251
2252+ #if defined(VK_KHR_cooperative_matrix)
22452253 VkPhysicalDeviceCooperativeMatrixFeaturesKHR coopmat_features;
22462254 coopmat_features.pNext = nullptr ;
22472255 coopmat_features.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_COOPERATIVE_MATRIX_FEATURES_KHR;
@@ -2251,6 +2259,7 @@ static vk_device ggml_vk_get_device(size_t idx) {
22512259 last_struct->pNext = (VkBaseOutStructure *)&coopmat_features;
22522260 last_struct = (VkBaseOutStructure *)&coopmat_features;
22532261 }
2262+ #endif
22542263
22552264#if defined(VK_NV_cooperative_matrix2)
22562265 VkPhysicalDeviceCooperativeMatrix2FeaturesNV coopmat2_features {};
@@ -2283,7 +2292,9 @@ static vk_device ggml_vk_get_device(size_t idx) {
22832292 device_extensions.push_back (" VK_EXT_subgroup_size_control" );
22842293 }
22852294
2295+ #if defined(VK_KHR_cooperative_matrix)
22862296 device->coopmat_support = device->coopmat_support && coopmat_features.cooperativeMatrix ;
2297+ #endif
22872298
22882299 if (coopmat2_support) {
22892300#if defined(VK_NV_cooperative_matrix2) && defined(GGML_VULKAN_COOPMAT2_GLSLC_SUPPORT)
@@ -2376,6 +2387,7 @@ static vk_device ggml_vk_get_device(size_t idx) {
23762387 device_extensions.push_back (" VK_KHR_shader_float16_int8" );
23772388 }
23782389
2390+ #if defined(VK_KHR_cooperative_matrix)
23792391 if (device->coopmat_support ) {
23802392 // Query supported shapes
23812393 std::vector<VkCooperativeMatrixPropertiesKHR> cm_props;
@@ -2442,7 +2454,7 @@ static vk_device ggml_vk_get_device(size_t idx) {
24422454 if (device->coopmat_support ) {
24432455 device_extensions.push_back (" VK_KHR_cooperative_matrix" );
24442456 }
2445-
2457+ # endif
24462458 device->name = GGML_VK_NAME + std::to_string (idx);
24472459
24482460 device_create_info = {
@@ -2553,9 +2565,11 @@ static void ggml_vk_print_gpu_info(size_t idx) {
25532565 fp16_storage = true ;
25542566 } else if (strcmp (" VK_KHR_shader_float16_int8" , properties.extensionName ) == 0 ) {
25552567 fp16_compute = true ;
2556- } else if (strcmp (" VK_KHR_cooperative_matrix" , properties.extensionName ) == 0 &&
2568+ #if defined(GGML_VULKAN_COOPMAT_GLSLC_SUPPORT)
2569+ } else if (strcmp (" VK_KHR_cooperative_matrix" , properties.extensionName ) == 0 &&
25572570 !getenv (" GGML_VK_DISABLE_COOPMAT" )) {
25582571 coopmat_support = true ;
2572+ #endif
25592573#if defined(GGML_VULKAN_COOPMAT2_GLSLC_SUPPORT)
25602574 } else if (strcmp (" VK_NV_cooperative_matrix2" , properties.extensionName ) == 0 &&
25612575 !getenv (" GGML_VK_DISABLE_COOPMAT2" )) {
@@ -2593,6 +2607,7 @@ static void ggml_vk_print_gpu_info(size_t idx) {
25932607 // Pointer to the last chain element
25942608 VkBaseOutStructure * last_struct = (VkBaseOutStructure *)&vk12_features;
25952609
2610+ #if defined(GGML_VULKAN_COOPMAT_GLSLC_SUPPORT)
25962611 VkPhysicalDeviceCooperativeMatrixFeaturesKHR coopmat_features;
25972612 coopmat_features.pNext = nullptr ;
25982613 coopmat_features.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_COOPERATIVE_MATRIX_FEATURES_KHR;
@@ -2608,6 +2623,7 @@ static void ggml_vk_print_gpu_info(size_t idx) {
26082623 fp16 = fp16 && vk12_features.shaderFloat16 ;
26092624
26102625 coopmat_support = coopmat_support && coopmat_features.cooperativeMatrix ;
2626+ #endif
26112627
26122628 std::string matrix_cores = coopmat2_support ? " NV_coopmat2" : coopmat_support ? " KHR_coopmat" : " none" ;
26132629
0 commit comments