@@ -1645,6 +1645,7 @@ static void ggml_vk_load_shaders(vk_device& device) {
1645
1645
#undef CREATE_MM2
1646
1646
} else
1647
1647
#endif // defined(VK_NV_cooperative_matrix2) && defined(GGML_VULKAN_COOPMAT2_GLSLC_SUPPORT)
1648
+ #if defined(VK_KHR_cooperative_matrix) && defined(GGML_VULKAN_COOPMAT_GLSLC_SUPPORT)
1648
1649
if (device->coopmat_support ) {
1649
1650
// Create 6 variants, {s,m,l}x{unaligned,aligned}
1650
1651
#define CREATE_MM (PIPELINE_NAME, NAMELC, F16ACC, WG_DENOMS, WARPTILE, PUSHCONST, PARAMCOUNT, ID ) \
@@ -1739,7 +1740,9 @@ static void ggml_vk_load_shaders(vk_device& device) {
1739
1740
}
1740
1741
#undef CREATE_MM2
1741
1742
#undef CREATE_MM
1742
- } else if (device->fp16 ) {
1743
+ } else
1744
+ #endif // defined(VK_KHR_cooperative_matrix) && defined(GGML_VULKAN_COOPMAT_GLSLC_SUPPORT)
1745
+ if (device->fp16 ) {
1743
1746
// Create 6 variants, {s,m,l}x{unaligned,aligned}
1744
1747
#define CREATE_MM (PIPELINE_NAME, NAMELC, F16ACC, WG_DENOMS, WARPTILE, PUSHCONST, PARAMCOUNT, ID ) \
1745
1748
if (device->mul_mat ## ID ## _l) \
@@ -2242,6 +2245,7 @@ static vk_device ggml_vk_get_device(size_t idx) {
2242
2245
last_struct = (VkBaseOutStructure *)&subgroup_size_control_features;
2243
2246
}
2244
2247
2248
+ #if defined(VK_KHR_cooperative_matrix)
2245
2249
VkPhysicalDeviceCooperativeMatrixFeaturesKHR coopmat_features;
2246
2250
coopmat_features.pNext = nullptr ;
2247
2251
coopmat_features.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_COOPERATIVE_MATRIX_FEATURES_KHR;
@@ -2251,6 +2255,7 @@ static vk_device ggml_vk_get_device(size_t idx) {
2251
2255
last_struct->pNext = (VkBaseOutStructure *)&coopmat_features;
2252
2256
last_struct = (VkBaseOutStructure *)&coopmat_features;
2253
2257
}
2258
+ #endif
2254
2259
2255
2260
#if defined(VK_NV_cooperative_matrix2)
2256
2261
VkPhysicalDeviceCooperativeMatrix2FeaturesNV coopmat2_features {};
@@ -2283,7 +2288,9 @@ static vk_device ggml_vk_get_device(size_t idx) {
2283
2288
device_extensions.push_back (" VK_EXT_subgroup_size_control" );
2284
2289
}
2285
2290
2291
+ #if defined(VK_KHR_cooperative_matrix)
2286
2292
device->coopmat_support = device->coopmat_support && coopmat_features.cooperativeMatrix ;
2293
+ #endif
2287
2294
2288
2295
if (coopmat2_support) {
2289
2296
#if defined(VK_NV_cooperative_matrix2) && defined(GGML_VULKAN_COOPMAT2_GLSLC_SUPPORT)
@@ -2376,6 +2383,7 @@ static vk_device ggml_vk_get_device(size_t idx) {
2376
2383
device_extensions.push_back (" VK_KHR_shader_float16_int8" );
2377
2384
}
2378
2385
2386
+ #if defined(VK_KHR_cooperative_matrix)
2379
2387
if (device->coopmat_support ) {
2380
2388
// Query supported shapes
2381
2389
std::vector<VkCooperativeMatrixPropertiesKHR> cm_props;
@@ -2442,7 +2450,7 @@ static vk_device ggml_vk_get_device(size_t idx) {
2442
2450
if (device->coopmat_support ) {
2443
2451
device_extensions.push_back (" VK_KHR_cooperative_matrix" );
2444
2452
}
2445
-
2453
+ # endif
2446
2454
device->name = GGML_VK_NAME + std::to_string (idx);
2447
2455
2448
2456
device_create_info = {
@@ -2553,9 +2561,11 @@ static void ggml_vk_print_gpu_info(size_t idx) {
2553
2561
fp16_storage = true ;
2554
2562
} else if (strcmp (" VK_KHR_shader_float16_int8" , properties.extensionName ) == 0 ) {
2555
2563
fp16_compute = true ;
2556
- } else if (strcmp (" VK_KHR_cooperative_matrix" , properties.extensionName ) == 0 &&
2564
+ #if defined(GGML_VULKAN_COOPMAT_GLSLC_SUPPORT)
2565
+ } else if (strcmp (" VK_KHR_cooperative_matrix" , properties.extensionName ) == 0 &&
2557
2566
!getenv (" GGML_VK_DISABLE_COOPMAT" )) {
2558
2567
coopmat_support = true ;
2568
+ #endif
2559
2569
#if defined(GGML_VULKAN_COOPMAT2_GLSLC_SUPPORT)
2560
2570
} else if (strcmp (" VK_NV_cooperative_matrix2" , properties.extensionName ) == 0 &&
2561
2571
!getenv (" GGML_VK_DISABLE_COOPMAT2" )) {
@@ -2593,6 +2603,7 @@ static void ggml_vk_print_gpu_info(size_t idx) {
2593
2603
// Pointer to the last chain element
2594
2604
VkBaseOutStructure * last_struct = (VkBaseOutStructure *)&vk12_features;
2595
2605
2606
+ #if defined(GGML_VULKAN_COOPMAT_GLSLC_SUPPORT)
2596
2607
VkPhysicalDeviceCooperativeMatrixFeaturesKHR coopmat_features;
2597
2608
coopmat_features.pNext = nullptr ;
2598
2609
coopmat_features.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_COOPERATIVE_MATRIX_FEATURES_KHR;
@@ -2608,6 +2619,7 @@ static void ggml_vk_print_gpu_info(size_t idx) {
2608
2619
fp16 = fp16 && vk12_features.shaderFloat16 ;
2609
2620
2610
2621
coopmat_support = coopmat_support && coopmat_features.cooperativeMatrix ;
2622
+ #endif
2611
2623
2612
2624
std::string matrix_cores = coopmat2_support ? " NV_coopmat2" : coopmat_support ? " KHR_coopmat" : " none" ;
2613
2625
0 commit comments