@@ -87,13 +87,6 @@ def _get_amd_constraints_with_rocm_smi(rctx, rocm_smi, gpu_mapping):
8787
8888 return constraints
8989
90- def _toolchain_supports_metal4 (rctx ):
91- result = rctx .execute (["/usr/bin/xcrun" , "--sdk" , "macosx" , "--show-sdk-version" ])
92- _log_result (rctx , "/usr/bin/xcrun --sdk macosx --show-sdk-version" , result )
93- if result .return_code != 0 :
94- return False
95- return int (result .stdout .strip ().split ("." )[0 ]) >= 26
96-
9790def _get_apple_constraint (rctx , gpu_mapping ):
9891 result = rctx .execute (["/usr/bin/sw_vers" , "--productVersion" ])
9992 _log_result (rctx , "/usr/sbin/sw_vers --productVersion" , result )
@@ -109,29 +102,21 @@ def _get_apple_constraint(rctx, gpu_mapping):
109102
110103 _log_result (rctx , "/usr/sbin/system_profiler SPDisplaysDataType" , result )
111104
112- chipset_model = None
113- metal_support = None
105+ metal_version = None
114106 for line in result .stdout .splitlines ():
115- if "Chipset Model:" in line :
116- chipset_model = line
117- elif "Metal Support:" in line :
118- metal_support = line
107+ if "Metal Support:" in line :
108+ metal_version = line
109+ break
119110
120- if not chipset_model : # macOS VMs may not have GPUs attached
111+ if not metal_version : # macOS VMs may not have GPUs attached
121112 return None
122113
123- metal4 = (
124- metal_support and "Metal 4" in metal_support and
125- _toolchain_supports_metal4 (rctx )
126- )
127-
128114 for gpu_name , constraint in gpu_mapping .items ():
129- if gpu_name in chipset_model :
130- if not constraint :
115+ if gpu_name in metal_version :
116+ if constraint :
117+ return "@mojo_gpu_toolchains//:{}_gpu" .format (constraint )
118+ else :
131119 return None
132- if metal4 :
133- constraint += "_metal4"
134- return "@mojo_gpu_toolchains//:{}_gpu" .format (constraint )
135120
136121 _fail (rctx , "Unrecognized system_profiler output, please add it to your gpu_mapping in the MODULE.bazel file: {}" .format (result .stdout ))
137122 return None
0 commit comments