Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
db673a2
Revive reaction diffusion iOS app
abadams Mar 5, 2026
521adc6
Redo the HelloiOS build
alexreinking Mar 5, 2026
a528870
Remove HelloiOS from apps/CMakeLists.txt
alexreinking Mar 6, 2026
0741098
Move reaction_diffusion_2_generator.cpp to Generators directory
alexreinking Mar 6, 2026
cb42dc1
Single-target Xcode-driven prototype
alexreinking Mar 7, 2026
7a1e632
use Xcode generator again
alexreinking Mar 7, 2026
73ec9a4
don't clutter the Xcode project navigator
alexreinking Mar 7, 2026
2f0b8ed
Build for both device and simulator
alexreinking Mar 7, 2026
72d54c8
Set folder directly in HalideGeneratorHelpers.cmake
alexreinking Mar 7, 2026
665a256
Simplify folder setting in HelloiOS
alexreinking Mar 7, 2026
afef4f1
A little more cleanup
alexreinking Mar 7, 2026
8a79778
Fix header selection
alexreinking Mar 7, 2026
3818887
Use xcodebuild directly rather than store the CMake path
alexreinking Mar 7, 2026
541121f
All supported iPhone versions have Metal
alexreinking Mar 7, 2026
be58a13
Rename build.sh to setup.sh
alexreinking Mar 7, 2026
5322b96
Update README.md
alexreinking Mar 7, 2026
8f13267
Generate xcconfig from CMake
alexreinking Mar 7, 2026
a94b6aa
Use XCode's own propagation mechanism for includes and libraries
alexreinking Mar 7, 2026
0f19d45
Just bundle an XCFramework
alexreinking Mar 7, 2026
d507262
Add helpers for creating iOS xcframeworks
alexreinking Mar 8, 2026
bcdd483
Use new add_halide_xcframework helper
alexreinking Mar 8, 2026
b7aff8f
Get code-signing working
alexreinking Mar 9, 2026
8ffb6ad
Don't inherit environment from device build
abadams Mar 11, 2026
950d9bc
Drop env -i and patch HalideGeneratorHelpers.cmake instead
abadams Mar 12, 2026
50afdcb
grammar tweak
abadams Mar 12, 2026
e641316
Reflow troubleshooting paragraph
alexreinking Mar 12, 2026
69aa26a
Merge remote-tracking branch 'origin/main' into abadams/revive_hello_…
abadams Mar 16, 2026
6b9ad81
clang-format
abadams Mar 16, 2026
50d2b46
Add note about known issue
abadams Mar 16, 2026
aabd972
Apply pre-commit auto-fixes
halide-ci[bot] Mar 16, 2026
9b011bf
Add missing keep-sorted start
abadams Mar 16, 2026
2ad3bf3
Merge branch 'abadams/revive_hello_ios-xcode' of https://github.com/h…
abadams Mar 16, 2026
9e55d91
Pacify cmake linter
abadams Mar 16, 2026
811ece5
Apply pre-commit auto-fixes
halide-ci[bot] Mar 16, 2026
7937eb0
Fix bad merge
abadams Mar 16, 2026
0dcc147
Add a macOS workflow for HelloiOS testing
alexreinking Mar 19, 2026
f3f133d
Use Python 3.10 so we don't need to build onnx wheels
alexreinking Mar 19, 2026
99f15f9
Don't install to /opt
alexreinking Mar 19, 2026
a0b9c5a
Use a more generic destination for iOS
alexreinking Mar 19, 2026
a2c8458
Merge branch 'main' into abadams/revive_hello_ios-xcode
alexreinking Mar 20, 2026
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
86 changes: 86 additions & 0 deletions .github/workflows/testing-macos.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
name: macOS

on:
pull_request:
types: [ opened, synchronize, reopened ]
paths-ignore:
- "doc/**"
- "README.md"
- "CODE_OF_CONDUCT.md"
- "LICENSE.txt"
- ".gitignore"
- ".gitattributes"
- ".gitmodules"
- ".lldbinit"
- ".github/**"
- "!.github/workflows/testing-macos.yml"
- "packaging/**"
- "Makefile"
- "Makefile.inc"
- 'run-clang-tidy.sh'
- '**.clang-tidy'

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

permissions:
contents: read

jobs:
macos:
if: "!contains(github.event.pull_request.labels.*.name, 'skip_buildbots')"
name: ${{ matrix.arch }} / ${{ matrix.uv_group }}
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: false
matrix:
# Disable extra cases until we have a fuller workflow
# For now, we're only testing HelloiOS
uv_group: [ "ci-llvm-main", ] # "ci-llvm-22", "ci-llvm-21"
runner: [ "macos-26", ] # "macos-26-intel"
include:
- runner: macos-26
arch: arm-64
python: cpython-3.10.20-macos-aarch64-none

steps:
- uses: actions/checkout@v4

- uses: astral-sh/setup-uv@v5

- name: Sync CI environment
run: |
uv sync --python '${{ matrix.python }}' --group '${{ matrix.uv_group }}' --no-install-project
echo "${GITHUB_WORKSPACE}/.venv/bin" >> "$GITHUB_PATH"
echo "VIRTUAL_ENV=${GITHUB_WORKSPACE}/.venv" >> "$GITHUB_ENV"

- name: Configure LLVM paths
run: echo "Halide_LLVM_ROOT=$(halide-llvm --prefix)" >> "$GITHUB_ENV"

- name: Configure CMake
run: >-
cmake --preset ci-macos-${{ matrix.arch }}
-DCMAKE_INSTALL_PREFIX="${{ github.workspace }}/install"
-DWITH_TESTS=NO
-DWITH_UTILS=NO
-DWITH_TUTORIALS=NO
-DWITH_PYTHON_BINDINGS=NO

- name: Initial build
run: cmake --build build --target install

- name: Configure HelloiOS
run: ./setup.sh
working-directory: apps/HelloiOS
env:
Halide_ROOT: ${{ github.workspace }}/install

- name: Build HelloiOS
run: >-
xcodebuild -workspace HelloiOS.xcworkspace
-scheme HelloiOS
-configuration Debug
-destination 'generic/platform=iOS Simulator'
build
working-directory: apps/HelloiOS
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ CMakeSettings.json

# XCode
*.xcworkspacedata
!apps/HelloiOS/HelloiOS.xcworkspace/contents.xcworkspacedata
tools/objc/*.mobileprovision
tools/objc/BUILD
xcuserdata
Expand Down
2 changes: 1 addition & 1 deletion apps/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ add_app(harris)
# add_app(HelloAndroid) # TODO(#5374): missing CMake build
# add_app(HelloAndroidCamera2) # TODO(#5374): missing CMake build
add_app(HelloBaremetal)
# add_app(HelloiOS) # TODO(#5374): missing CMake build
# add_app(HelloiOS) # don't build HelloiOS here because it isn't universal.
# add_app(HelloPyTorch) # TODO(#5374): missing CMake build
add_app(hexagon_benchmarks)
# add_app(hexagon_dma) # TODO(#5374): missing CMake build
Expand Down
41 changes: 41 additions & 0 deletions apps/HelloiOS/Generators/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
cmake_minimum_required(VERSION 3.28)
project(HelloiOS-Generators LANGUAGES C CXX)

# CMake hasn't yet finished implementing support for Xcode's new build system,
# so disable the warning about it for now.
set(CMAKE_XCODE_ATTRIBUTE_DISABLE_MANUAL_TARGET_ORDER_BUILD_WARNING YES)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED YES)
set(CMAKE_CXX_EXTENSIONS NO)

find_package(Halide REQUIRED)

add_halide_generator(
reaction_diffusion_2_generator
SOURCES reaction_diffusion_2_generator.cpp
)

foreach (simulator IN ITEMS "" "-simulator")
foreach (stage IN ITEMS init update render)
add_halide_library(reaction_diffusion_2_${stage}${simulator}
FROM reaction_diffusion_2_generator
GENERATOR reaction_diffusion_2_${stage}
FUNCTION_NAME reaction_diffusion_2_${stage}
FILE_BASE_NAME reaction_diffusion_2_${stage}
OUTPUT_DIR "arm-64-ios${simulator}"
TARGETS "arm-64-ios${simulator}"
FEATURES user_context)

add_halide_library(reaction_diffusion_2_metal_${stage}${simulator}
FROM reaction_diffusion_2_generator
GENERATOR reaction_diffusion_2_${stage}
FUNCTION_NAME reaction_diffusion_2_metal_${stage}
FILE_BASE_NAME reaction_diffusion_2_metal_${stage}
OUTPUT_DIR "arm-64-ios${simulator}"
TARGETS "arm-64-ios${simulator}"
FEATURES metal user_context)
endforeach ()
endforeach ()

add_halide_xcframework(HalideKernels LIBRARIES ALL)
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@ class ReactionDiffusion2Update : public Halide::Generator<ReactionDiffusion2Upda
Output<Buffer<float, 3>> new_state{"new_state"};

void generate() {
clamped = Halide::BoundaryConditions::repeat_edge(state);
// Add a boundary condition to the old state that treats out of bounds values as random
clamped = Halide::BoundaryConditions::constant_exterior(state, random_float(frame));

// Diffusion

blur_x(x, y, c) = (clamped(x - 3, y, c) +
clamped(x - 1, y, c) +
Expand All @@ -62,14 +65,16 @@ class ReactionDiffusion2Update : public Halide::Generator<ReactionDiffusion2Upda
// Reaction
Expr dR = B * (1 - R - G);
Expr dG = (1 - B) * (R - G);
Expr dB = 1 - B + 2 * G * R - R - G;
Expr dB = 0.5f * (1 - B + 2 * G * R - R - G);

Expr bump = (frame % 1024) / 1024.0f;
bump *= 1 - bump;
Expr alpha = lerp(0.3f, 0.7f, bump);
dR = select(dR > 0, dR * alpha, dR);
// We'll massively speed up the reaction where the user touches
Expr dx = x - mouse_x;
Expr dy = y - mouse_y;
Expr radius = dx * dx + dy * dy;
Expr bump = 0.002f * state.dim(0).extent() * state.dim(1).extent() / max(1.0f, radius);
bump = select(mouse_x >= 0, bump, 0.0f);

Expr t = 0.1f;
Expr t = 0.04f + bump;

R += t * dR;
G += t * dG;
Expand All @@ -80,26 +85,6 @@ class ReactionDiffusion2Update : public Halide::Generator<ReactionDiffusion2Upda
B = clamp(B, 0.0f, 1.0f);

new_state(x, y, c) = mux(c, {R, G, B});

// Noise at the edges
new_state(x, state.dim(1).min(), c) = random_float(frame) * 0.2f;
new_state(x, state.dim(1).max(), c) = random_float(frame) * 0.2f;
new_state(state.dim(0).min(), y, c) = random_float(frame) * 0.2f;
new_state(state.dim(0).max(), y, c) = random_float(frame) * 0.2f;

// Add some white where the mouse is
Expr min_x = clamp(mouse_x - 20, 0, state.dim(0).extent() - 1);
Expr max_x = clamp(mouse_x + 20, 0, state.dim(0).extent() - 1);
Expr min_y = clamp(mouse_y - 20, 0, state.dim(1).extent() - 1);
Expr max_y = clamp(mouse_y + 20, 0, state.dim(1).extent() - 1);
clobber = RDom(min_x, max_x - min_x + 1, min_y, max_y - min_y + 1);

Expr dx = clobber.x - mouse_x;
Expr dy = clobber.y - mouse_y;
Expr radius = dx * dx + dy * dy;
new_state(clobber.x, clobber.y, c) = select(radius < 400.0f,
1.0f,
new_state(clobber.x, clobber.y, c));
}

void schedule() {
Expand All @@ -112,53 +97,33 @@ class ReactionDiffusion2Update : public Halide::Generator<ReactionDiffusion2Upda
if (get_target().has_gpu_feature()) {
blur
.reorder(c, x, y)
.vectorize(c)
.unroll(c)
.compute_at(new_state, xi);

new_state.gpu_tile(x, y, xi, yi, 8, 2);

for (int i = 0; i <= 1; ++i) {
new_state.update(i)
.reorder(c, x)
.unroll(c)
.gpu_tile(x, xi, 8);
}
for (int i = 2; i <= 3; ++i) {
new_state.update(i)
.reorder(c, y)
.unroll(c)
.gpu_tile(y, yi, 8);
}
new_state.update(4)
.reorder(c, clobber.x)
.unroll(c)
.gpu_tile(clobber.x, clobber.y, 1, 1);

state.dim(0).set_stride(3);
state.dim(2).set_stride(1).set_extent(3);
new_state.dim(0).set_stride(3);
new_state.dim(2).set_stride(1).set_extent(3);
} else {
Var yi;
new_state
.split(y, y, yi, 64)
.split(y, y, yi, 32)
.parallel(y)
.vectorize(x, natural_vector_size<float>());

blur
.compute_at(new_state, yi)
.vectorize(x, natural_vector_size<float>());

clamped
.store_in(MemoryType::Stack)
.store_at(new_state, y)
.compute_at(new_state, yi);
.compute_at(new_state, yi)
.vectorize(Halide::_0, natural_vector_size<float>());
}
}

private:
Func blur_x, blur_y, blur, clamped;
Var x, y, xi, yi, c;
RDom clobber;
};

class ReactionDiffusion2Render : public Halide::Generator<ReactionDiffusion2Render> {
Expand All @@ -170,7 +135,7 @@ class ReactionDiffusion2Render : public Halide::Generator<ReactionDiffusion2Rend

void generate() {
Func contour;
contour(x, y, c) = pow(state(x, y, c) * (1 - state(x, y, c)) * 4, 8);
contour(x, y, c) = pow(state(x, y, c) * (1 - state(x, y, c)) * 4, 2);

Expr c0 = contour(x, y, 0);
Expr c1 = contour(x, y, 1);
Expand Down
Loading
Loading