|
12 | 12 | static c10::once_flag mpsdev_init; |
13 | 13 |
|
14 | 14 | static inline MTLLanguageVersion getMetalLanguageVersion(const id<MTLDevice>& device) { |
15 | | - #if defined(__MAC_10_13) && __MAC_OS_X_VERSION_MIN_REQUIRED >= __MAC_10_13 |
16 | | - #else |
17 | | - #error "Metal is not available on the current platform." |
18 | | - #endif |
19 | | - |
20 | | - // MPS Advanced Indexing needs at least Metal 2.0 (support for Argument Buffer and function constants) |
| 15 | + // MPS Advanced Indexing needs at least Metal 2.0 (support for Argument Buffers and function constants) |
21 | 16 | MTLLanguageVersion languageVersion; |
22 | | - if (@available(macOS 13.0, *)) { |
23 | | - languageVersion = MTLLanguageVersion3_0; |
24 | | - } else if (@available(macOS 12.0, *)) { |
25 | | - languageVersion = MTLLanguageVersion2_4; |
26 | | - } else if (@available(macOS 11.0, *)) { |
27 | | - languageVersion = MTLLanguageVersion2_3; |
28 | | - } else if (@available(macOS 10.15, *)) { |
29 | | - languageVersion = MTLLanguageVersion2_2; |
30 | | - } else if (@available(macOS 10.14, *)) { |
31 | | - languageVersion = MTLLanguageVersion2_1; |
32 | | - } else if (@available(macOS 10.13, *)) { |
| 17 | + |
| 18 | +#if defined(__MAC_13_0) && __MAC_OS_X_VERSION_MIN_REQUIRED >= __MAC_13_0 |
| 19 | + languageVersion = MTLLanguageVersion3_0; |
| 20 | +#elif defined(__MAC_12_0) && __MAC_OS_X_VERSION_MIN_REQUIRED >= __MAC_12_0 |
| 21 | + languageVersion = MTLLanguageVersion2_4; |
| 22 | +#elif defined(__MAC_11_0) && __MAC_OS_X_VERSION_MIN_REQUIRED >= __MAC_11_0 |
| 23 | + languageVersion = MTLLanguageVersion2_3; |
| 24 | +#elif defined(__MAC_10_15) && __MAC_OS_X_VERSION_MIN_REQUIRED >= __MAC_10_15 |
| 25 | + languageVersion = MTLLanguageVersion2_2; |
| 26 | +#elif defined(__MAC_10_14) && __MAC_OS_X_VERSION_MIN_REQUIRED >= __MAC_10_14 |
| 27 | + languageVersion = MTLLanguageVersion2_1; |
| 28 | +#elif defined(__MAC_10_13) && __MAC_OS_X_VERSION_MIN_REQUIRED >= __MAC_10_13 |
33 | 29 | languageVersion = MTLLanguageVersion2_0; |
34 | | - } |
| 30 | +#elif |
| 31 | + #error "Metal is not available on the current platform." |
| 32 | +#endif |
35 | 33 |
|
36 | 34 | TORCH_CHECK([device supportsFamily:MTLGPUFamilyMac2], "Missing Metal support for MTLGPUFamilyMac2"); |
37 | 35 | return languageVersion; |
|
0 commit comments