Skip to content

Commit ef3cecd

Browse files
authored
Revert "For Apple silicon, add separation between architecture and Metal API selection" (#101)
This seems to not work with some Mac versions, reverting for now. Reverts #96
1 parent 09b87fd commit ef3cecd

2 files changed

Lines changed: 13 additions & 39 deletions

File tree

‎mojo/extensions.bzl‎

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -201,16 +201,8 @@ _gpu_toolchains_tag = tag_class(
201201
"mi325": "amdgpu:gfx942",
202202
"mi355": "amdgpu:gfx950",
203203
"rtx5090": "nvidia:120a",
204-
"metal1": "metal:1",
205-
"metal2": "metal:2",
206-
"metal3": "metal:3",
207-
"metal4": "metal:4",
208-
"metal5": "metal:5",
209-
"metal1_metal4": "metal:1-metal4",
210-
"metal2_metal4": "metal:2-metal4",
211-
"metal3_metal4": "metal:3-metal4",
212-
"metal4_metal4": "metal:4-metal4",
213-
"metal5_metal4": "metal:5-metal4",
204+
"metal3": "metal:30",
205+
"metal4": "metal:40",
214206
},
215207
doc = "The GPUs supported by this toolchain, mapping to Mojo's target accelerators.",
216208
),
@@ -235,11 +227,8 @@ _gpu_toolchains_tag = tag_class(
235227
"MI355": "mi355",
236228
"Navi": "radeon",
237229
"AMD Radeon Graphics": "radeon",
238-
"Apple M1": "metal1",
239-
"Apple M2": "metal2",
240-
"Apple M3": "metal3",
241-
"Apple M4": "metal4",
242-
"Apple M5": "metal5",
230+
"Metal 3": "metal3",
231+
"Metal 4": "metal4",
243232
},
244233
doc = "The output from nvidia-smi or rocm-smi to the corresponding GPU name in SUPPORTED_GPUS.",
245234
),

‎mojo/mojo_host_platform.bzl‎

Lines changed: 9 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -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-
9790
def _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

Comments
 (0)