Skip to content
Draft
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
38 changes: 28 additions & 10 deletions .github/workflows/ci-fusilli-plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,24 +65,42 @@ jobs:
- name: checkout fusilli-plugin
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

- name: install hipdnn_sdk dependencies
working-directory: ${{ env.FUSILLI_PLUGIN_DIR }}
run: |
${{ env.FUSILLI_DIR }}/build_tools/docker/exec_docker_ci.sh \
bash -c "./build_tools/install_deps_from_source.sh"

- name: install fusilli
working-directory: ${{ env.FUSILLI_DIR }}
run: |
./build_tools/docker/exec_docker_ci.sh \
bash -c "cmake -GNinja -S. -Bbuild \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_C_COMPILER=clang-21 \
-DCMAKE_CXX_COMPILER=clang++-21 \
-DCMAKE_INSTALL_PREFIX=/workspace/.cache/docker/fusilli-install \
-DIREERuntime_DIR=/workspace/.cache/docker/iree-install/lib/cmake/IREE \
-DFUSILLI_BUILD_TESTS=OFF \
-DFUSILLI_BUILD_BENCHMARKS=OFF \
-DFUSILLI_SYSTEMS_AMDGPU=ON && \
cmake --build build && \
cmake --install build"

- name: build fusilli-plugin
# The docker container mounts the working directory as a volume, so we
# must run from github.workspace to ensure fusilli-plugin can reach into
# ../sharkfuser for its fusilli dependency.
working-directory: ${{ github.workspace }}
working-directory: ${{ env.FUSILLI_PLUGIN_DIR }}
run: |
${{ env.FUSILLI_DIR }}/build_tools/docker/exec_docker_ci.sh \
bash -c "cd fusilli-plugin && \
cmake -GNinja -S. -Bbuild \
${{ matrix.fusilli-plugin-cmake-options }} && \
bash -c "cmake -GNinja -S. -Bbuild \
${{ matrix.fusilli-plugin-cmake-options }} \
-DCMAKE_PREFIX_PATH='/workspace/.cache/docker/therock;/workspace/.cache/docker/iree-install;/workspace/.cache/docker/fusilli-install' && \
cmake --build build --target all"

- name: Test fusilli-plugin
working-directory: ${{ github.workspace }}
working-directory: ${{ env.FUSILLI_PLUGIN_DIR }}
run: |
${{ env.FUSILLI_DIR }}/build_tools/docker/exec_docker_ci.sh \
bash -c "cd fusilli-plugin && \
ctest --test-dir build --output-on-failure --extra-verbose --timeout 120"
bash -c "ctest --test-dir build --output-on-failure --extra-verbose --timeout 120"

# Depends on all other jobs to provide an aggregate job status.
ci_fusilli_plugin_summary:
Expand Down
22 changes: 15 additions & 7 deletions fusilli-plugin/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,25 @@ include(FusilliPluginDependencyUtils)
set(FUSILLI_PLUGIN_NAME fusilli_plugin)
set(FUSILLI_PLUGIN_ENGINE_ID 1001)

# Options
option(FUSILLI_PLUGIN_USE_LOCAL_FUSILLI "Use local Fusilli build from ../sharkfuser" ON)

# Dependencies
set(HIP_PLATFORM "amd")
find_package(hip REQUIRED)
find_package(IREERuntime CONFIG REQUIRED)
find_package(hipdnn_sdk CONFIG REQUIRED)
find_package(Fusilli CONFIG REQUIRED)

# GTest is still fetched since TheRock doesn't provide it
fusilli_plugin_dependency(GTest GTEST_VERSION 1.16.0)
fusilli_plugin_dependency(IREERuntime)
fusilli_plugin_dependency(hipdnn_frontend HIP_DNN_HASH 4e0a0452cfcb8fdb86e9c40a6e43debab4d4ecbc)
fusilli_plugin_dependency(Fusilli USE_LOCAL ${FUSILLI_PLUGIN_USE_LOCAL_FUSILLI})

# Define hipDNN variables that were previously provided by building hipDNN
# These are needed since hipdnn_sdk config doesn't export them
if(NOT DEFINED HIPDNN_PLUGIN_ENGINE_SUBDIR)
set(HIPDNN_PLUGIN_ENGINE_SUBDIR "hipdnn_plugins/engines")
endif()
if(NOT DEFINED HIPDNN_BUILD_PLUGIN_ENGINE_DIR)
set(HIPDNN_BUILD_PLUGIN_ENGINE_DIR
"${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}/${HIPDNN_PLUGIN_ENGINE_SUBDIR}")
endif()

# Includes
include_directories(include)
Expand All @@ -45,7 +54,6 @@ include_directories(include)
add_library(${FUSILLI_PLUGIN_NAME} SHARED
src/fusilli_plugin.cpp
)
target_compile_options(${FUSILLI_PLUGIN_NAME} PRIVATE ${HIPDNN_WARNING_COMPILE_OPTIONS})
target_link_libraries(${FUSILLI_PLUGIN_NAME} PRIVATE hipdnn_sdk hip::host fusilli::fusilli)
target_compile_definitions(${FUSILLI_PLUGIN_NAME} PRIVATE
FUSILLI_PLUGIN_NAME="${FUSILLI_PLUGIN_NAME}"
Expand Down
123 changes: 6 additions & 117 deletions fusilli-plugin/build_tools/cmake/FusilliPluginDependencyUtils.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,9 @@
# fusilli_plugin_dependency(DEP_NAME [args...])
#
# `fusilli_plugin_dependency` routes to lower level `_fetch_X` macros to
# actually fetch dependency `X`. Each `_fetch_X` macro preferentially
# `find_package`s installed/system versions of packages and falls back to
# vendoring dependencies in the build tree with `FetchContent`.
# actually fetch dependency `X` using FetchContent.
#
# Supported dependencies: GTest, hipdnn_frontend, Fusilli, IREERuntime
# Supported dependencies: GTest
#
#===------------------------------------------------------------------------===#

Expand All @@ -25,9 +23,8 @@ cmake_minimum_required(VERSION 3.25.2)
include(FetchContent)

# Provide a fusilli plugin dependency. `fusilli_plugin_dependency` will
# preferentially use system version (available through `find_package`) of a
# dependency, and fall back to building local copy with `FetchContent` +
# configuration.
# fetch the dependency using FetchContent for dependencies not available
# as system packages.
#
# fusilli_plugin_dependency(
# DEP_NAME
Expand All @@ -36,14 +33,11 @@ include(FetchContent)
#
# DEP_NAME
# Supported dependencies:
# GTest
# hipdnn_frontend
# Fusilli
# IREERuntime
# GTest - Fetched via FetchContent (not provided by TheRock)
#
# <dependency-specific args>
# The `_fetch_X` macro for dependency X defines the available options.
# Examples: GTEST_VERSION for GTest, HIP_DNN_HASH for hipdnn_frontend
# Example: GTEST_VERSION for GTest
#
function(fusilli_plugin_dependency DEP_NAME)
# Set indent for logging, any logs from dep "X" will be prefixed with [X].
Expand Down Expand Up @@ -112,108 +106,3 @@ macro(_fetch_GTest)
set(BUILD_GMOCK OFF)
FetchContent_MakeAvailable(GTest)
endmacro()

# hipdnn_frontend
#
# NOTE: we currently build hipDNN as a CMake source dependency (via
# FetchContent) rather than using find_package() to locate an installed version.
# The hipDNN build automatically handles transitive dependencies, which is
# quite convenient.
#
# HIP_DNN_HASH
# Git commit hash or tag to fetch
macro(_fetch_hipdnn_frontend)
cmake_parse_arguments(
ARG # prefix for parsed variables
"" # options (flags)
"HIP_DNN_HASH;LOCAL_PATH" # single-value arguments
"" # multi-value arguments
${ARGN}
)
if(NOT DEFINED ARG_LOCAL_PATH AND NOT DEFINED ARG_HIP_DNN_HASH)
message(FATAL_ERROR "Required argument: one of LOCAL_PATH or HIP_DNN_HASH")
endif()

if(DEFINED ARG_LOCAL_PATH AND DEFINED ARG_HIP_DNN_HASH)
message(FATAL_ERROR "Argument error: passing both LOCAL_PATH and HIP_DNN_HASH is ambiguous.")
endif()

if (DEFINED ARG_HIP_DNN_HASH)
FetchContent_Declare(
hipdnn_frontend
# location of hipdnn CMakeLists.txt in rocm-libraries
SOURCE_SUBDIR projects/hipdnn
# rocm-libraries takes 10+ min to fetch without sparse checkout
# (even with a shallow clone). We provide a custom
# DOWNLOAD_COMMAND until such time as CMAKE natively supports
# sparse checkouts.
DOWNLOAD_COMMAND
git clone --no-checkout --filter=blob:none https://github.com/ROCm/rocm-libraries.git <SOURCE_DIR> &&
cd <SOURCE_DIR> &&
git sparse-checkout init --cone &&
git sparse-checkout set projects/hipdnn &&
git checkout ${ARG_HIP_DNN_HASH}
)
else()
FetchContent_Declare(
hipdnn_frontend
SOURCE_DIR ${ARG_LOCAL_PATH}
)
endif()

set(HIP_DNN_BUILD_BACKEND ON)
set(HIP_DNN_BUILD_FRONTEND ON)
set(HIP_DNN_SKIP_TESTS ON)
set(HIP_DNN_BUILD_PLUGINS OFF)
set(ENABLE_CLANG_TIDY OFF)
# PIC required to link static library into shared object.
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
FetchContent_MakeAvailable(hipdnn_frontend)
endmacro()

# IREERuntime
#
# NOTE: For now, we're not providing a FetchContent fallback for IREERuntime.
# Fusilli expects that the system provides this dependency, and we're
# keeping the projects in sync as much as possible for now. If you're
# running in the fusilli docker container (described in sharkfuser README)
# passing -DIREERuntime_DIR=/workspace/.cache/docker/iree/build/lib/cmake/IREE
# should be enough.
macro(_fetch_IREERuntime)
find_package(IREERuntime CONFIG REQUIRED)
endmacro()

# Fusilli
#
# USE_LOCAL
# If set, uses local source from ../sharkfuser directory. Without USE_LOCAL,
# requires system installation via find_package.
macro(_fetch_Fusilli)
cmake_parse_arguments(
ARG # prefix for parsed variables
"" # options (flags)
"USE_LOCAL" # single-value arguments
"" # multi-value arguments
${ARGN}
)

if(NOT DEFINED ARG_USE_LOCAL)
message(FATAL_ERROR "USE_LOCAL argument is required")
endif()

if(NOT ARG_USE_LOCAL)
# For the time being we're keeping fusilli-plugin setup as in sync as
# possible with fusilli.
message(FATAL_ERROR "Only LOCAL builds are supported currently")
endif()

message(STATUS "Using local Fusilli build from ../sharkfuser")
FetchContent_Declare(
Fusilli
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../sharkfuser
)
set(FUSILLI_BUILD_TESTS OFF)
set(FUSILLI_BUILD_BENCHMARKS OFF)
set(FUSILLI_SYSTEMS_AMDGPU ON)
FetchContent_MakeAvailable(Fusilli)
endmacro()
73 changes: 73 additions & 0 deletions fusilli-plugin/build_tools/install_deps_from_source.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
#!/bin/bash
# Install hipdnn_sdk dependencies from source
# These dependencies need CMake config files which aren't provided by apt packages

set -e

echo "Installing dependencies (using CMake default install location)..."

# Create temporary build directory
BUILD_DIR="/tmp/fusilli-plugin-deps-build-$$"
mkdir -p "$BUILD_DIR"
cd "$BUILD_DIR"

# Number of parallel jobs
JOBS="${JOBS:-$(nproc)}"

echo "Using $JOBS parallel jobs for building"

# Install flatbuffers
echo "========================================="
echo "Building flatbuffers..."
echo "========================================="
git clone --depth 1 --branch v25.9.23 https://github.com/google/flatbuffers.git
cd flatbuffers
cmake -S. -Bbuild \
-DCMAKE_BUILD_TYPE=Release \
-DFLATBUFFERS_BUILD_TESTS=OFF \
-DFLATBUFFERS_BUILD_FLATHASH=OFF \
-DFLATBUFFERS_BUILD_FLATC=ON
cmake --build build -j$JOBS
cmake --install build
cd ..
echo "flatbuffers installed!"

# Install spdlog
echo "========================================="
echo "Building spdlog..."
echo "========================================="
git clone --depth 1 --branch v1.16.0 https://github.com/gabime/spdlog.git
cd spdlog
cmake -S. -Bbuild \
-DCMAKE_BUILD_TYPE=Release \
-DSPDLOG_BUILD_EXAMPLE=OFF \
-DSPDLOG_BUILD_TESTS=OFF
cmake --build build -j$JOBS
cmake --install build
cd ..
echo "spdlog installed!"

# Install nlohmann_json
echo "========================================="
echo "Building nlohmann_json..."
echo "========================================="
git clone --depth 1 --branch v3.11.3 https://github.com/nlohmann/json.git
cd json
cmake -S. -Bbuild \
-DCMAKE_BUILD_TYPE=Release \
-DJSON_BuildTests=OFF
cmake --build build -j$JOBS
cmake --install build
cd ..
echo "nlohmann_json installed!"

# Clean up
echo "========================================="
echo "Cleaning up..."
echo "========================================="
cd /
rm -rf "$BUILD_DIR"

echo "========================================="
echo "All dependencies installed successfully!"
echo "========================================="
1 change: 1 addition & 0 deletions fusilli-plugin/test/integration/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

include(GoogleTest)
find_package(Threads REQUIRED)
find_package(hipdnn_frontend CONFIG REQUIRED)

# Integration tests
add_executable(fusilli_plugin_integration_tests
Expand Down
Loading