Skip to content

Commit 88449a6

Browse files
committed
Support rocm src install
1 parent 3d19216 commit 88449a6

4 files changed

Lines changed: 120 additions & 25 deletions

File tree

script/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# MLCommons Automation Scripts
22

3-
*Last updated: 2026-04-23 19:45:00*
3+
*Last updated: 2026-04-23 19:51:36*
44

55
This directory contains automation scripts for MLPerf benchmarks, AI/ML workflows, and development operations.
66

script/install-rocm/customize.py

Lines changed: 57 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,37 @@ def preprocess(i):
2929

3030
env['MLC_ROCM_INSTALL_PREFIX'] = install_prefix
3131

32-
# For ROCm 7+, resolve the runfile download URL
3332
version = env.get('MLC_VERSION', '')
33+
34+
# Source build: set up git tag and cmake command, skip runfile logic
35+
if env.get('MLC_ROCM_BUILD_FROM_SRC', '') == 'yes':
36+
env['MLC_GIT_CHECKOUT_TAG'] = f'rocm-{version}'
37+
38+
src_path = env.get('MLC_ROCM_LLVM_SRC_PATH', '')
39+
build_install_prefix = os.path.join(os.getcwd(), 'install')
40+
env['MLC_ROCM_INSTALL_PREFIX'] = build_install_prefix
41+
42+
targets = 'AMDGPU;X86'
43+
projects = 'clang;lld;compiler-rt;clang-tools-extra'
44+
runtimes = 'libcxx;libcxxabi;openmp'
45+
46+
cmake_cmd = (
47+
f'cmake {os.path.join(src_path, "llvm")} -GNinja'
48+
f' -DCMAKE_BUILD_TYPE=Release'
49+
f' -DCMAKE_INSTALL_PREFIX={build_install_prefix}'
50+
f' -DLLVM_ENABLE_PROJECTS=\"{projects}\"'
51+
f' -DLLVM_ENABLE_RUNTIMES=\"{runtimes}\"'
52+
f' -DLLVM_TARGETS_TO_BUILD={targets}'
53+
f' -DLLVM_ENABLE_RTTI=ON'
54+
f' -DLLVM_INSTALL_UTILS=ON'
55+
f' -DLLVM_ENABLE_ASSERTIONS=OFF'
56+
f' -DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=OFF'
57+
)
58+
env['MLC_ROCM_CMAKE_CMD'] = cmake_cmd
59+
i['run_script_input']['script_name'] = 'run-src'
60+
return {'return': 0}
61+
62+
# For ROCm 7+, resolve the runfile download URL
3463
major_version = int(version.split('.')[0]) if version else 0
3564

3665
if major_version >= 7:
@@ -65,6 +94,33 @@ def postprocess(i):
6594

6695
env = i['env']
6796

97+
# Source build: look for clang in install dir, create amdclang symlinks
98+
if env.get('MLC_ROCM_BUILD_FROM_SRC', '') == 'yes':
99+
install_dir = env.get('MLC_ROCM_INSTALL_PREFIX', os.path.join(os.getcwd(), 'install'))
100+
bin_dir = os.path.join(install_dir, 'bin')
101+
102+
clang_path = os.path.join(bin_dir, 'clang')
103+
if not os.path.isfile(clang_path):
104+
return {'return': 1, 'error': f'ROCm LLVM build failed: clang not found at {clang_path}'}
105+
106+
# Create amdclang symlinks
107+
symlinks = {
108+
'amdclang': 'clang',
109+
'amdclang++': 'clang++',
110+
'amdflang': 'flang-new',
111+
}
112+
for link_name, target in symlinks.items():
113+
link_path = os.path.join(bin_dir, link_name)
114+
target_path = os.path.join(bin_dir, target)
115+
if os.path.isfile(target_path) and not os.path.exists(link_path):
116+
os.symlink(target, link_path)
117+
print(f' Created symlink: {link_name} -> {target}')
118+
119+
env['MLC_ROMLC_INSTALLED_PATH'] = bin_dir
120+
env['MLC_ROMLC_BIN_WITH_PATH'] = os.path.join(bin_dir, 'rocminfo') if os.path.isfile(os.path.join(bin_dir, 'rocminfo')) else clang_path
121+
env['+PATH'] = [bin_dir]
122+
return {'return': 0}
123+
68124
install_prefix = env.get('MLC_ROCM_INSTALL_PREFIX', '/')
69125
cur_dir = os.getcwd()
70126

script/install-rocm/meta.yaml

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,35 +2,23 @@ alias: install-rocm
22
uid: 9d13f90463ce4545
33
automation_alias: script
44
automation_uid: 5b4e0237da074764
5-
6-
# Metadata
75
category: AI/ML frameworks
86
tags:
97
- install
108
- rocm
119
- install-rocm
12-
13-
# Cache
1410
cache: true
1511
clean_files: []
16-
17-
# Input mapping
1812
input_mapping:
1913
rocm_install_prefix: MLC_ROCM_INSTALL_PREFIX
20-
21-
# Environment
2214
env: {}
2315
new_env_keys:
2416
- MLC_ROMLC_*
2517
- MLC_ROCM_INSTALL_PREFIX
2618
- +PATH
27-
28-
# Dependencies
2919
deps:
3020
- tags: detect,os
3121
- tags: detect,sudo
32-
33-
# Prehook dependencies
3422
prehook_deps:
3523
- tags: download,file
3624
extra_cache_tags: rocm,installer,runfile
@@ -43,23 +31,37 @@ prehook_deps:
4331
force_env_keys:
4432
- MLC_DOWNLOAD_URL
4533
- MLC_DOWNLOAD_FILENAME
46-
47-
# Variations
4834
variations:
4935
compiler-only:
5036
env:
5137
MLC_ROCM_COMPILER_ONLY: 'yes'
52-
53-
# Versions
38+
src:
39+
env:
40+
MLC_ROCM_BUILD_FROM_SRC: 'yes'
41+
MLC_GIT_URL: https://github.com/ROCm/llvm-project
42+
deps:
43+
- tags: get,cmake
44+
- tags: get,generic-sys-util,_ninja-build
45+
- tags: get,git,repo
46+
env:
47+
MLC_GIT_CHECKOUT_PATH_ENV_NAME: MLC_ROCM_LLVM_SRC_PATH
48+
extra_cache_tags: rocm,llvm,src
49+
force_env_keys:
50+
- MLC_GIT_*
51+
names:
52+
- rocm-llvm-src-repo
53+
update_tags_from_env_with_prefix:
54+
_tag.:
55+
- MLC_GIT_CHECKOUT_TAG
56+
_repo.:
57+
- MLC_GIT_URL
5458
default_version: 7.2.2
5559
versions:
56-
'7.2.2': {}
57-
'7.2.1': {}
58-
'6.2.0': {}
59-
'6.1.0': {}
60-
'5.7.1': {}
61-
62-
# Tests
60+
7.2.2: {}
61+
7.2.1: {}
62+
6.2.0: {}
63+
6.1.0: {}
64+
5.7.1: {}
6365
tests:
6466
run_inputs:
6567
- variations_list: []

script/install-rocm/run-src.sh

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#!/bin/bash
2+
3+
# Build ROCm LLVM compiler from source
4+
5+
CUR_DIR=$PWD
6+
INSTALL_DIR="${MLC_ROCM_INSTALL_PREFIX}"
7+
8+
echo "Building ROCm LLVM from source..."
9+
echo " Source: ${MLC_ROCM_LLVM_SRC_PATH}"
10+
echo " Install prefix: ${INSTALL_DIR}"
11+
12+
mkdir -p build
13+
cd build
14+
test $? -eq 0 || exit $?
15+
16+
echo ""
17+
echo "Running cmake..."
18+
echo "${MLC_ROCM_CMAKE_CMD}"
19+
eval "${MLC_ROCM_CMAKE_CMD}"
20+
test $? -eq 0 || exit $?
21+
22+
echo ""
23+
echo "Building with ninja (this may take a while)..."
24+
ninja
25+
test $? -eq 0 || exit $?
26+
27+
echo ""
28+
echo "Installing..."
29+
ninja install
30+
test $? -eq 0 || exit $?
31+
32+
# Clean build directory (can be very large)
33+
cd "${CUR_DIR}"
34+
rm -rf build
35+
36+
echo ""
37+
echo "ROCm LLVM built and installed to ${INSTALL_DIR}"

0 commit comments

Comments
 (0)