From 5891e2ae799886440a2b0e23e1b55b8ea68cf5f3 Mon Sep 17 00:00:00 2001 From: John Shumway Date: Mon, 20 Oct 2025 07:54:09 -0700 Subject: [PATCH] [CK_BUILDER] Add experimental builder directory and configuration for composable_kernel (#3043) Add experimental builder infrastructure for composable_kernel - Add experimental/builder directory with README documentation. - Create initial test infrastructure with CMakeLists.txt and placeholder test. - Update root CMakeLists.txt to support CK_EXPERIMENTAL_BUILDER option. - Update .gitignore to not treat `experimental/builder` as a CMake build directory. This establishes the directory structure for a high-level builder pattern that will provide a semantically-clear interface for constructing CK operations, with initial focus on convolution kernels for MIOpen integration. [ROCm/composable_kernel commit: f18b79f328df35e2305416b890dbb9eb561fa9e2] --- .gitignore | 8 +++-- CMakeLists.txt | 5 +++ cmake/gtest.cmake | 1 + experimental/builder/CMakeLists.txt | 3 ++ experimental/builder/README.md | 34 +++++++++++++++++++ .../include/ck_tile/builder/CMakeLists.txt | 1 + experimental/builder/test/CMakeLists.txt | 20 +++++++++++ .../builder/test/test_conv_builder.cpp | 11 ++++++ 8 files changed, 81 insertions(+), 2 deletions(-) create mode 100644 experimental/builder/CMakeLists.txt create mode 100644 experimental/builder/README.md create mode 100644 experimental/builder/include/ck_tile/builder/CMakeLists.txt create mode 100644 experimental/builder/test/CMakeLists.txt create mode 100644 experimental/builder/test/test_conv_builder.cpp diff --git a/.gitignore b/.gitignore index e4dd8f7513..bcc5888b7f 100644 --- a/.gitignore +++ b/.gitignore @@ -36,7 +36,7 @@ tags # Editors .vscode -# build-in-source directory +# build-in-source directory (see exceptions below) build* # emacs temporary/backup files @@ -58,7 +58,7 @@ _doxygen/ docs/doxygen/html docs/doxygen/xml -# JetBrains IDE +# JetBrains IDE (see build* exceptions below) .idea/ cmake-build*/ build*/ @@ -71,3 +71,7 @@ __pycache__/ .cache/ +# Exceptions to build* patterns above +# The experimental/builder directory should be tracked despite matching build* +!experimental/builder +!experimental/builder/** diff --git a/CMakeLists.txt b/CMakeLists.txt index f4d3a83c34..310e2a6576 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -37,6 +37,7 @@ include(CTest) option(ENABLE_CLANG_CPP_CHECKS "Enables clang tidy, cppcheck" ON) option(MIOPEN_REQ_LIBS_ONLY "Build only the MIOpen required libraries" OFF) +option(CK_EXPERIMENTAL_BUILDER "Enable experimental builder" OFF) option(BUILD_MHA_LIB "Build the static library for flash attention" OFF) # Usage: for customized Python location cmake -DCK_USE_ALTERNATIVE_PYTHON="/opt/Python-3.8.13/bin/python3.8" @@ -692,6 +693,10 @@ if (NOT MIOPEN_REQ_LIBS_ONLY) add_subdirectory(profiler) endif() +if (CK_EXPERIMENTAL_BUILDER) + add_subdirectory(experimental/builder) +endif() + if(CK_USE_CODEGEN AND (SUPPORTED_GPU_TARGETS MATCHES "gfx9" OR GPU_ARCHS)) add_subdirectory(codegen) endif() diff --git a/cmake/gtest.cmake b/cmake/gtest.cmake index 41e2fa2cc0..9336d47e71 100644 --- a/cmake/gtest.cmake +++ b/cmake/gtest.cmake @@ -1,3 +1,4 @@ +include_guard(GLOBAL) include(FetchContent) set(GOOGLETEST_DIR "" CACHE STRING "Location of local GoogleTest repo to build against") diff --git a/experimental/builder/CMakeLists.txt b/experimental/builder/CMakeLists.txt new file mode 100644 index 0000000000..103acbad55 --- /dev/null +++ b/experimental/builder/CMakeLists.txt @@ -0,0 +1,3 @@ +if(BUILD_TESTING) + add_subdirectory(test) +endif() diff --git a/experimental/builder/README.md b/experimental/builder/README.md new file mode 100644 index 0000000000..d8b8757dc2 --- /dev/null +++ b/experimental/builder/README.md @@ -0,0 +1,34 @@ +# Builder + +This directory contains the experimental builder feature for composable_kernel. + +* Status: In development (October - November 2025) + +## Overview + +The builder provides a high-level, semantically-clear interface for constructing composable kernel operations, with an initial focus on convolution kernels for MIOpen. It leverages modern C++20 features (such as POD structs as non-type template parameters, concepts, and designated initializers) to simplify kernel instantiation and improve developer experience. + +This project is a prototype for a more general builder pattern for all of composable_kernel (CK) and CKTile, but is currently limited to formalizing the interface between MIOpen and CK. + +## Directory Structure + +- `include/ck_tile/builder/` + Core builder headers and public API. +- `test/` + Unit tests and example usage of the builder pattern. +- `CMakeLists.txt` + CMake configuration for building the experimental builder and its tests. + +## CMake Configuration + +To enable the experimental builder, configure your build with: + +```sh +cmake -DCK_EXPERIMENTAL_BUILDER=ON -DCMAKE_CXX_STANDARD=20 ... +``` +## Building and testing + +During development, build and test from the CK build directory with +```sh +ninja test_conv_builder && bin/test_conv_builder +``` diff --git a/experimental/builder/include/ck_tile/builder/CMakeLists.txt b/experimental/builder/include/ck_tile/builder/CMakeLists.txt new file mode 100644 index 0000000000..f20b5d54ec --- /dev/null +++ b/experimental/builder/include/ck_tile/builder/CMakeLists.txt @@ -0,0 +1 @@ +# Empty placeholder until we add library code. diff --git a/experimental/builder/test/CMakeLists.txt b/experimental/builder/test/CMakeLists.txt new file mode 100644 index 0000000000..5890aa8dcd --- /dev/null +++ b/experimental/builder/test/CMakeLists.txt @@ -0,0 +1,20 @@ + +include(gtest) + +# Helper function to create a gtest executable with common properties +function(add_ck_builder_test test_name) + add_executable(${test_name} ${ARGN}) + target_compile_features(${test_name} PRIVATE cxx_std_20) + target_include_directories(${test_name} PRIVATE + "${PROJECT_SOURCE_DIR}/experimental/builder/include" + "${PROJECT_SOURCE_DIR}/include" + ) + target_compile_options(${test_name} PRIVATE + -Wno-global-constructors + -Wno-c++20-compat + ) + target_link_libraries(${test_name} PRIVATE GTest::gtest_main GTest::gmock) +endfunction() + +add_ck_builder_test(test_conv_builder + test_conv_builder.cpp) diff --git a/experimental/builder/test/test_conv_builder.cpp b/experimental/builder/test/test_conv_builder.cpp new file mode 100644 index 0000000000..4ec189daa4 --- /dev/null +++ b/experimental/builder/test/test_conv_builder.cpp @@ -0,0 +1,11 @@ +#include + +class ConvBuilderTest : public ::testing::Test +{ +}; + +TEST_F(ConvBuilderTest, PlaceholderTest) +{ + // TODO: Implement actual test + EXPECT_TRUE(true); +}