Skip to content

Commit 13a068e

Browse files
committed
Vulkan: Add VK_AMD_shader_core_properties2 support to read Compute Unit count for split_k logic
1 parent 56c67df commit 13a068e

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1974,6 +1974,7 @@ static vk_device ggml_vk_get_device(size_t idx) {
19741974
bool fp16_compute = false;
19751975
bool maintenance4_support = false;
19761976
bool sm_builtins = false;
1977+
bool amd_shader_core_properties2 = false;
19771978
bool pipeline_robustness = false;
19781979
bool coopmat2_support = false;
19791980
device->coopmat_support = false;
@@ -1988,6 +1989,8 @@ static vk_device ggml_vk_get_device(size_t idx) {
19881989
fp16_compute = true;
19891990
} else if (strcmp("VK_NV_shader_sm_builtins", properties.extensionName) == 0) {
19901991
sm_builtins = true;
1992+
} else if (strcmp("VK_AMD_shader_core_properties2", properties.extensionName) == 0) {
1993+
amd_shader_core_properties2 = true;
19911994
} else if (strcmp("VK_EXT_pipeline_robustness", properties.extensionName) == 0) {
19921995
pipeline_robustness = true;
19931996
} else if (strcmp("VK_KHR_cooperative_matrix", properties.extensionName) == 0) {
@@ -2006,6 +2009,7 @@ static vk_device ggml_vk_get_device(size_t idx) {
20062009
vk::PhysicalDeviceMaintenance4Properties props4;
20072010
vk::PhysicalDeviceSubgroupProperties subgroup_props;
20082011
vk::PhysicalDeviceShaderSMBuiltinsPropertiesNV sm_props;
2012+
vk::PhysicalDeviceShaderCoreProperties2AMD amd_shader_core_properties2_props;
20092013
props2.pNext = &props3;
20102014
props3.pNext = &subgroup_props;
20112015

@@ -2019,6 +2023,10 @@ static vk_device ggml_vk_get_device(size_t idx) {
20192023
last_struct->pNext = (VkBaseOutStructure *)&sm_props;
20202024
last_struct = (VkBaseOutStructure *)&sm_props;
20212025
}
2026+
if (amd_shader_core_properties2) {
2027+
last_struct->pNext = (VkBaseOutStructure *)&amd_shader_core_properties2_props;
2028+
last_struct = (VkBaseOutStructure *)&amd_shader_core_properties2_props;
2029+
}
20222030

20232031
#if defined(VK_NV_cooperative_matrix2)
20242032
vk::PhysicalDeviceCooperativeMatrix2PropertiesNV coopmat2_props;
@@ -2046,6 +2054,8 @@ static vk_device ggml_vk_get_device(size_t idx) {
20462054
device->uma = device->properties.deviceType == vk::PhysicalDeviceType::eIntegratedGpu;
20472055
if (sm_builtins) {
20482056
device->shader_core_count = sm_props.shaderSMCount;
2057+
} else if (amd_shader_core_properties2) {
2058+
device->shader_core_count = amd_shader_core_properties2_props.activeComputeUnitCount;
20492059
} else {
20502060
device->shader_core_count = 0;
20512061
}
@@ -2314,6 +2324,7 @@ static vk_device ggml_vk_get_device(size_t idx) {
23142324
// Shaders
23152325
// Disable matmul tile sizes early if performance low or not supported
23162326
switch (device->vendor_id) {
2327+
#ifndef GGML_VULKAN_RUN_TESTS
23172328
case VK_VENDOR_ID_AMD:
23182329
case VK_VENDOR_ID_INTEL:
23192330
device->mul_mat_l = false;
@@ -2331,6 +2342,7 @@ static vk_device ggml_vk_get_device(size_t idx) {
23312342
device->mul_mat_id_m = true;
23322343
device->mul_mat_id_s = false;
23332344
break;
2345+
#endif
23342346
default:
23352347
device->mul_mat_l = true;
23362348
device->mul_mat_m = true;

0 commit comments

Comments
 (0)