metal : detect more GPU families

This commit is contained in:
Georgi Gerganov 2024-01-06 12:20:09 +02:00
parent 96e80dabc6
commit 2c3ffd2944
No known key found for this signature in database
GPG key ID: 449E073F9DC10735

View file

@ -316,10 +316,23 @@ struct ggml_metal_context * ggml_metal_init(int n_cb) {
// 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
for (int i = MTLGPUFamilyApple1 + 20; i >= MTLGPUFamilyApple1; --i) {
if ([ctx->device supportsFamily:i]) {
GGML_METAL_LOG_INFO("%s: GPU family: MTLGPUFamilyApple%d (%d)\n", __func__, i - (int) MTLGPUFamilyApple1 + 1, i);
break;
{
bool found = false;
for (int i = MTLGPUFamilyApple1 + 20; !found && i >= MTLGPUFamilyApple1; --i) {
if ([ctx->device supportsFamily:i]) {
GGML_METAL_LOG_INFO("%s: GPU family: MTLGPUFamilyApple%d (%d)\n", __func__, i - (int) MTLGPUFamilyApple1 + 1, i);
found = true;
break;
}
}
for (int i = MTLGPUFamilyCommon1 + 5; !found && i >= MTLGPUFamilyCommon1; --i) {
if ([ctx->device supportsFamily:i]) {
GGML_METAL_LOG_INFO("%s: GPU family: MTLGPUFamilyCommon%d (%d)\n", __func__, i - (int) MTLGPUFamilyCommon1 + 1, i);
found = true;
break;
}
}
}