Skip to content

Commit d9a30dc

Browse files
committed
Added get-amdclang
1 parent f493e88 commit d9a30dc

12 files changed

Lines changed: 407 additions & 42 deletions

File tree

script/README.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# MLCommons Automation Scripts
22

3-
*Last updated: 2026-04-22 06:04:04*
3+
*Last updated: 2026-04-23 01:45:13*
44

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

@@ -326,6 +326,9 @@ This directory contains automation scripts for MLPerf benchmarks, AI/ML workflow
326326

327327
## Compiler automation
328328

329+
- **[get-amdclang](get-amdclang/)**
330+
- Detect amdclang compiler from ROCm
331+
- Tags: `compiler`, `get`, `amdclang`, `c-compiler`, `cpp-compiler`, `f-compiler`
329332
- **[get-aocc](get-aocc/)**
330333
- Detect or install AOCC compiler
331334
- Tags: `compiler`, `get`, `aocc`
@@ -920,12 +923,12 @@ This directory contains automation scripts for MLPerf benchmarks, AI/ML workflow
920923
- **[get-mlperf-training-nvidia-code](get-mlperf-training-nvidia-code/)**
921924
- get-mlperf-training-nvidia-code
922925
- Tags: `get`, `nvidia`, `mlperf`, `training`, `code`, `training-code`
923-
- **[get-mlperf-training-src](get-mlperf-training-src/)**
924-
- get-mlperf-training-src
925-
- Tags: `get`, `src`, `source`, `training`, `training-src`, `training-source`, `mlperf`, `mlcommons`
926926
- **[get-mlperf-training-results-summary](get-mlperf-training-results-summary/)**
927927
- get-mlperf-training-results-summary
928928
- Tags: `get`, `mlperf`, `training`, `results`, `summary`, `summary-results`, `results-summary`
929+
- **[get-mlperf-training-src](get-mlperf-training-src/)**
930+
- get-mlperf-training-src
931+
- Tags: `get`, `src`, `source`, `training`, `training-src`, `training-source`, `mlperf`, `mlcommons`
929932
- **[prepare-training-data-bert](prepare-training-data-bert/)**
930933
- prepare-training-data-bert
931934
- Tags: `prepare`, `mlperf`, `training`, `data`, `input`, `bert`
@@ -1201,7 +1204,7 @@ This directory contains automation scripts for MLPerf benchmarks, AI/ML workflow
12011204

12021205
## Statistics
12031206

1204-
- **Total Scripts**: 351
1207+
- **Total Scripts**: 353
12051208
- **Categories**: 33
12061209

12071210
## Usage

script/get-amdclang/customize.py

Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
from mlc import utils
2+
import os
3+
import glob
4+
5+
6+
def preprocess(i):
7+
8+
os_info = i['os_info']
9+
env = i['env']
10+
recursion_spaces = i['recursion_spaces']
11+
12+
file_name_c = 'amdclang'
13+
14+
env['FILE_NAME_C'] = file_name_c
15+
16+
if 'MLC_AMDCLANG_BIN_WITH_PATH' not in env:
17+
18+
# Build search paths from ROCm installation
19+
search_paths = []
20+
21+
if env.get('MLC_AMDCLANG_DIR_PATH', '') != '':
22+
d = env['MLC_AMDCLANG_DIR_PATH']
23+
if os.path.exists(os.path.join(d, 'bin', file_name_c)):
24+
search_paths.append(os.path.join(d, 'bin'))
25+
26+
# Check ROCm llvm directories
27+
rocm_path = env.get('MLC_ROMLC_INSTALLED_PATH', '')
28+
if rocm_path:
29+
rocm_base = os.path.dirname(rocm_path) # /opt/rocm
30+
llvm_bin = os.path.join(rocm_base, 'llvm', 'bin')
31+
if os.path.isdir(llvm_bin):
32+
search_paths.append(llvm_bin)
33+
34+
# Also check standard paths
35+
for p in ['/opt/rocm/llvm/bin'] + sorted(glob.glob('/opt/rocm-*/llvm/bin'), reverse=True):
36+
if os.path.isdir(p) and p not in search_paths:
37+
search_paths.append(p)
38+
39+
if search_paths:
40+
env['MLC_TMP_PATH'] = os.pathsep.join(search_paths)
41+
42+
r = i['automation'].find_artifact({'file_name': file_name_c,
43+
'env': env,
44+
'os_info': os_info,
45+
'default_path_env_key': 'PATH',
46+
'detect_version': True,
47+
'env_path_key': 'MLC_AMDCLANG_BIN_WITH_PATH',
48+
'run_script_input': i['run_script_input'],
49+
'recursion_spaces': recursion_spaces})
50+
if r['return'] > 0:
51+
return r
52+
53+
return {'return': 0}
54+
55+
56+
def detect_version(i):
57+
env = i['env']
58+
logger = i['automation'].logger
59+
60+
r = i['automation'].parse_version({'match_text': r'AMD clang version\s+([\d.]+)',
61+
'group_number': 1,
62+
'env_key': 'MLC_AMDCLANG_VERSION',
63+
'which_env': env})
64+
if r['return'] > 0:
65+
return r
66+
67+
version = r['version']
68+
69+
logger.info(
70+
f"{i['recursion_spaces']} Detected version: {version}")
71+
72+
return {'return': 0, 'version': version}
73+
74+
75+
def postprocess(i):
76+
77+
env = i['env']
78+
r = detect_version(i)
79+
if r['return'] > 0:
80+
return r
81+
82+
version = r['version']
83+
env['MLC_COMPILER_FAMILY'] = 'AMDCLANG'
84+
env['MLC_COMPILER_VERSION'] = version
85+
env['MLC_AMDCLANG_CACHE_TAGS'] = 'version-' + version
86+
env['MLC_COMPILER_CACHE_TAGS'] = 'version-' + version + ',family-amdclang'
87+
88+
found_file_path = env['MLC_AMDCLANG_BIN_WITH_PATH']
89+
found_path = os.path.dirname(found_file_path)
90+
91+
env['MLC_AMDCLANG_BIN_PATH'] = found_path
92+
env['MLC_AMDCLANG_INSTALLED_PATH'] = os.path.dirname(found_path)
93+
env['MLC_AMDCLANG_LIB_PATH'] = os.path.join(
94+
env['MLC_AMDCLANG_INSTALLED_PATH'], 'lib')
95+
96+
file_name_c = os.path.basename(found_file_path)
97+
file_name_cpp = 'amdclang++'
98+
file_name_fortran = 'amdflang'
99+
100+
env['MLC_AMDCLANG_BIN'] = file_name_c
101+
102+
# C compiler
103+
env['MLC_C_COMPILER_BIN'] = file_name_c
104+
env['MLC_C_COMPILER_WITH_PATH'] = found_file_path
105+
env['MLC_C_COMPILER_FLAG_OUTPUT'] = '-o '
106+
env['MLC_C_COMPILER_FLAG_VERSION'] = '--version'
107+
env['MLC_C_COMPILER_FLAG_INCLUDE'] = '-I'
108+
109+
# C++ compiler
110+
env['MLC_CXX_COMPILER_BIN'] = file_name_cpp
111+
env['MLC_CXX_COMPILER_WITH_PATH'] = os.path.join(found_path, file_name_cpp)
112+
env['MLC_CXX_COMPILER_FLAG_OUTPUT'] = '-o '
113+
env['MLC_CXX_COMPILER_FLAG_VERSION'] = '--version'
114+
env['MLC_CXX_COMPILER_FLAG_INCLUDE'] = '-I'
115+
116+
# Fortran compiler
117+
fortran_path = os.path.join(found_path, file_name_fortran)
118+
if os.path.exists(fortran_path):
119+
env['MLC_FORTRAN_COMPILER_BIN'] = file_name_fortran
120+
env['MLC_FORTRAN_COMPILER_WITH_PATH'] = fortran_path
121+
env['MLC_FORTRAN_COMPILER_FLAG_OUTPUT'] = '-o '
122+
env['MLC_FORTRAN_COMPILER_FLAG_VERSION'] = '--version'
123+
124+
env['MLC_COMPILER_FLAGS_FAST'] = "-O3"
125+
env['MLC_LINKER_FLAGS_FAST'] = "-O3"
126+
env['MLC_COMPILER_FLAGS_DEBUG'] = "-O0"
127+
env['MLC_LINKER_FLAGS_DEBUG'] = "-O0"
128+
env['MLC_COMPILER_FLAGS_DEFAULT'] = "-O2"
129+
env['MLC_LINKER_FLAGS_DEFAULT'] = "-O2"
130+
131+
env['+PATH'] = [found_path]
132+
133+
return {'return': 0, 'version': version}

script/get-amdclang/meta.yaml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
alias: get-amdclang
2+
uid: fd0e87bcc1bc45cc
3+
automation_alias: script
4+
automation_uid: 5b4e0237da074764
5+
6+
# Metadata
7+
name: Detect amdclang compiler from ROCm
8+
category: Compiler automation
9+
tags:
10+
- compiler
11+
- get
12+
- amdclang
13+
- c-compiler
14+
- cpp-compiler
15+
- f-compiler
16+
17+
# Cache
18+
cache: true
19+
clean_files: []
20+
21+
# Environment
22+
new_env_keys:
23+
- MLC_AMDCLANG_*
24+
- MLC_C_COMPILER_*
25+
- MLC_CXX_COMPILER_*
26+
- MLC_FORTRAN_COMPILER_*
27+
- MLC_COMPILER_*
28+
- MLC_LINKER_*
29+
- +PATH
30+
31+
# Dependencies
32+
deps:
33+
- tags: get,rocm
34+
35+
post_deps:
36+
- tags: get,compiler-flags
37+
38+
# Variations
39+
variations:
40+
path.#:
41+
env:
42+
MLC_AMDCLANG_DIR_PATH: '#'
43+
44+
# Output / debugging
45+
sort: 500
46+
47+
# Tests
48+
tests:
49+
run_inputs:
50+
- variations_list: []

script/get-amdclang/run.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/bash
2+
3+
amdclang_bin=${MLC_AMDCLANG_BIN_WITH_PATH}
4+
${amdclang_bin} --version > tmp-ver.out
5+
test $? -eq 0 || exit $?

script/get-rocm/customize.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from mlc import utils
22
import os
3+
import glob
34

45

56
def preprocess(i):
@@ -12,7 +13,21 @@ def preprocess(i):
1213

1314
file_name = 'rocminfo.exe' if os_info['platform'] == 'windows' else 'rocminfo'
1415
env['FILE_NAME'] = file_name
15-
env['MLC_TMP_PATH'] = "/opt/rocm/bin"
16+
17+
# Build search paths: check /opt/rocm/bin and any versioned /opt/rocm-*/bin
18+
rocm_paths = []
19+
if os.path.isdir("/opt/rocm/bin"):
20+
rocm_paths.append("/opt/rocm/bin")
21+
for p in sorted(glob.glob("/opt/rocm-*/bin"), reverse=True):
22+
if os.path.isdir(p):
23+
rocm_paths.append(p)
24+
25+
if rocm_paths:
26+
env['MLC_TMP_PATH'] = os.pathsep.join(rocm_paths)
27+
else:
28+
# No ROCm found, skip search and trigger install
29+
env['MLC_REQUIRE_INSTALL'] = "yes"
30+
return {'return': 0}
1631

1732
if 'MLC_ROMLC_BIN_WITH_PATH' not in env:
1833
r = i['automation'].find_artifact({'file_name': file_name,

script/get-rocm/meta.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,8 @@ prehook_deps:
2626
- 'yes'
2727
reuse_version: true
2828
tags: install,rocm
29+
30+
# Tests
31+
tests:
32+
run_inputs:
33+
- variations_list: []

script/get-rocm/run.sh

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
#!/bin/bash
22

3-
dir="${MLC_ROMLC_BIN_WITH_PATH%/*}/../"
4-
cat ${dir}/.info/version > tmp-ver.out
5-
test $? -eq 0 || exit 1
3+
dir="${MLC_ROMLC_BIN_WITH_PATH%/*}/.."
4+
version_file="${dir}/.info/version"
5+
6+
if [ -f "${version_file}" ]; then
7+
cat "${version_file}" > tmp-ver.out
8+
test $? -eq 0 || exit 1
9+
else
10+
# Fallback: try rocminfo output
11+
${MLC_ROMLC_BIN_WITH_PATH} 2>/dev/null | grep "Runtime Version" | head -1 | sed 's/.*: *//' > tmp-ver.out
12+
test $? -eq 0 || exit 1
13+
fi

script/install-rocm/README.md

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# README for install-rocm
2+
This README is automatically generated. Create and add custom content in info.md. Please follow the [script execution document](https://docs.mlcommons.org/mlcflow/targets/script/execution-flow/) to understand more about the MLC script execution.
3+
4+
`mlcflow` stores all local data under `$HOME/MLC` by default. So, if there is space constraint on the home directory and you have more space on say `/mnt/$USER`, you can do
5+
```
6+
mkdir /mnt/$USER/MLC
7+
ln -s /mnt/$USER/MLC $HOME/MLC
8+
```
9+
You can also use the `ENV` variable `MLC_REPOS` to control this location but this will need a set after every system reboot.
10+
11+
## Setup
12+
13+
If you are not on a Python development environment please refer to the [official docs](https://docs.mlcommons.org/mlcflow/install/) for the installation.
14+
15+
```bash
16+
python3 -m venv mlcflow
17+
. mlcflow/bin/activate
18+
pip install mlcflow
19+
```
20+
21+
- Using a virtual environment is recommended (per `pip` best practices), but you may skip it or use `--break-system-packages` if needed.
22+
23+
### Pull mlperf-automations
24+
25+
Once `mlcflow` is installed:
26+
27+
```bash
28+
mlc pull repo mlcommons@mlperf-automations --pat=<Your Private Access Token>
29+
```
30+
- `--pat` or `--ssh` is only needed if the repo is PRIVATE
31+
- If `--pat` is avoided, you'll be asked to enter the password where you can enter your Private Access Token
32+
- `--ssh` option can be used instead of `--pat=<>` option if you prefer to use SSH for accessing the github repository.
33+
## Run Commands
34+
35+
```bash
36+
mlcr install,rocm,install-rocm
37+
```
38+
39+
No script specific inputs
40+
### Generic Script Inputs
41+
42+
| Name | Description | Choices | Default |
43+
|------|-------------|---------|------|
44+
| `--input` | Input to the script passed using the env key `MLC_INPUT` | | `` |
45+
| `--output` | Output from the script passed using the env key `MLC_OUTPUT` | | `` |
46+
| `--outdirname` | The directory to store the script output | | `cache directory ($HOME/MLC/repos/local/cache/<>) if the script is cacheable or else the current directory` |
47+
| `--outbasename` | The output file/folder name | | `` |
48+
| `--search_folder_path` | The folder path where executables of a given script need to be searched. Search is done recursively upto 4 levels. | | `` |
49+
| `--name` | | | `` |
50+
| `--extra_cache_tags` | Extra cache tags to be added to the cached entry when the script results are saved | | `` |
51+
| `--skip_compile` | Skip compilation | | `False` |
52+
| `--skip_run` | Skip run | | `False` |
53+
| `--skip_sudo` | Skip SUDO detection | | `False` |
54+
| `--accept_license` | Accept the required license requirement to run the script | | `False` |
55+
| `--skip_system_deps` | Skip installing any system dependencies | | `False` |
56+
| `--git_ssh` | Use SSH for git repos | | `False` |
57+
| `--gh_token` | Github Token | | `` |
58+
| `--hf_token` | Huggingface Token | | `` |
59+
| `--verify_ssl` | Verify SSL | | `False` |
60+
## Variations

script/install-rocm/customize.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from mlc import utils
22
import os
3+
import glob
34

45

56
def preprocess(i):
@@ -13,7 +14,17 @@ def preprocess(i):
1314
def postprocess(i):
1415

1516
env = i['env']
16-
installed_path = "/opt/rocm/bin"
17+
18+
# Check standard and versioned ROCm install paths
19+
installed_path = ""
20+
for candidate in ["/opt/rocm/bin"] + sorted(glob.glob("/opt/rocm-*/bin"), reverse=True):
21+
if os.path.isfile(os.path.join(candidate, "rocminfo")):
22+
installed_path = candidate
23+
break
24+
25+
if not installed_path:
26+
return {'return': 1, 'error': 'ROCm installation not found after install'}
27+
1728
env['MLC_ROMLC_INSTALLED_PATH'] = installed_path
1829
env['MLC_ROMLC_BIN_WITH_PATH'] = os.path.join(installed_path, "rocminfo")
1930
env['+PATH'] = [installed_path]

script/install-rocm/meta.yaml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,15 @@ deps:
2525
- tags: detect,os
2626

2727
# Versions
28-
default_version: 5.7.1
29-
versions: {}
28+
default_version: 7.2.2
29+
versions:
30+
'7.2.2': {}
31+
'7.2.1': {}
32+
'6.2.0': {}
33+
'6.1.0': {}
34+
'5.7.1': {}
35+
36+
# Tests
37+
tests:
38+
run_inputs:
39+
- variations_list: []

0 commit comments

Comments
 (0)