Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,7 @@
path = base/amdsmi
url = https://github.com/ROCm/amdsmi.git
branch = amd-staging
[submodule "amd-mesa"]
path = third-party/sysdeps/linux/amd-mesa/mesa-fork
url = https://github.com/ROCm/mesa-fork.git
branch = amd-decode-only
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ instructions and configurations for alternatives.
```bash
# Install Ubuntu dependencies
sudo apt update
sudo apt install gfortran git ninja-build cmake g++ pkg-config xxd patchelf automake libtool python3-venv python3-dev libegl1-mesa-dev
sudo apt install gfortran git ninja-build cmake g++ pkg-config xxd patchelf automake libtool python3-venv python3-dev libva-dev libegl1-mesa-dev

# Clone the repository
git clone https://github.com/ROCm/TheRock.git
Expand Down
21 changes: 21 additions & 0 deletions build_tools/fetch_sources.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ def get_enabled_projects(args) -> list[str]:
projects.extend(["rocm-systems"])
if args.include_ml_frameworks:
projects.extend(args.ml_framework_projects)
if args.include_rocm_media:
projects.extend(args.rocm_media_projects)
return projects


Expand Down Expand Up @@ -317,6 +319,12 @@ def main(argv):
action=argparse.BooleanOptionalAction,
help="Include machine learning frameworks that are part of ROCM",
)
parser.add_argument(
"--include-rocm-media",
default=True,
action=argparse.BooleanOptionalAction,
help="Include media projects that are part of ROCM",
)
parser.add_argument(
"--system-projects",
nargs="+",
Expand Down Expand Up @@ -353,6 +361,19 @@ def main(argv):
]
),
)
parser.add_argument(
"--rocm-media-projects",
nargs="+",
type=str,
default=(
[]
if is_windows()
else [
# Linux only projects.
"amd-mesa",
]
),
)
parser.add_argument(
# projects that use DVC to manage large files
"--dvc-projects",
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ PyYAML==6.0.2
setuptools>=80.9.0
tomli==2.2.1; python_version <= '3.10'
pytest-cmake==0.13.0
mako>=1.1.3

# hipBLASLt deps
joblib>=1.4.2
Expand Down
2 changes: 2 additions & 0 deletions third-party/sysdeps/linux/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/../common/zstd" "${CMAKE_CURRENT_B

# System deps that depend on the above.
add_subdirectory(elfutils)
add_subdirectory(amd-mesa)

therock_provide_artifact(sysdeps
TARGET_NEUTRAL
Expand All @@ -29,4 +30,5 @@ therock_provide_artifact(sysdeps
therock-sqlite3
therock-zlib
therock-zstd
therock-amd-mesa
)
76 changes: 76 additions & 0 deletions third-party/sysdeps/linux/amd-mesa/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
if(NOT CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
# setup submodule project
set(_source_dir "${CMAKE_CURRENT_SOURCE_DIR}/mesa-fork")

therock_cmake_subproject_declare(therock-amd-mesa
EXTERNAL_SOURCE_DIR .
BINARY_DIR build
NO_MERGE_COMPILE_COMMANDS
BACKGROUND_BUILD
OUTPUT_ON_FAILURE
CMAKE_ARGS
"-DSOURCE_DIR=${_source_dir}"
"-DPATCHELF=${PATCHELF}"
"-DMESON_BUILD=${MESON_BUILD}"
"-DPython3_EXECUTABLE=${Python3_EXECUTABLE}"
RUNTIME_DEPS
therock-libdrm
INSTALL_DESTINATION
lib/rocm_sysdeps
INTERFACE_LINK_DIRS
lib/rocm_sysdeps/lib
INTERFACE_INSTALL_RPATH_DIRS
lib/rocm_sysdeps/lib
INTERFACE_PKG_CONFIG_DIRS
lib/rocm_sysdeps/lib/pkgconfig
)

therock_cmake_subproject_activate(therock-amd-mesa)

therock_test_validate_shared_lib(
PATH build/dist/lib/rocm_sysdeps/lib
LIB_NAMES libgallium_drv_video.so radeonsi_drv_video.so
)

return()
endif()

# Otherwise, this is the sub-project build.
cmake_minimum_required(VERSION 3.25)
project(MESA_BUILD)
if(NOT PATCHELF OR NOT MESON_BUILD)
message(FATAL_ERROR "Missing PATCHELF or MESON_BUILD from super-project")
endif()

add_custom_target(
meson_build ALL
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
COMMAND
"${CMAKE_COMMAND}" -E rm -rf -- "${CMAKE_INSTALL_PREFIX}"
COMMAND
"${CMAKE_COMMAND}" -E env
"LDFLAGS=-Wl,-rpath='$$ORIGIN' -Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/version.lds"
--
"${MESON_BUILD}" setup
--reconfigure
--prefix "/"
-Dpkgconfig.relocatable=true
-Dlibdir=lib
-Dva-libs-path="/lib"
# -Dallow-fallback-for=libva # NOTE: Use local build of VA library
-Dpkg_config_path="${CMAKE_CURRENT_BINARY_DIR}"/../../../libdrm/build/dist/lib/rocm_sysdeps/lib/pkgconfig
-Damd-decode-only=true # NOTE: enable decode only for TheRock
"${CMAKE_CURRENT_BINARY_DIR}"
"${CMAKE_CURRENT_SOURCE_DIR}/mesa-fork"
COMMAND
"${MESON_BUILD}" compile --verbose
COMMAND
"${CMAKE_COMMAND}" -E env "DESTDIR=${CMAKE_INSTALL_PREFIX}" --
"${MESON_BUILD}" install
COMMAND
"${CMAKE_COMMAND}" -E env
"PATCHELF=${PATCHELF}"
"THEROCK_SOURCE_DIR=${THEROCK_SOURCE_DIR}"
"Python3_EXECUTABLE=${Python3_EXECUTABLE}" --
"${CMAKE_CURRENT_SOURCE_DIR}/patch_install.sh" ${CMAKE_INSTALL_PREFIX}
)
1 change: 1 addition & 0 deletions third-party/sysdeps/linux/amd-mesa/mesa-fork
Submodule mesa-fork added at e541a1
13 changes: 13 additions & 0 deletions third-party/sysdeps/linux/amd-mesa/patch_install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash
# Patches installed binaries from the external build system.
# Args: install_dir patchelf_binary
set -e

PREFIX="${1:?Expected install prefix argument}"
PATCHELF="${PATCHELF:-patchelf}"
THEROCK_SOURCE_DIR="${THEROCK_SOURCE_DIR:?THEROCK_SOURCE_DIR not defined}"
Python3_EXECUTABLE="${Python3_EXECUTABLE:?Python3_EXECUTABLE not defined}"

"$Python3_EXECUTABLE" "$THEROCK_SOURCE_DIR/build_tools/patch_linux_so.py" \
--patchelf "${PATCHELF}" --add-prefix rocm_sysdeps_ \
$PREFIX/lib/libgallium_drv_video.so
3 changes: 3 additions & 0 deletions third-party/sysdeps/linux/amd-mesa/version.lds
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
AMDROCM_SYSDEPS_1.0 {
global: *;
};
4 changes: 4 additions & 0 deletions third-party/sysdeps/linux/artifact.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ include = [
"**/share/**",
]

# amd-mesa
[components.dev."third-party/sysdeps/linux/amd-mesa/build/stage"]
[components.lib."third-party/sysdeps/linux/amd-mesa/build/stage"]

# liblzma
[components.dev."third-party/sysdeps/linux/liblzma/build/stage"]
[components.lib."third-party/sysdeps/linux/liblzma/build/stage"]
Expand Down
Loading