Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
b86830a
Throwing the std::runtime_error instead of just making one
ericwait Jul 22, 2025
c11e2c7
Updated cmake lists
ericwait Jul 22, 2025
2442a01
Adding some versioning tools
ericwait Jul 22, 2025
ebce0f8
Added a local check to matlab
ericwait Jul 28, 2025
957676d
Updated cmake lists to install components for others to use
ericwait Jul 28, 2025
7cc5313
Adding files for making a vcpkg port
ericwait Jul 28, 2025
eec7cc2
Removed old ci file
ericwait Jul 28, 2025
a5ea2d3
Removed inline comment in json
ericwait Jul 28, 2025
8efeb90
fixed build to not use env in matrix def
ericwait Jul 28, 2025
a206ab0
Trying without linux build
ericwait Jul 28, 2025
b4274c4
Update CMakeLists.txt for python
ericwait Jul 28, 2025
084f582
Update src/c/Cuda/_TemplateKernel.cuh removed extra throw
ericwait Jul 28, 2025
41a14e9
Using a github runner
ericwait Jul 29, 2025
ce3d83a
Refactor vcpkg file update script to use version source SHA and impro…
ericwait Jul 29, 2025
985c6ef
Merge branch 'feature/vcpkg' of https://github.com/ericwait/hydra-ima…
ericwait Jul 29, 2025
dd2bd8e
Fix file paths in vcpkg update script to correctly reference vcpkg.json
ericwait Jul 29, 2025
6cdc6c8
Update CI configuration to debug linux build
ericwait Jul 29, 2025
62ab4e7
Update CUDA Toolkit version to 12.9.1 in CI configuration
ericwait Jul 29, 2025
19b155d
Use default cuda
ericwait Jul 29, 2025
8c9aebb
Fix artifact upload name format in CI workflow
ericwait Jul 29, 2025
31aae57
Update CI configuration to use self-hosted runner for Windows
ericwait Jul 30, 2025
becd2df
Refactor artifact collection step to handle OS-specific file types fo…
ericwait Jul 30, 2025
88818d2
Refactor artifact collection step to separate Windows and Linux handling
ericwait Jul 30, 2025
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
123 changes: 123 additions & 0 deletions .github/workflows/hydra-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
name: Hydra CUDA CI

on:
push:
branches: [ '**' ]
tags: [ 'v*.*.*' ]
pull_request:
branches: [ main ]

jobs:
build:
name: Build on ${{ matrix.os }}
runs-on: ${{ matrix.runner }}
strategy:
matrix:
include:
- os: Windows
runner: self-hosted
cuda_arch: "89;90"
config: Release
# - os: Linux
# runner: ubuntu-latest
# cuda_arch: "89;90"
# config: Release

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0 # Needed for GitVersion

- name: Install GitVersion
uses: gittools/actions/gitversion/setup@v0.10.2
with:
versionSpec: '5.x'

- name: Determine version
id: gitversion
uses: gittools/actions/gitversion/execute@v0.10.2

- name: Print GitVersion Info
run: echo "Calculated version is ${{ steps.gitversion.outputs.semVer }}"

- name: Patch vcpkg files
run: >
python scripts/update-vcpkg-files.py
${{ steps.gitversion.outputs.VersionSourceSha }}
${{ steps.gitversion.outputs.semVer }}

- name: Install CUDA Toolkit (Linux only)
if: matrix.os == 'Linux'
uses: Jimver/cuda-toolkit@v0.2.11
# with:
# cuda: '12.3.2'

- name: Configure CMake
run: >
cmake -S . -B build
-DGITVERSION_SEMVER="${{ steps.gitversion.outputs.semVer }}"
-DGITVERSION_MAJOR="${{ steps.gitversion.outputs.major }}"
-DGITVERSION_MINOR="${{ steps.gitversion.outputs.minor }}"
-DGITVERSION_PATCH="${{ steps.gitversion.outputs.patch }}"
-DCMAKE_CUDA_ARCHITECTURES="${{ matrix.cuda_arch }}"
-DCMAKE_BUILD_TYPE=${{ matrix.config }}

- name: Build HydraCudaStatic
run: cmake --build build --target HydraCudaStatic --config ${{ matrix.config }} --parallel

- name: Build MEX bindings (optional)
run: cmake --build build --target Mex --config ${{ matrix.config }} --parallel
continue-on-error: true

- name: Build Python bindings (optional)
run: cmake --build build --target Python --config ${{ matrix.config }} --parallel
continue-on-error: true

- name: Collect artifacts (Windows)
if: matrix.os == 'Windows'
run: |
mkdir -p staging/${{ matrix.os }}
cp -r build/src/c/Cuda/*.{dll,lib,pdb} staging/${{ matrix.os }} 2> $null || true
cp -r build/src/c/Python/*.pyd staging/${{ matrix.os }} 2> $null || true
cp -r build/src/c/Mex/*.mex* staging/${{ matrix.os }} 2> $null || true

- name: Collect artifacts (Linux)
if: matrix.os != 'Windows'
run: |
mkdir -p staging/${{ matrix.os }}
cp -r build/src/c/Cuda/*.{so,a} staging/${{ matrix.os }} 2>/dev/null || true
cp -r build/src/c/Python/*.so staging/${{ matrix.os }} 2>/dev/null || true
cp -r build/src/c/Mex/*.mexa64 staging/${{ matrix.os }} 2>/dev/null || true

- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: hydra-${{ matrix.os }}-${{ steps.gitversion.outputs.semVer }}
path: staging/${{ matrix.os }}

- name: Install to staging dir
run: cmake --install build --prefix install-root

- name: Upload installable artifacts
uses: actions/upload-artifact@v4
with:
name: hydra_install_${{ matrix.os }}
path: install-root

release:
name: Create GitHub Release
needs: build
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
steps:
- name: Download all build artifacts
uses: actions/download-artifact@v4

- name: Create GitHub Release
uses: softprops/action-gh-release@v1
with:
name: Hydra Release ${{ github.ref_name }}
tag_name: ${{ github.ref_name }}
files: |
hydra-*/**
31 changes: 31 additions & 0 deletions .gitversion.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
mode: Mainline
branches:
main:
regex: ^main$
increment: Minor
prevent-increment-of-merged-branch-version: true
is-release-branch: true
tag: ''
develop:
regex: ^develop$
increment: Patch
tag: ''
feature:
regex: ^features?[/-]
increment: Inherit
tag: useBranchName
hotfix:
regex: ^hotfix(es)?[/-]
increment: Patch
tag: useBranchName
release:
regex: ^releases?[/-]
increment: None
tag: 'rc'
pull-request:
tag: 'pr'
increment: Inherit
ignore:
sha: []
commit-message-incrementing: Enabled
merge-message-strategy: MergeMessage
122 changes: 110 additions & 12 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,28 +1,126 @@
cmake_minimum_required(VERSION 3.22)

project(HydraImageProcessor LANGUAGES C CXX CUDA)
# Project metadata
project(HydraImageProcessor VERSION 0.0.0 LANGUAGES C CXX CUDA)

set(HYDRA_MODULE_NAME "HIP")
# ===========================
# GitVersioning (optional defaults for local builds)
# ===========================
if(NOT DEFINED GITVERSION_SEMVER)
set(GITVERSION_SEMVER "0.0.0-dev")
endif()
if(NOT DEFINED GITVERSION_MAJOR)
set(GITVERSION_MAJOR 0)
endif()
if(NOT DEFINED GITVERSION_MINOR)
set(GITVERSION_MINOR 0)
endif()
if(NOT DEFINED GITVERSION_PATCH)
set(GITVERSION_PATCH 0)
endif()

# ===========================
# Version Header Generation
# ===========================
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/src/c/Version.h.in
${CMAKE_BINARY_DIR}/generated/Version.h
@ONLY
)
include_directories(${CMAKE_BINARY_DIR}/generated)

# Use CMake's modern FindCUDAToolkit module
# ===========================
# CUDA Architecture Defaults
# ===========================
if(NOT DEFINED CMAKE_CUDA_ARCHITECTURES)
set(CMAKE_CUDA_ARCHITECTURES "89;90;103;121"
CACHE STRING "CUDA architectures to build for"
FORCE)
endif()

# ===========================
# Default Install Locations
# ===========================
include(GNUInstallDirs)

# ===========================
# Dependencies
# ===========================
find_package(CUDAToolkit REQUIRED)
find_package(OpenMP)
find_package(OpenMP REQUIRED COMPONENTS CXX)

# Find optional dependencies
find_package(Matlab COMPONENTS MAIN_PROGRAM OPTIONAL_COMPONENTS MEX_COMPILER)
find_package(Python COMPONENTS Development NumPy OPTIONAL)

# find_package(Python COMPONENTS Development NumPy OPTIONAL)

# Setup backend Hydra CUDA library (static) for CUDA building
# ===========================
# Subdirectories
# ===========================
add_subdirectory(src/c/Cuda)
add_subdirectory(src/c/test_back)

# Setup MEX interface if Matlab was found
if (Matlab_FOUND)
add_subdirectory(src/c/Mex)
add_subdirectory(src/c/Mex)
endif()

# Setup Python interface if Python is found
# Try to help FindPython by injecting the environment path (for local mamba or CI conda)
message(STATUS "CONDA_PREFIX: $ENV{CONDA_PREFIX}")
if(DEFINED ENV{CONDA_PREFIX})
if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows")
set(Python_EXECUTABLE "$ENV{CONDA_PREFIX}/python.exe" CACHE FILEPATH "Python interpreter")
else()
set(Python_EXECUTABLE "$ENV{CONDA_PREFIX}/python" CACHE FILEPATH "Python interpreter")
endif()
list(PREPEND CMAKE_PREFIX_PATH "$ENV{CONDA_PREFIX}")
message(STATUS "Python: ${Python_EXECUTABLE}")
message(STATUS "Python Include Dir: ${Python_INCLUDE_DIRS}")
else()
message(STATUS "Using system Python interpreter")
endif()

find_package(Python COMPONENTS Interpreter Development NumPy OPTIONAL)
# Manually set the Python library location if using conda/mamba on Windows
# if(WIN32 AND NOT Python_LIBRARIES)
# set(Python_LIBRARIES "$ENV{CONDA_PREFIX}/libs/python311.lib")
# endif()

message(STATUS "Python: ${Python_EXECUTABLE}")
message(STATUS "Python Include Dir: ${Python_INCLUDE_DIRS}")
message(STATUS "Python Library: ${Python_LIBRARIES}")
message(STATUS "NumPy Include Dir: ${Python_NumPy_INCLUDE_DIRS}")

if (Python_FOUND)
add_subdirectory(src/c/Python)
add_subdirectory(src/c/Python)
endif()

# ===========================
# CMake Package Config
# ===========================
include(CMakePackageConfigHelpers)

# Generate hydra-config.cmake
configure_package_config_file(
${CMAKE_CURRENT_SOURCE_DIR}/cmake/hydra-config.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/hydra-config.cmake
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/Hydra
)

# Generate hydra-config-version.cmake
write_basic_package_version_file(
${CMAKE_CURRENT_BINARY_DIR}/hydra-config-version.cmake
VERSION ${GITVERSION_SEMVER}
COMPATIBILITY AnyNewerVersion
)

# Install config files
install(FILES
${CMAKE_CURRENT_BINARY_DIR}/hydra-config.cmake
${CMAKE_CURRENT_BINARY_DIR}/hydra-config-version.cmake
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/Hydra
)

# Export all targets (defined in subdirs like Cuda)
install(EXPORT HydraTargets
FILE HydraTargets.cmake
NAMESPACE Hydra::
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/Hydra
)
File renamed without changes.
4 changes: 4 additions & 0 deletions cmake/hydra-config.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# hydra-config.cmake.in
@PACKAGE_INIT@

include("${CMAKE_CURRENT_LIST_DIR}/HydraTargets.cmake")
7 changes: 7 additions & 0 deletions environment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
name: hydra-build
channels:
- conda-forge
dependencies:
- python=3.11
- numpy
- cmake
20 changes: 20 additions & 0 deletions ports/hydra/portfile.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO ericwait/hydra-image-processor
REF v${GITVERSION_SEMVER} # you can pass this in via `cmake -D`

Copilot AI Jul 28, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The REF should use a fixed version tag or commit SHA for vcpkg stability. Using a variable like ${GITVERSION_SEMVER} will cause build failures as this variable is not available in the vcpkg context.

Suggested change
REF v${GITVERSION_SEMVER} # you can pass this in via `cmake -D`
REF v1.2.3 # Replace with the actual fixed version tag or commit SHA

Copilot uses AI. Check for mistakes.
SHA512 0 # This must be updated

Copilot AI Jul 28, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The SHA512 value is set to 0, which is invalid. This must be updated with the actual SHA512 hash of the source archive for vcpkg to verify the download integrity.

Suggested change
SHA512 0 # This must be updated
SHA512 <calculated_sha512_hash> # Replace with the actual hash

Copilot uses AI. Check for mistakes.
HEAD_REF main
)

vcpkg_cmake_configure(
SOURCE_PATH "${SOURCE_PATH}"
PREFER_NINJA
)

vcpkg_cmake_build()

vcpkg_cmake_install()

vcpkg_cmake_config_fixup()

file(INSTALL "${SOURCE_PATH}/LICENSE" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright)
12 changes: 12 additions & 0 deletions ports/hydra/vcpkg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"name": "hydra",
"version": "0.1.0",
"description": "Hydra Image Processor: CUDA-accelerated image analysis backend.",
"homepage": "https://github.com/ericwait/hydra-image-processor",
"license": "BSD-3-Clause",
"dependencies": [
"cuda",
"vcpkg-cmake",
"vcpkg-cmake-config"
]
}
39 changes: 39 additions & 0 deletions scripts/update-vcpkg-files.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import json, hashlib, urllib.request, sys

ref = sys.argv[1] # e.g., a tag, branch, or commit SHA
version = sys.argv[2] # e.g., "3.15.1-vcpkg.1"

# Construct GitHub tarball URL for the given ref
tarball_url = f"https://github.com/ericwait/hydra-image-processor/archive/{ref}.tar.gz"

# Download the tarball
print(f"Downloading tarball from: {tarball_url}")
tarball_data = urllib.request.urlopen(tarball_url).read()

# Compute SHA512
sha512 = hashlib.sha512(tarball_data).hexdigest()
print(f"Computed SHA512: {sha512}")

# Patch vcpkg.json
with open("ports/hydra/vcpkg.json", "r") as f:
vcpkg = json.load(f)

vcpkg["version"] = version

with open("ports/hydra/vcpkg.json", "w") as f:
json.dump(vcpkg, f, indent=2)
f.write("\n")

# Patch portfile.cmake
portfile_path = "ports/hydra/portfile.cmake"
with open(portfile_path, "r") as f:
lines = f.readlines()

with open(portfile_path, "w") as f:
for line in lines:
if line.strip().startswith("REF "):
f.write(f' REF {ref}\n')
elif line.strip().startswith("SHA512 "):
f.write(f' SHA512 {sha512}\n')
else:
f.write(line)
1 change: 1 addition & 0 deletions src/MATLAB/+HIP/CheckConfig.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@
[hydraConfig] = HIP.Cuda.CheckConfig();
catch errMsg
warning(errMsg.message);
[hydraConfig] = HIP.Local.CheckConfig();
end
end
Loading
Loading