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
8 changes: 4 additions & 4 deletions .github/copilot-instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ cmake --build build --config Release --parallel 32
- **CUDA >= 13**: All architectures allowed.

### Windows-Specific Notes
- CI uses self-hosted runners with LLVM 21.1.0 at `D:/clang+llvm-21.1.0-x86_64-pc-windows-msvc/bin/`.
- CI uses self-hosted runners with LLVM 23.1.0 at `D:/clang+llvm-23.1.0-x86_64-pc-windows-msvc/bin/`.
- The Ninja generator requires a workaround: after `cmake`, `rules.ninja` may contain a wrong NVCC path that must be patched (see `cmake-windows-amd64.yml`).
- The VS Developer Shell (`Enter-VsDevShell`) must be activated for both configure and build steps on Windows.
- `utf8cp.manifest` is embedded into test executables on Windows for UTF-8 codepage support.
Expand Down Expand Up @@ -222,17 +222,17 @@ Each operation type exposes a `static build(...)` factory method returning an in
All three workflow files trigger on **pull requests to `main`** (push triggers are commented out). All runners are **self-hosted**.

### Linux (cmake-linux-amd64.yml, cmake-linux-arm64.yml)
- **Compilers**: `g++-13`, `clang++-21`
- **Compilers**: `g++-13`, `clang++-23`
- **CUDA**: 13.3 (via `/usr/local/cuda-<version>/bin/nvcc`)
- **CMake**: Custom installation at `/home/cudeiro/cmake-4.3.3-linux-x86_64/bin/` (added to PATH)
- **CMake**: Custom installation at `/home/cudeiro/cmake-4.4.2-linux-x86_64/bin/` (added to PATH)
- **Generator**: Ninja
- **Build type**: Release

### Windows (cmake-windows-amd64.yml)
- **Host compilers**: `cl` (MSVC), `clang-cl`
- **MSVC versions**: 14.44, 14.51 (via `-vcvars_ver`)
- **CUDA**: 13.0, 13.3 (NVCC at `%ProgramFiles%\NVIDIA GPU Computing Toolkit\CUDA\v<version>\bin\nvcc.exe`)
- **LLVM**: `D:/clang+llvm-21.1.0-x86_64-pc-windows-msvc/bin/` (added to PATH)
- **LLVM**: `D:/clang+llvm-23.1.0-x86_64-pc-windows-msvc/bin/` (added to PATH)
- **Generator**: Ninja
- **Workaround**: After CMake configure, `rules.ninja` may contain an empty NVCC path that is patched with PowerShell string replacement.

Expand Down
2 changes: 1 addition & 1 deletion .github/skills/fkl-build-and-test/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ int launch() { RUN_ALL_TESTS }
## CI Matrix

GitHub workflows build on `linux-amd64`, `linux-arm64` and `windows-amd64` using self-hosted runners.
- Linux builds against `g++-13` and `clang++-21`.
- Linux builds against `g++-13` and `clang++-23`.
- Windows builds against MSVC (`cl` versions 14.44 and 14.51) and `clang-cl`.
- Keep changes warning-clean on BOTH compilers: clang is a first-class compiler for FKL (single-step host+device compiles matter for downstream packaging).

Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/cmake-linux-arm64.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: CMake on Linux (ARM64)
name: CMake on Linux (CUDA ARM64)

on:
#push:
Expand All @@ -19,7 +19,7 @@ jobs:
include:
- host_compiler: "g++-13"
cuda_toolkit: "13.3"
- host_compiler: "clang++-21"
- host_compiler: "clang++-23"
cuda_toolkit: "13.3"


Expand All @@ -30,14 +30,14 @@ jobs:
id: strings
run: |
echo "build-output-dir=${{github.workspace}}/build" >> "$GITHUB_OUTPUT"
echo "PATH=$HOME/cmake-4.3.3-linux-aarch64/bin/:$PATH" >> "$GITHUB_ENV"
echo "PATH=$HOME/cmake-4.4.2-linux-aarch64/bin/:$PATH" >> "$GITHUB_ENV"
echo "CUDACXX=/usr/local/cuda-${{matrix.cuda_toolkit}}/bin/nvcc" >> "$GITHUB_ENV"
echo "CC=${{matrix.host_compiler}}" >> "$GITHUB_ENV"
echo "CXX=${{matrix.host_compiler}}" >> "$GITHUB_ENV"

- name: Configure CMake
run: |
cmake -G "Ninja" -B ${{steps.strings.outputs.build-output-dir}} -DCMAKE_BUILD_TYPE="Release" -S ${{github.workspace}}
cmake -G "Ninja" -DENABLE_HIP=OFF -DENABLE_CUDA=ON -B ${{steps.strings.outputs.build-output-dir}} -DCMAKE_BUILD_TYPE="Release" -S ${{github.workspace}}

- name: Build
run: |
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: CMake on Linux (x86_64)
name: CMake on Linux (CUDA x86_64)

on:
#push:
Expand All @@ -19,7 +19,7 @@ jobs:
include:
- host_compiler: "g++-13"
cuda_toolkit: "13.3"
- host_compiler: "clang++-21"
- host_compiler: "clang++-23"
cuda_toolkit: "13.3"


Expand All @@ -30,13 +30,13 @@ jobs:
id: strings
run: |
echo "build-output-dir=${{github.workspace}}/build" >> "$GITHUB_OUTPUT"
echo "PATH=$HOME/cmake-4.3.3-linux-x86_64/bin/:$PATH" >> "$GITHUB_ENV"
echo "PATH=$HOME/cmake-4.4.2-linux-x86_64/bin/:$PATH" >> "$GITHUB_ENV"
echo "CUDACXX=/usr/local/cuda-${{matrix.cuda_toolkit}}/bin/nvcc" >> "$GITHUB_ENV"
echo "CC=${{matrix.host_compiler}}" >> "$GITHUB_ENV"
echo "CXX=${{matrix.host_compiler}}" >> "$GITHUB_ENV"
- name: Configure CMake
run: |
cmake -G "Ninja" -B ${{steps.strings.outputs.build-output-dir}} -DCMAKE_BUILD_TYPE="Release" -S ${{github.workspace}}
cmake -G "Ninja" -DENABLE_HIP=OFF -DENABLE_CUDA=ON -B ${{steps.strings.outputs.build-output-dir}} -DCMAKE_BUILD_TYPE="Release" -S ${{github.workspace}}

- name: Build
run: |
Expand Down
49 changes: 49 additions & 0 deletions .github/workflows/cmake-linux-rocm-amd64.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: CMake on Linux (ROCM x86_64)

on:
#push:
# branches: [ $default-branch ]
pull_request:
branches: ["main"]

jobs:
build:
runs-on: [self-hosted, linux, x64, rocm]

strategy:
# Set fail-fast to false to ensure that feedback is delivered for all matrix combinations.
# Consider changing this to true when your workflow is stable.
fail-fast: false

matrix:
include:
- rocm_version: "10.0"

steps:
- uses: actions/checkout@v6
- name: Set reusable strings and path
# Turn repeated input strings (such as the build output directory) into step outputs. These step outputs can be used throughout the workflow file.
id: strings
run: |
echo "build-output-dir=${{github.workspace}}/build" >> "$GITHUB_OUTPUT"
ROCM_PATH=/opt/rocm/core-${{matrix.rocm_version}}
echo "ROCM_PATH=$ROCM_PATH" >> "$GITHUB_ENV"
echo "HIP_PATH=$ROCM_PATH" >> "$GITHUB_ENV"
echo "PATH=$HOME/cmake-4.4.2-linux-x86_64/bin/:$ROCM_PATH/bin:$PATH" >> "$GITHUB_ENV"
echo "CC=/opt/rocm/bin/amdclang" >> "$GITHUB_ENV"
echo "CXX=/opt/rocm/bin/amdclang++" >> "$GITHUB_ENV"
echo "HIPCXX=/opt/rocm/bin/amdclang++" >> "$GITHUB_ENV"
echo "LD_LIBRARY_PATH=/opt/rocm/core-${{matrix.rocm_version}}/lib:${LD_LIBRARY_PATH}" >> "$GITHUB_ENV"

- name: Configure CMake
run: |
cmake -G "Ninja" -DENABLE_HIP=ON -DENABLE_CUDA=OFF -B ${{steps.strings.outputs.build-output-dir}} -DCMAKE_BUILD_TYPE="Release" -S ${{github.workspace}}

- name: Build
run: |
cmake --build ${{ steps.strings.outputs.build-output-dir }} --config Release

- name: Test
working-directory: ${{ steps.strings.outputs.build-output-dir }}
run: |
ctest --build-config Release --output-junit test_results.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: CMake on Windows (x64)
name: CMake on Windows (CUDA x64)

on:
#push:
Expand Down Expand Up @@ -35,7 +35,7 @@ jobs:
id: strings
run: |
echo "build-output-dir=${{github.workspace}}/build" >> "$env:GITHUB_OUTPUT"
echo "D:/clang+llvm-21.1.0-x86_64-pc-windows-msvc/bin/" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
echo "D:/clang+llvm-23.1.0-x86_64-pc-windows-msvc/bin/" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
echo "CUDACXX=${env:ProgramFiles}\NVIDIA GPU Computing Toolkit\CUDA\v${{matrix.cuda_version}}\bin\nvcc.exe" >> "$env:GITHUB_ENV"
echo "CC=${{matrix.host_compiler}}" >> "$env:GITHUB_ENV"
echo "CXX=${{matrix.host_compiler}}" >> "$env:GITHUB_ENV"
Expand All @@ -51,7 +51,7 @@ jobs:
run: |
Import-Module (Get-ChildItem $env:VS_INSTALLATION_PATH -Recurse -File -Filter Microsoft.VisualStudio.DevShell.dll).FullName
Enter-VsDevShell -VsInstallPath $env:VS_INSTALLATION_PATH -SkipAutomaticLocation -DevCmdArguments $env:DEV_ARGS
cmake -G "Ninja" -B ${{steps.strings.outputs.build-output-dir}} -DCMAKE_BUILD_TYPE=Release -S ${{github.workspace}};
cmake -G "Ninja" -DENABLE_HIP=OFF -DENABLE_CUDA=ON -B ${{steps.strings.outputs.build-output-dir}} -DCMAKE_BUILD_TYPE=Release -S ${{github.workspace}};
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
#workaround for rules.ninja generating empty path
(Get-Content ${{steps.strings.outputs.build-output-dir}}\CMakeFiles\rules.ninja) -replace "\\nvcc\\bin\\nvcc.exe", "$env:CUDACXX" | Set-Content ${{steps.strings.outputs.build-output-dir}}\CMakeFiles\rules.ninja
Expand Down
59 changes: 59 additions & 0 deletions .github/workflows/cmake-windows-rocm-amd64.yml.disabled
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: CMake on Windows (ROCM x64)

on:
#push:
# branches: [ $default-branch ]
pull_request:
branches: ["main"]

jobs:
build:
runs-on: [self-hosted, windows, x64, rocm]

strategy:
# Set fail-fast to false to ensure that feedback is delivered for all matrix combinations. Consider changing this to true when your workflow is stable.
fail-fast: false
matrix:
include:
- msvc_env_version: "14.44" #HIP on windows is vs2022 only
rocm_version: "7.2"


steps:
- uses: actions/checkout@v6

- name: Set reusable strings
# Turn repeated input strings (such as the build output directory) into step outputs. These step outputs can be used throughout the workflow file.
id: strings
run: |
echo "build-output-dir=${{github.workspace}}/build" >> "$env:GITHUB_OUTPUT"
echo "CC=$env:HIP_PATH\bin\clang.exe" >> "$env:GITHUB_ENV"
echo "CXX=$env:HIP_PATH\bin\clang++.exe" >> "$env:GITHUB_ENV"
echo "HIPCXX=$env:HIP_PATH\bin\clang++.exe" >> "$env:GITHUB_ENV"
echo "CMAKE_PREFIX_PATH=$env:HIP_PATH" >> "$env:GITHUB_ENV"

- name: Detect visual studio installation (2022)
run: |
$vsWhere = "${Env:ProgramFiles(x86)}/Microsoft Visual Studio/Installer/vswhere.exe"
$vsInstallationPath = & $vsWhere -products * -version "[17.0,18.0)" -property installationPath
echo "VS_INSTALLATION_PATH=$vsInstallationPath" >> "$env:GITHUB_ENV"
echo "DEV_ARGS=-arch=x64 -vcvars_ver=${{matrix.msvc_env_version}}" >> "$env:GITHUB_ENV"

- name: Configure CMake
run: |
Import-Module (Get-ChildItem $env:VS_INSTALLATION_PATH -Recurse -File -Filter Microsoft.VisualStudio.DevShell.dll).FullName
Enter-VsDevShell -VsInstallPath $env:VS_INSTALLATION_PATH -SkipAutomaticLocation -DevCmdArguments $env:DEV_ARGS
cmake -G "Ninja" -DENABLE_HIP=ON -DENABLE_CUDA=OFF `
-DCMAKE_HIP_ARCHITECTURES="gfx1200" -B ${{steps.strings.outputs.build-output-dir}} -DCMAKE_BUILD_TYPE=Release -S ${{github.workspace}};
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }


- name: Build
run: |
Import-Module (Get-ChildItem $env:VS_INSTALLATION_PATH -Recurse -File -Filter Microsoft.VisualStudio.DevShell.dll).FullName
Enter-VsDevShell -VsInstallPath $env:VS_INSTALLATION_PATH -SkipAutomaticLocation -DevCmdArguments $env:DEV_ARGS
cmake --build ${{ steps.strings.outputs.build-output-dir }} --config Release

- name: Test
working-directory: ${{ steps.strings.outputs.build-output-dir }}
run: ctest --build-config Release --output-junit test_results.xml
2 changes: 1 addition & 1 deletion .github/workflows/copilot-setup-steps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- name: Set up Copilot Environment
# The agent will need the same paths you define in your CI
run: |
echo "PATH=$HOME/cmake-4.3.3-linux-x86_64/bin/:$PATH" >> "$GITHUB_ENV"
echo "PATH=$HOME/cmake-4.4.2-linux-x86_64/bin/:$PATH" >> "$GITHUB_ENV"
echo "CUDACXX=/usr/local/cuda-13.3/bin/nvcc" >> "$GITHUB_ENV"
echo "CC=g++-13" >> "$GITHUB_ENV"
echo "CXX=g++-13" >> "$GITHUB_ENV"
2 changes: 1 addition & 1 deletion CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ ctest -R '_cpp$' # CPU-backend tests only (no GP

Key CMake options: `ENABLE_CPU` (ON), `ENABLE_CUDA` (ON if nvcc found), `BUILD_TEST` (ON), `BUILD_UTEST` (ON), `ENABLE_BENCHMARK` (OFF), `CUDA_ARCH` ("native", passed verbatim to `CUDA_ARCHITECTURES` — no arch filtering exists), `ARCH_FLAGS` (CPU SIMD), `ENABLE_NVTX`, `ENABLE_DEBUG`, `TEMPLATE_DEPTH` (1000).

There is no lint/format gate. Format manually with `clang-format -i` using the repo-root `.clang-format` (LLVM base, 4-space indent, 120-char lines, `PointerAlignment: Right`). The merge gate is the full ctest suite building and passing across CI's compiler matrix (no `-Werror` anywhere, though the skills' PR checklists ask for warning-clean nvcc and clang builds). CI runs only on PRs to `main` (self-hosted runners): Linux amd64/arm64 with g++-13 and clang++-21 + CUDA 13.3; Windows with cl 14.44 + CUDA 13.0, cl 14.51 + CUDA 13.3, and clang-cl 14.51 + CUDA 13.3.
There is no lint/format gate. Format manually with `clang-format -i` using the repo-root `.clang-format` (LLVM base, 4-space indent, 120-char lines, `PointerAlignment: Right`). The merge gate is the full ctest suite building and passing across CI's compiler matrix (no `-Werror` anywhere, though the skills' PR checklists ask for warning-clean nvcc and clang builds). CI runs only on PRs to `main` (self-hosted runners): Linux amd64/arm64 with g++-13 and clang++-23 + CUDA 13.3; Windows with cl 14.44 + CUDA 13.0, cl 14.51 + CUDA 13.3, and clang-cl 14.51 + CUDA 13.3.

## Test infrastructure (no framework — no GTest/Catch2)

Expand Down
44 changes: 37 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@

cmake_minimum_required(VERSION 3.28 FATAL_ERROR)

set(CMAKE_CXX_SCAN_FOR_MODULES OFF)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(CMAKE_COLOR_DIAGNOSTICS ON)
set (PROJECT_VERSION_MAJOR 0)
set (PROJECT_VERSION_MINOR 2)
set (PROJECT_VERSION_REV 1)
Expand All @@ -18,15 +20,43 @@ HOMEPAGE_URL "https://github.com/morousg/FusedKernelLibrary" )

#cuda is optional, but if it is found, it will be used
option(ENABLE_CPU "Enable CPU support" ON)
option(ENABLE_CUDA "Enable CUDA support" ON)
option(ENABLE_HIP "Enable HIP support" OFF)

if (ENABLE_CUDA AND ENABLE_HIP)
message(FATAL_ERROR "ENABLE_CUDA and ENABLE_HIP cannot be enabled at the same time.")
endif()

include(CheckLanguage)
check_language(CUDA)
if (CMAKE_CUDA_COMPILER)
option (ENABLE_CUDA "Enable CUDA support" ON)
if (${ENABLE_CUDA})

if (ENABLE_CUDA)
check_language(CUDA)
if (CMAKE_CUDA_COMPILER)
include(cmake/cuda_init.cmake)
else()
message(WARNING "CUDA compiler not found. Disabling CUDA support")
set(ENABLE_CUDA OFF CACHE BOOL "Enable CUDA support" FORCE)
endif()
endif()

if (ENABLE_HIP)
check_language(HIP)
if (CMAKE_HIP_COMPILER)
if(NOT DEFINED HIP_PATH)
if(NOT DEFINED ENV{HIP_PATH})
set(HIP_PATH "/opt/rocm/hip" CACHE PATH "Path to which HIP has been installed")
else()
set(HIP_PATH $ENV{HIP_PATH} CACHE PATH "Path to which HIP has been installed")
endif()
endif()
set(CMAKE_MODULE_PATH "${HIP_PATH}/cmake" ${CMAKE_MODULE_PATH})
set(CMAKE_CXX_SCAN_FOR_MODULES OFF) #clang with HIP does not come with clang-scan-deps
include(cmake/hip_init.cmake)
message("Using HIP compiler at " ${CMAKE_HIP_COMPILER})
else()
message(WARNING "HIP compiler not found. Disabling HIP support")
set(ENABLE_HIP OFF CACHE BOOL "Enable HIP support" FORCE)
endif()
else()
message(STATUS "CUDA compiler not found, CUDA support will be disabled.")
endif()

add_subdirectory(include)
Expand Down
12 changes: 8 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# Fused Kernel Library (FKL) Main branch

The Fused Kernel Library is a C++20 implementation of a methodology that allows to define a set of operations that need to be executed inside a kernel, in the same order that they are expressed. The library currently has CPU and CUDA backends, but other GPU language implemenations (such as HIP) are possible.
The Fused Kernel Library is a C++20 implementation of a methodology that allows to define a set of operations that need to be executed inside a kernel, in the same order that they are expressed. The library currently has CPU, CUDA and ROCM backends, but other GPU language implementations are possible.

It automatically implements Vertical and Horizontal fusion, and also implements two new Fusion techniques, Backwards Vertical Fusion (akin to OpenCV Filters, but with an standard generic API), and Divergent Horizontal Fusion.

This is the Main branch of the repository, where the FKL API can be modified, the minimum C++ version can be increased (currently it is C++20), and in general, we can break retro-compatibility with the goal of improving future code maintainability, code performance, and being able to fuse more types of algorithms.

If you are looking for a more stable branch, where new features can be added, but the FKL API is frozen to ensure your user code will continue to work with newer versions, check the LTS-C++17 branch.
If you are looking for a more stable branch, where new features can be added, but the FKL API is frozen to ensure your user code will continue to work with newer versions, check the LTS-C++17 branch (ROCM is not supported there).

## Reference paper and other publications
This repository provides the official implementation of a kernel fusion methodology for GPU libraries, providing the mechanisms to perform automatic Vertical Fusion, Horizontal Fusion, Backwards Vertical Fusion and Divergent Horizontal Fusion.
Expand Down Expand Up @@ -159,7 +159,7 @@ This has been tested before, by creating special compilers that generate the ass

## Closed source friendly

A company that has it's own CUDA kernels, and wants to start fusing them along with operations present in this library, can do so by shaping their kernels into a conformant FusedKernel Operation, that can be passed as a template parameter of one of the FKL InstantiableOperation structs.
A company that has it's own CUDA or HIP kernels, and wants to start fusing them along with operations present in this library, can do so by shaping their kernels into a conformant FusedKernel Operation, that can be passed as a template parameter of one of the FKL InstantiableOperation structs.

With this strategy, they don't need to share any of their code. They just need to make their kernels fusionable.

Expand All @@ -168,5 +168,9 @@ With this strategy, they don't need to share any of their code. They just need t
This is an Apache 2.0 OpenSource project, currently with no funding. The 3 main contributors work on the project on their spare time. In the case of the main author, he can work on solving bugs or adding features during his work hours on Grup Mediapro S.L.U. The code added during that time will include Copyright Grup Mediapro S.L.U.

As per Apache 2.0 we provide no guaratees, or free support. Nevertheless, the software has some testing on the following OS and compiler versions:
- Ubuntu 24.04 g++ 13 + CUDA 13.3 or clang21 + CUDA 13.3 for both amd64 and arm64 systems.
for CUDA builds (x86_64 and arm64)
- Ubuntu 24.04 g++ 13 + CUDA 13.3 or clang++-23 + CUDA 13.3 for both amd64 and arm64 systems.
- Windows 11 Visual Studio 2022 + CUDA 13.0 or Visual Studio 2026 + CUDA 13.3 or clang-cl (VS2026) + CUDA 13.3 on amd64 systems.

For ROCM builds (x86_64 only):
- Ubuntu 24.04 + ROCM 10.0.
Loading
Loading