Skip to content

Commit 27dfad7

Browse files
committed
Initial support for building AOMP with TheRock
1 parent 80f802c commit 27dfad7

File tree

8 files changed

+998
-0
lines changed

8 files changed

+998
-0
lines changed

tr_aomp/README

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
2+
AOMP is a development build of ROCm for the ROCm-compiler.
3+
AOMP builds the amd-staging branch of the ROCm llvm-compliler with
4+
the latest stable release branches of supporting components.
5+
6+
This directory (aomp/tr_aomp) contains all the support to build AOMP
7+
using TheRock. This includes the manifest file tr_aomp.xml.
8+
The manifest file is used by tr_set_aomp_branches.sh to change
9+
the submodule branch from some set of hashes determined by
10+
TheRock oligarchs to branches needed by AOMP.
11+
12+
Currently, building AOMP with TheRock is experimental.
13+
14+
The current build process is:
15+
16+
1) ./tr_clone_aomp.sh
17+
2) ./tr_set_aomp_branches.sh
18+
3) apply an evolving custom patch to TheRock and all of its submodules.
19+
cd /work/$USER/git/tr_aomp/TheRock
20+
patch -p1 --dry-run </work/$USER/git/tr_aomp/aomp/tr_aomp/patches/tr_aomp.patch
21+
patch -p1 </work/$USER/git/tr_aomp/aomp/tr_aomp/patches/tr_aomp.patch
22+
4) nohup ./tr_build_aomp.sh &
23+
24+
Eventually we will merge 1), 2), and 3) into a fully automated script tr_clone_aomp.sh
25+
26+
Currently tr_build_aomp.sh builds rocm into /work/$USER/git/tr_aomp/TheRock/build/dist/rocm.
27+
tr_build_aomp.sh will eventually be modified to copy
28+
/work/$USER/git/tr_aomp/TheRock/build/dist/rocm to $AOMP (~/rocm/aomp).
29+
30+
Till then, set AOMP=/work/$USER/git/tr_aomp/TheRock/build/dist/rocm to test your build with AOMP tests.
31+
that expect AOMP to point to the compiler.
32+
33+
How to update the AOMP patch of TheRock (tr_aomp.patch).
34+
cd /work/$USER/git/tr_aomp
35+
pfile=/work/$USER/git/tr_aomp/aomp/tr_aomp/patches/tr_aomp.patch
36+
diff -Naur -x .git -x __pycache__ -x amd-llvm TheRock.orig TheRock > $pfile
37+
cd /work/$USER/git/tr_aomp/aomp
38+
git add tr_aomp/patches/tr_aomp.patch
39+
git commit -m "Update to tr_aomp.patch"
40+
git push
41+
42+
This README file was last updated on 8/19/2025

tr_aomp/patches/tr_aomp.patch

Lines changed: 502 additions & 0 deletions
Large diffs are not rendered by default.

tr_aomp/tr_aomp.xml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<manifest>
3+
<!-- Manifest for AOMP 21.0-x which uses ROCM 6.4 release branches of external repositories -->
4+
5+
<default revision="release/rocm-rel-6.4" remote="gerritgit" sync-j="4" sync-c="true" />
6+
<remote name="roc" fetch="https://github.com/ROCm" />
7+
<remote name="SJTU" fetch="https://github.com/SJTU-IPADS" />
8+
9+
<!-- These first 4 repos are NOT rocm 6.4. They are compiler developer branches -->
10+
<project remote="githubemu-lightning" path="llvm-project" name="llvm-project.git" revision="amd-staging" groups="unlocked" />
11+
<project remote="githubemu-lightning" path="SPIRV-LLVM-Translator" name="spirv-llvm-translator.git" revision="amd-staging" groups="unlocked" />
12+
<project remote="githubemu-lightning" path="hipify" name="hipify.git" revision="amd-staging" groups="unlocked" />
13+
14+
<project remote="roc" path="flang" name="flang" revision="aomp-dev" groups="unlocked" />
15+
<project remote="roc" path="aomp" name="aomp" revision="aomp-dev" groups="unlocked" />
16+
17+
<project remote="roc" path="rocprofiler" name="rocprofiler" revision="release/rocm-rel-6.4" groups="unlocked" />
18+
<project remote="roc" path="rocprofiler-sdk" name="rocprofiler-sdk" revision="release/rocm-rel-6.4" groups="unlocked" />
19+
<project remote="roc" path="roctracer" name="roctracer" revision="release/rocm-rel-6.4" groups="unlocked" />
20+
<project remote="roc" path="ROCdbgapi" name="ROCdbgapi" revision="release/rocm-rel-6.4" groups="unlocked" />
21+
<project remote="roc" path="ROCgdb" name="ROCgdb" revision="release/rocm-rel-6.4" groups="unlocked" />
22+
<project remote="roc" path="hip" name="hip" revision="release/rocm-rel-6.4" groups="unlocked" />
23+
<project remote="roc" path="clr" name="clr" revision="release/rocm-rel-6.4" groups="unlocked" />
24+
<project remote="roc" path="rocminfo" name="rocminfo" revision="release/rocm-rel-6.4" groups="unlocked" />
25+
<project remote="roc" path="rocm_smi_lib" name="rocm_smi_lib" revision="release/rocm-rel-6.4" groups="unlocked" />
26+
<project remote="roc" path="amdsmi" name="amdsmi" revision="release/rocm-rel-6.4" groups="unlocked" />
27+
<project remote="roc" path="rocm-cmake" name="rocm-cmake" revision="release/rocm-rel-6.4" groups="unlocked" />
28+
<project remote="roc" path="rocr-runtime" name="ROCR-Runtime" revision="release/rocm-rel-6.4" groups="unlocked" />
29+
<project remote="roc" path="rocprofiler-register" name="rocprofiler-register" revision="release/rocm-rel-6.4" groups="unlocked" />
30+
<project remote="roc" path="hipfort" name="hipfort" revision="release/rocm-rel-6.4" groups="unlocked" />
31+
<project remote="roc" path="half" name="half" revision="release/rocm-rel-6.4" groups="unlocked"/>
32+
<project remote="roc" path="hipBLAS-common" name="hipBLAS-common" revision="release/rocm-rel-6.4" groups="unlocked"/>
33+
<project remote="roc" path="hipBLAS" name="hipBLAS" revision="release/rocm-rel-6.4" groups="unlocked"/>
34+
<project remote="roc" path="hipBLASLt" name="hipBLASLt" revision="release/rocm-rel-6.4" groups="unlocked"/>
35+
<project remote="roc" path="hipCUB" name="hipCUB" revision="release/rocm-rel-6.4" groups="unlocked"/>
36+
<project remote="roc" path="hipFFT" name="hipFFT" revision="release/rocm-rel-6.4" groups="unlocked"/>
37+
<project remote="roc" path="hipRAND" name="hipRAND" revision="release/rocm-rel-6.4" groups="unlocked"/>
38+
<project remote="roc" path="hipSOLVER" name="hipSOLVER" revision="release/rocm-rel-6.4" groups="unlocked"/>
39+
<project remote="roc" path="hipSPARSE" name="hipSPARSE" revision="release/rocm-rel-6.4" groups="unlocked"/>
40+
<project remote="roc" path="rccl" name="rccl" revision="release/rocm-rel-6.4" groups="unlocked"/>
41+
<project remote="roc" path="rocBLAS" name="rocBLAS" revision="release/rocm-rel-6.4" groups="unlocked"/>
42+
<project remote="roc" path="rocFFT" name="rocFFT" revision="release/rocm-rel-6.4" groups="unlocked"/>
43+
<project remote="roc" path="rocPRIM" name="rocPRIM" revision="release/rocm-rel-6.4" groups="unlocked"/>
44+
<project remote="roc" path="rocRAND" name="rocRAND" revision="release/rocm-rel-6.4" groups="unlocked"/>
45+
<project remote="roc" path="rocSOLVER" name="rocSOLVER" revision="release/rocm-rel-6.4" groups="unlocked"/>
46+
<project remote="roc" path="rocSPARSE" name="rocSPARSE" revision="release/rocm-rel-6.4" groups="unlocked"/>
47+
<project remote="roc" path="rocThrust" name="rocThrust" revision="release/rocm-rel-6.4" groups="unlocked"/>
48+
<project remote="roc" path="Tensile" name="Tensile" revision="release/rocm-rel-6.4" groups="unlocked"/>
49+
<project remote="roc" path="rocMLIR" name="rocMLIR" revision="release/rocm-rel-6.4" groups="unlocked"/>
50+
<project remote="roc" path="MIOpen" name="MIOpen" revision="release/rocm-rel-6.4" groups="unlocked"/>
51+
<project remote="roc" path="rocm-core" name="rocm-core" revision="release/rocm-rel-6.4" groups="unlocked"/>
52+
<project remote="roc" path="rccl-tests" name="rccl-tests" revision="develop" groups="unlocked"/>
53+
<project remote="roc" path="rocRoller" name="rocRoller" revision="develop" groups="unlocked"/>
54+
<project remote="roc" path="mxDataGenerator" name="mxDataGenerator" revision="main" groups="unlocked"/>
55+
<project remote="roc" path="amdgpu-windows-interop" name="amdgpu-windows-interop" revision="main" groups="unlocked"/>
56+
<project remote="roc" path="composable_kernel" name="composable_kernel" revision="release/rocm-rel-6.4" groups="unlocked"/>
57+
<project remote="roc" path="aqlprofile" name="aqlprofile" revision="amd-staging" groups="unlocked"/>
58+
<project remote="roc" path="rocprof-trace-decoder/binaries" name="rocprof-trace-decoder" revision="amd-mainline" groups="unlocked"/>
59+
<project remote="SJTU" path="PowerInfer" name="PowerInfer" revision="main" groups="unlocked" />
60+
</manifest>

tr_aomp/tr_build_aomp.sh

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#!/bin/bash
2+
#
3+
# tr_build_aomp.sh : Build aomp using TheRock
4+
5+
_workdir=${1:-/work}
6+
_aomprepodir=$_workdir/$USER/git/tr_aomp
7+
_therockdir=$_aomprepodir/TheRock
8+
_curdir=$PWD
9+
10+
cd $_therockdir
11+
12+
_config_out=config.out
13+
_build_out=build.out
14+
_build_dist_out=$PWD/build_dist.out
15+
_setup_ccache_out=setup_ccache.out
16+
17+
[ -d build ] && rm -rf build
18+
[ -f $_setup_ccache_out ] && rm $_setup_ccache_out
19+
[ -f $_build_out ] && rm $_build_out
20+
[ -f $_config_out ] && rm $_config_out
21+
[ -f $_build_dist_out ] && rm $_build_dist_out
22+
23+
#_cmd="cmake -B build -GNinja -DTHEROCK_AMDGPU_TARGETS=gfx90a -DTHEROCK_ENABLE_COMPOSABLE_KERNEL=OFF -DTHEROCK_ENABLE_FFT=OFF -DTHEROCK_ENABLE_RAND=OFF -DTHEROCK_ENABLE_PRIM=OFF -DTHEROCK_ENABLE_BLAS=OFF -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache $PWD"
24+
#_cmd="cmake -B build -GNinja -DTHEROCK_AMDGPU_TARGETS=gfx90a -DTHEROCK_ENABLE_COMPOSABLE_KERNEL=OFF -DTHEROCK_ENABLE_MATH_LIBS=OFF -DTHEROCK_ENABLE_ML_LIBS=OFF -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DTHEROCK_BUNDLE_SYSDEPS=OFF $PWD"
25+
#
26+
_cmd="cmake -B build -GNinja -DTHEROCK_AMDGPU_TARGETS=gfx90a -DTHEROCK_ENABLE_COMPOSABLE_KERNEL=OFF -DTHEROCK_ENABLE_MATH_LIBS=OFF -DTHEROCK_ENABLE_ML_LIBS=OFF -DTHEROCK_BUNDLE_SYSDEPS=OFF $PWD"
27+
eval "$(python3 ./build_tools/setup_ccache.py)" 2>&1 >>$_setup_ccache_out
28+
echo "===> CMD:$_cmd" >> $_config_out
29+
date >> $_config_out
30+
$_cmd 2>&1 >> $_config_out
31+
[ $? != 0 ] && cd $_curdir && exit 1
32+
33+
_cmd="cmake --build build"
34+
echo "===> CMD:$_cmd" >> $_build_out
35+
date >> $_build_out
36+
$_cmd 2>&1 >> $_build_out
37+
[ $? != 0 ] && cd $_curdir && exit 1
38+
date >> $_build_out
39+
40+
cd build
41+
_cmd="ninja therock-dist"
42+
pwd >> $_build_dist_out
43+
echo "===> CMD:$_cmd" >> $_build_dist_out
44+
date >> $_build_dist_out
45+
$_cmd 2>&1 >> $_build_dist_out
46+
[ $? != 0 ] && cd $_curdir && exit 1
47+
date >> $_build_dist_out
48+
echo "DONE see $_config_out and $_build_out and $_build_dist_out " | tee -a $_build_dist_out

tr_aomp/tr_clone_aomp.sh

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#!/bin/bash
2+
#
3+
# tr_clone_aomp.sh: Clone TheRock repository to use to build aomp.sh
4+
# using TheRock repo and its submodules. unlike clone_aomp.sh
5+
# this script is NOT (yet) reusable to refresh all the repos.
6+
#
7+
# WARNING: This script is experimental.
8+
#
9+
10+
_workdir=${1:-/work}
11+
_aomprepodir=$_workdir/$USER/git/tr_aomp
12+
_therockdir=$_aomprepodir/TheRock
13+
_curdir=$PWD
14+
15+
if [ ! -d $_workdir ] ; then
16+
echo "ERROR: $0 needs directory $_workdir"
17+
exit
18+
fi
19+
20+
mkdir -p $_aomprepodir
21+
if [ ! -d $_aomprepodir ] ; then
22+
echo "ERROR: $0 could not create directory $_aomprepodir"
23+
exit
24+
fi
25+
26+
cd $_aomprepodir
27+
if [ -d $_aomprepodir/aomp ] ; then
28+
echo "WARNING: Skipping clone of aomp , $_aomprepodir/aomp already exists"
29+
else
30+
echo git clone -b aomp-dev https://github.com/ROCm/aomp
31+
git clone -b aomp-dev https://github.com/ROCm/aomp
32+
fi
33+
if [ -d $_therockdir ] ; then
34+
echo "WARNING: Skipping clone of TheRock, $_therockdir already exists"
35+
else
36+
echo git clone https://github.com/ROCm/TheRock.git
37+
git clone https://github.com/ROCm/TheRock.git
38+
fi
39+
40+
cd $_therockdir
41+
42+
python3 -m venv .venv && source .venv/bin/activate
43+
pip install -r requirements.txt
44+
python ./build_tools/fetch_sources.py 2>&1 | tee fetch_sources.out
45+
46+
# At this point we can run tr_set_aomp_branches.sh
47+
# But for now we run tr_set_aomp_branches.sh manually
48+
49+
cd $_curdir

tr_aomp/tr_list_aomp_branches.sh

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
#!/bin/bash
2+
#
3+
# tr_list_aomp_branches.sh: list key information about all the repos found
4+
# in the tr_aompi_$AOMP_VERSION.xml file
5+
#
6+
_workdir=${1:-/work}
7+
_aomprepodir=$_workdir/$USER/git/tr_aomp
8+
_therockdir=$_aomprepodir/TheRock
9+
_curdir=$PWD
10+
11+
_manifest_file=$_aomprepodir/aomp/tr_aomp/tr_aomp.xml
12+
13+
HEADERS=0
14+
15+
if [ ! -f "$_manifest_file" ] ; then
16+
echo "ERROR manifest file missing: $_manifest_file"
17+
exit 1
18+
fi
19+
tmpfile=/tmp/mlines$$
20+
# HACK: The manifest file must be one project line per repo
21+
grep project < "$_manifest_file" > "$tmpfile"
22+
if [ $HEADERS == 1 ] ; then
23+
printf "MANIFEST FILE: %40s\n" "$_manifest_file"
24+
printf "%20s %20s %30s %30s \n" "remote" "branch" "path" "repo name"
25+
printf "%20s %20s %30s %30s \n" "------" "------" "----" "---------"
26+
fi
27+
while read -r line; do
28+
line_is_good=1
29+
remote=$(echo "$line" | grep remote | cut -d"=" -f2)
30+
sha_key_used=0
31+
COSHAKEY=""
32+
for field in $line; do
33+
if [[ "$field" =~ remote=\"([^\"]*)\" ]]; then
34+
remote=${BASH_REMATCH[1]}
35+
fi
36+
if [[ "$field" =~ name=\"([^\"]*)\" ]]; then
37+
name=${BASH_REMATCH[1]}
38+
name=${name%*.git}
39+
fi
40+
if [[ "$field" =~ path=\"([^\"]*)\" ]]; then
41+
path=${BASH_REMATCH[1]}
42+
fi
43+
if [[ "$field" =~ upstream=\"([^\"]*)\" ]]; then
44+
COBRANCH=${BASH_REMATCH[1]}
45+
sha_key_used=1
46+
fi
47+
if [[ "$field" =~ revision=\"([^\"]*)\" ]] && [ "$sha_key_used" == 1 ]; then
48+
COSHAKEY=${BASH_REMATCH[1]}
49+
elif [[ "$field" =~ revision=\"([^\"]*)\" ]]; then
50+
COBRANCH=${BASH_REMATCH[1]}
51+
fi
52+
done
53+
if [ "$remote" == "roc" ] ; then
54+
repo_web_location=$GITROC
55+
elif [ "$remote" == "gerritgit" ] ; then
56+
repo_web_location=$GITGERRIT
57+
elif [ "$remote" == "hwloc" ] ; then
58+
repo_web_location=$GITHWLOC
59+
elif [ "$remote" == "githubemu-lightning" ] ; then
60+
repo_web_location=$GITLIGHTNINGINTERNAL
61+
else
62+
line_is_good=0
63+
fi
64+
if [ "$line_is_good" == 1 ] ; then
65+
printf "%20s %20s %30s %30s\n" "$remote" "$COBRANCH" "$path" "$name"
66+
fi # end line_is_good
67+
done <"$tmpfile"
68+
rm "$tmpfile"
69+
70+
cd $_curdir
71+
exit
72+

tr_aomp/tr_list_submodules.sh

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
#!/bin/bash
2+
#
3+
# tr_list_submodules.sh
4+
#
5+
6+
_workdir=${1:-/work}
7+
_aomprepodir=$_workdir/$USER/git/tr_aomp
8+
_therockdir=$_aomprepodir/TheRock
9+
_curdir=$PWD
10+
11+
cd $_therockdir
12+
if [ ! -d .git ] ; then
13+
echo "ERROR: Directory $_therockdir is not a git clone." >&2
14+
echo " Run $0 from TheRock root directory." >&2
15+
exit 1
16+
fi
17+
18+
# Collect info from aomp manifest which is read by tr_list_aomp_branches.sh
19+
_aomp_repos_temp=()
20+
for _line in `$_aomprepodir/aomp/tr_aomp/tr_list_aomp_branches.sh | awk '{print $2 ":" $4}' | tr -d '"' ` ; do
21+
_aomp_repos_temp+=($_line)
22+
done
23+
# Fix certain aomp reponames
24+
aomp_repos=()
25+
for _repo in ${_aomp_repos_temp[@]} ; do
26+
_aomp_branch_name=${_repo%:*}
27+
_aomp_reponame=${_repo#*:}
28+
if [ "$_aomp_reponame" == "hip" ] ; then
29+
_aomp_reponame="HIP"
30+
elif [ "$_aomp_reponame" == "llvm-project" ] ; then
31+
_aomp_reponame="amd-llvm"
32+
elif [ "$_aomp_reponame" == "rocprof-trace-decoder" ] ; then
33+
_aomp_reponame="rocprof-trace-decoder/binaries"
34+
fi
35+
aomp_repos+=("$_aomp_branch_name:$_aomp_reponame")
36+
done
37+
38+
submodules=()
39+
for _line in `git submodule | awk '{print $2}'` ; do
40+
_category=`echo $_line | cut -d"/" -f1`
41+
cd $_therockdir
42+
if [ -d $_category ] ; then
43+
_dir=$_line
44+
_reponame=${_dir##*/}
45+
if [ "$_reponame" == "binaries" ] ; then
46+
_reponame=${_dir#*/}
47+
fi
48+
# search for the branch we want for this submodule
49+
cd $_therockdir/$_dir
50+
_aomp_branch_name=""
51+
for _repo in ${aomp_repos[@]} ; do
52+
_aomp_reponame=${_repo#*:}
53+
if [ $_reponame == $_aomp_reponame ] ; then
54+
_aomp_branch_name=${_repo%:*}
55+
fi
56+
done
57+
if [ -z "$_aomp_branch_name" ] ; then
58+
echo "WARNING: NO AOMP REPO FOR SUBMODULE:$_reponame $_dir" >&2
59+
else
60+
submodules+=($_reponame:$_category:$_dir:$_aomp_branch_name)
61+
fi
62+
fi
63+
done
64+
65+
for _repo in ${aomp_repos[@]} ; do
66+
_aomp_reponame=${_repo#*:}
67+
_aomp_submodule_entry=""
68+
for _submodule in ${submodules[@]} ; do
69+
_reponame=`echo $_submodule | cut -d":" -f1`
70+
if [ "$_aomp_reponame" == "$_reponame" ] ; then
71+
_aomp_submodule_entry=_submodule
72+
fi
73+
done
74+
if [ -z "$_aomp_submodule_entry" ] ; then
75+
echo "WARNING: NO SUBMODULE FOR AOMP REPO $_aomp_reponame" >&2
76+
fi
77+
done
78+
79+
joined=()
80+
for _submodule in ${submodules[@]} ; do
81+
_dir=`echo $_submodule | cut -d":" -f3`
82+
_aomp_branch_name=`echo $_submodule | cut -d":" -f4`
83+
cd $_therockdir/$_dir
84+
if [ -f .git ] ; then
85+
_mod_dir=`cat .git | cut -d":" -f2`
86+
_therockdir_branch_name=`cat $_mod_dir/HEAD | cut -d":" -f2 | awk '{print $1}'`
87+
_therockdir_branch_name=${_therockdir_branch_name#refs\/heads\/*}
88+
_entry_colons="$_dir":"$_therockdir_branch_name":"$_aomp_branch_name"
89+
joined+=("$_entry_colons")
90+
else
91+
echo "WARNING: SUBMODULE $_dir DOES NOT HAVE A .git FILE AT $_therockdir/$_dir/.git" >&2
92+
fi
93+
done
94+
95+
for _join in ${joined[@]} ; do
96+
_dir=`echo $_join | cut -d":" -f1`
97+
_therock_branch_name=`echo $_join | cut -d":" -f2`
98+
_aomp_branch_name=`echo $_join | cut -d":" -f3`
99+
if [ "$_aomp_branch_name" == "$_therock_branch_name" ] ; then
100+
printf "%40s %24s\n" "$_dir" "$_therock_branch_name"
101+
else
102+
echo "WARNING: $_dir reset branch $_therock_branch_name to $_aomp_branch_name" >&2
103+
fi
104+
done
105+
cd $_curdir

0 commit comments

Comments
 (0)