Skip to content

Commit

Permalink
metal : fix build when MTLGPUFamilyApple3 is not available
Browse files Browse the repository at this point in the history
ggml-ci
  • Loading branch information
ggerganov committed Oct 6, 2024
1 parent 4b161bc commit 6dcb899
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions ggml/src/ggml-metal.m
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@

// globals

// overload of MTLGPUFamilyMetal3 (not available in some environments)
static const NSInteger MTLGPUFamilyMetal3_GGML = 5001;

// initialized in ggml_backend_metal_reg
static struct ggml_backend_reg g_ggml_backend_metal_reg;
static struct ggml_backend_device g_ggml_backend_metal_device;
Expand All @@ -46,7 +49,7 @@
g_state.mtl_device = MTLCreateSystemDefaultDevice();

g_state.support_simdgroup_reduction = [g_state.mtl_device supportsFamily:MTLGPUFamilyApple7];
g_state.support_simdgroup_reduction |= [g_state.mtl_device supportsFamily:MTLGPUFamilyMetal3];
g_state.support_simdgroup_reduction |= [g_state.mtl_device supportsFamily:MTLGPUFamilyMetal3_GGML];

g_state.support_simdgroup_mm = [g_state.mtl_device supportsFamily:MTLGPUFamilyApple7];
}
Expand Down Expand Up @@ -442,8 +445,6 @@ @implementation GGMLMetalClass
// print MTL GPU family:
GGML_LOG_INFO("%s: GPU name: %s\n", __func__, [[ctx->device name] UTF8String]);

const NSInteger MTLGPUFamilyMetal3 = 5001;

// determine max supported GPU family
// https://developer.apple.com/metal/Metal-Shading-Language-Specification.pdf
// https://developer.apple.com/metal/Metal-Feature-Set-Tables.pdf
Expand All @@ -462,9 +463,9 @@ @implementation GGMLMetalClass
}
}

for (int i = MTLGPUFamilyMetal3 + 5; i >= MTLGPUFamilyMetal3; --i) {
for (int i = MTLGPUFamilyMetal3_GGML + 5; i >= MTLGPUFamilyMetal3_GGML; --i) {
if ([ctx->device supportsFamily:i]) {
GGML_LOG_INFO("%s: GPU family: MTLGPUFamilyMetal%d (%d)\n", __func__, i - (int) MTLGPUFamilyMetal3 + 3, i);
GGML_LOG_INFO("%s: GPU family: MTLGPUFamilyMetal%d (%d)\n", __func__, i - (int) MTLGPUFamilyMetal3_GGML + 3, i);
break;
}
}
Expand Down

0 comments on commit 6dcb899

Please sign in to comment.