Skip to content

feat: add WAMR WebAssembly engine support for Halide JIT#9116

Open
soldair wants to merge 7 commits intohalide:mainfrom
soldair:halide-wamr
Open

feat: add WAMR WebAssembly engine support for Halide JIT#9116
soldair wants to merge 7 commits intohalide:mainfrom
soldair:halide-wamr

Conversation

@soldair
Copy link
Copy Markdown

@soldair soldair commented Apr 30, 2026

This PR introduces Wasm Micro Runtime (WAMR) integration as an execution engine backend alternative inside the WasmModule JIT runtime harness, in addition to supporting standard co-existence of fallback configurations alongside legacy engines (wabt / v8).

Design Background

Halide WebAssembly testing has historically targeted wabt or V8 modules. WAMR provides smaller execution footprint constraints suitable for constrained evaluation targets and embedding environments.

Technical Enhancements

  • Extended preprocessor conditionals guarding engine symbols within src/WasmExecutor.cpp.
  • Integrated system dependency mechanisms and fallbacks utilizing CMake FetchContent module downloads.
  • Added __extendhfsf2, __truncsfhf2 half-float native implementations and mathematical POSIX wrappers.

Fixes #

Breaking changes

None. Code coexistence preserves logic paths for previous backends wabt/v8.

Checklist

  • Tests added or updated (not required for docs, CI config, or typo fixes)
  • Documentation updated (if public API changed)
  • Python bindings updated (if public API changed)
  • Benchmarks are included here if the change is intended to affect performance.
  • Commits include AI attribution where applicable (see Code of Conduct)

@soldair
Copy link
Copy Markdown
Author

soldair commented Apr 30, 2026

I sent this pr a little early but i would love feedback. v8 is a very large dep and is causing issues and we cant use wabt. wamr is a perfect drop in.

Comment thread src/CMakeLists.txt Outdated
@soldair soldair force-pushed the halide-wamr branch 2 times, most recently from 4df6609 to 6223372 Compare April 30, 2026 17:54
Comment thread doc/BuildingHalideWithCMake.md
@alexreinking
Copy link
Copy Markdown
Member

alexreinking commented Apr 30, 2026

I just tried this... it is possible to use standard mechanisms to use WAMR. I would push directly, but I notice you prefer to force-push, @soldair, so to avoid losing work, I'll provide you with a patch file instead.

This boils down to two changes:

  • Rather than building WAMR in-line with Halide, add a vcpkg port to manage building WAMR. The WAMR build uses FetchContent to acquire simde, which is unnecessary, so we patch around it.
  • Use find_package to import WAMR into the build, mirroring the approach for V8 and wabt.

I've also opened bytecodealliance/wasm-micro-runtime#4932 to nudge upstream into also using standard mechanisms for pulling in dependencies.

0001-Use-standard-mechanisms-to-use-WAMR.patch

Patch contents
From 6c5c846544ba9e0a3775e3aeefc744705809072f Mon Sep 17 00:00:00 2001
From: Alex Reinking <areinking@adobe.com>
Date: Thu, 30 Apr 2026 15:30:06 -0400
Subject: [PATCH] Use standard mechanisms to use WAMR

- Rather than building WAMR in-line with Halide, add a vcpkg port
  to manage building WAMR. The WAMR build uses FetchContent to
  acquire simde, which is unnecessary, so we patch around it.
- Use find_package to import WAMR into the build, mirroring the
  approach for V8 and wabt.
---
 cmake/vcpkg/wamr/portfile.cmake            | 21 +++++++++++++++
 cmake/vcpkg/wamr/remove-fetchcontent.patch | 19 ++++++++++++++
 cmake/vcpkg/wamr/vcpkg.json                | 18 +++++++++++++
 src/CMakeLists.txt                         | 30 +++++-----------------
 vcpkg.json                                 | 12 ++++++---
 5 files changed, 73 insertions(+), 27 deletions(-)
 create mode 100644 cmake/vcpkg/wamr/portfile.cmake
 create mode 100644 cmake/vcpkg/wamr/remove-fetchcontent.patch
 create mode 100644 cmake/vcpkg/wamr/vcpkg.json

diff --git a/cmake/vcpkg/wamr/portfile.cmake b/cmake/vcpkg/wamr/portfile.cmake
new file mode 100644
index 000000000..05593b8de
--- /dev/null
+++ b/cmake/vcpkg/wamr/portfile.cmake
@@ -0,0 +1,21 @@
+vcpkg_check_linkage(ONLY_STATIC_LIBRARY)
+
+vcpkg_from_github(
+    OUT_SOURCE_PATH SOURCE_PATH
+    REPO bytecodealliance/wasm-micro-runtime
+    REF 8c18e3f68b16c4bcaf05996b2636f6ed2b4cf629  # WAMR-2.4.4
+    SHA512 2378ab44e6ea3cd9bfede86a413c5d5503b8cd0d072bbee7099bd149897a58d74b57c06214f6b163242f5ac8bcdbb81a59632016ebd4c12a717786e1c387c9e3
+    PATCHES remove-fetchcontent.patch
+)
+
+vcpkg_cmake_configure(SOURCE_PATH "${SOURCE_PATH}")
+
+vcpkg_cmake_install()
+vcpkg_cmake_config_fixup(PACKAGE_NAME iwasm CONFIG_PATH lib/cmake/iwasm)
+
+vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE")
+
+file(REMOVE_RECURSE
+     "${CURRENT_PACKAGES_DIR}/debug/include"
+     "${CURRENT_PACKAGES_DIR}/debug/share"
+)
diff --git a/cmake/vcpkg/wamr/remove-fetchcontent.patch b/cmake/vcpkg/wamr/remove-fetchcontent.patch
new file mode 100644
index 000000000..936f4dbf2
--- /dev/null
+++ b/cmake/vcpkg/wamr/remove-fetchcontent.patch
@@ -0,0 +1,19 @@
+diff --git a/core/iwasm/libraries/simde/simde.cmake b/core/iwasm/libraries/simde/simde.cmake
+--- a/core/iwasm/libraries/simde/simde.cmake
++++ b/core/iwasm/libraries/simde/simde.cmake
+@@ -15,14 +15,5 @@ add_definitions (-DWASM_ENABLE_SIMDE=1)
+ 
+ include_directories(${LIB_SIMDE_DIR} ${LIB_SIMDE_DIR}/simde)
+ 
+-include(FetchContent)
+-
+-FetchContent_Declare(
+-    simde
+-    GIT_REPOSITORY  https://github.com/simd-everywhere/simde
+-    GIT_TAG v0.8.2
+-)
+-
+-message("-- Fetching simde ..")
+-FetchContent_MakeAvailable(simde)
++find_path(simde_SOURCE_DIR simde/wasm/simd128.h)
+ include_directories("${simde_SOURCE_DIR}")
diff --git a/cmake/vcpkg/wamr/vcpkg.json b/cmake/vcpkg/wamr/vcpkg.json
new file mode 100644
index 000000000..b4a61bb6d
--- /dev/null
+++ b/cmake/vcpkg/wamr/vcpkg.json
@@ -0,0 +1,18 @@
+{
+  "name": "wamr",
+  "version-semver": "2.4.4",
+  "description": "WebAssembly Micro Runtime (WAMR)",
+  "homepage": "https://github.com/bytecodealliance/wasm-micro-runtime",
+  "license": "Apache-2.0",
+  "dependencies": [
+    "simde",
+    {
+      "name": "vcpkg-cmake",
+      "host": true
+    },
+    {
+      "name": "vcpkg-cmake-config",
+      "host": true
+    }
+  ]
+}
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 1e1f8e9b5..18624abc9 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -591,38 +591,20 @@ if (Halide_WASM_BACKEND STREQUAL "wabt")
     find_package(wabt REQUIRED)
     _Halide_pkgdep(wabt)
 
-    target_link_libraries(Halide PRIVATE wabt::wabt)
     target_compile_definitions(Halide PRIVATE WITH_WABT)
+    target_link_libraries(Halide PRIVATE wabt::wabt)
 elseif (Halide_WASM_BACKEND STREQUAL "V8")
     find_package(V8 REQUIRED)
     _Halide_pkgdep(V8)
+
     target_compile_definitions(Halide PRIVATE WITH_V8)
     target_link_libraries(Halide PRIVATE V8::V8)
 elseif (Halide_WASM_BACKEND STREQUAL "WAMR")
-    set(Halide_WAMR_ROOT_DIR "" CACHE PATH "Path to root directory of WAMR repository sources")
-
-    if ("${Halide_WAMR_ROOT_DIR}" STREQUAL "")
-        if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/../../wasm-micro-runtime/build-scripts/runtime_lib.cmake")
-            set(WAMR_ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../wasm-micro-runtime")
-        else()
-            message(FATAL_ERROR "WAMR backend requires specifying Halide_WAMR_ROOT_DIR or cloning wasm-micro-runtime adjacent to the Halide repository.")
-        endif()
-    else()
-        set(WAMR_ROOT_DIR "${Halide_WAMR_ROOT_DIR}")
-    endif()
-
-    set(WAMR_BUILD_PLATFORM "linux")
-    set(WAMR_BUILD_TARGET "X86_64")
-    set(WAMR_BUILD_INTERP 1)
-    set(WAMR_BUILD_FAST_INTERP 1)
-    set(WAMR_BUILD_REF_TYPES 1)
-    set(WAMR_BUILD_SIMD 1)
-    set(WAMR_BUILD_LIB_SIMDE 1)
-    include(${WAMR_ROOT_DIR}/build-scripts/runtime_lib.cmake)
-    add_library(wamr_lib STATIC ${WAMR_RUNTIME_LIB_SOURCE})
-    target_link_libraries(Halide PRIVATE wamr_lib)
+    find_package(iwasm REQUIRED)
+    _Halide_pkgdep(iwasm)
+
     target_compile_definitions(Halide PRIVATE WITH_WAMR)
-    target_include_directories(Halide PRIVATE "${WAMR_ROOT_DIR}/core/iwasm/include")
+    target_link_libraries(Halide PRIVATE iwasm::vmlib)
 elseif (Halide_WASM_BACKEND)
     message(FATAL_ERROR "Unknown Halide_WASM_BACKEND `${Halide_WASM_BACKEND}`")
 endif ()
diff --git a/vcpkg.json b/vcpkg.json
index 6a404753c..5d7b4c293 100644
--- a/vcpkg.json
+++ b/vcpkg.json
@@ -45,7 +45,7 @@
           "default-features": false,
           "features": [
             "serialization",
-            "wasm-executor"
+            "wasm-executor-wabt"
           ]
         }
       ]
@@ -180,11 +180,17 @@
         }
       ]
     },
-    "wasm-executor": {
-      "description": "Include built-in WASM executor",
+    "wasm-executor-wabt": {
+      "description": "Include wabt-based WASM executor",
       "dependencies": [
         "wabt"
       ]
+    },
+    "wasm-executor-wamr": {
+      "description": "Include wamr-based WASM executor",
+      "dependencies": [
+        "wamr"
+      ]
     }
   }
 }
-- 
2.50.1 (Apple Git-155)

@soldair
Copy link
Copy Markdown
Author

soldair commented Apr 30, 2026

please feel free to push any time. i'm not typically a force pusher just a product of a tool i was using. 😅

i'll apply this patch

@alexreinking
Copy link
Copy Markdown
Member

Testing this locally, I'm seeing issues with finding Halide's extern funcs feature. Also seeing issues with some surprisingly moderate allocation sizes (e.g. 48KB).

@soldair
Copy link
Copy Markdown
Author

soldair commented Apr 30, 2026

Thanks for looking. If you have a command handy ill make sure everything passes and @ you when i think we're doing ok. I thought i had been running all the tests. I'm very new to this project 😅

@alexreinking
Copy link
Copy Markdown
Member

Here's how I'm testing locally. You'll have to adapt my paths to yours.

$ source ~/dev/emsdk/emsdk_env.sh
$ export VCPKG_ROOT=$HOME/dev/vcpkg
$ cmake --preset macOS-vcpkg -DHalide_WASM_BACKEND=WAMR -DHalide_TARGET=wasm-32-wasmrt-wasm_simd128
$ cmake --build build/macOS-vcpkg
$ ctest --test-dir build/macOS-vcpkg -j$(sysctl -n hw.physicalcpu)

Even after your latest commit, I'm still seeing a few failures:

Complete CTest failures & output
(halide) areinking@Alexanders-MacBook-Pro Halide % ctest --test-dir build/macOS-vcpkg --rerun-failed --output-on-failure
Test project /Users/areinking/dev/Halide/build/macOS-vcpkg
      Start  37: correctness_align_bounds
 1/34 Test  #37: correctness_align_bounds ...................................Subprocess aborted***Exception:   0.10 sec
[13:58:58:801 - 1ED68D8C0]: warning: failed to link import function (env, halide_trace_helper)
Internal error at /Users/areinking/dev/Halide/src/WasmExecutor.cpp:3180
Condition failed: call_success
Error: wasm_runtime_call_wasm_a failed: Exception: failed to call unlinked import function (env, halide_trace_helper)

      Start  69: correctness_callable_errors
 2/34 Test  #69: correctness_callable_errors ................................Subprocess aborted***Exception:   0.10 sec
Saw expected: (NO ERROR)
Internal error at /Users/areinking/dev/Halide/src/WasmExecutor.cpp:3146
Condition failed: wbuf
Error: hostbuf_to_wasmbuf_wamr failed

      Start 128: correctness_exception
 3/34 Test #128: correctness_exception ......................................Subprocess aborted***Exception:   0.10 sec
Expected compile error:
Error: Implicit cast from float32 to int in argument 1 in call to "f0" is not allowed. Use an explicit cast.

Expected compile error:
Error: Can't index into a reference to Func "f0", because it does not return a Tuple.

Expected compile error:
Error: In update definition 0 of Func "f0":
Tuple element 0 of update definition has type float32, but pure definition has type int32

Expected compile error:
Error: In update definition 0 of Func "f0":
Undefined expression in right-hand-side of update.

Expected internal error:
Internal error at /Users/areinking/dev/Halide/src/IR.cpp:40
Condition failed: a.defined()
Error: Add of undefined

Expected internal error:
Internal error at /Users/areinking/dev/Halide/src/ModulusRemainder.cpp:161
Error: modulus_remainder of bool

Internal error at /Users/areinking/dev/Halide/src/WasmExecutor.cpp:3146
Condition failed: wbuf
Error: hostbuf_to_wasmbuf_wamr failed

      Start 144: correctness_float16_t
 4/34 Test #144: correctness_float16_t ......................................***Failed  Required regular expression not found. Regex=[Success!
]  0.30 sec
Error: Error: Buffer argument f5 is nullptr

Testing float16_t...

      Start 220: correctness_interleave
 5/34 Test #220: correctness_interleave .....................................Subprocess aborted***Exception:   1.50 sec
Skipping part of correctness_interleave test for WebAssembly+WasmSimd128 due to https://bugs.chromium.org/p/v8/issues/detail?id=9083.
Internal error at /Users/areinking/dev/Halide/src/WasmExecutor.cpp:3180
Condition failed: call_success
Error: wasm_runtime_call_wasm_a failed: Exception: invalid local type

      Start 230: correctness_iterate_over_circle
 6/34 Test #230: correctness_iterate_over_circle ............................Subprocess aborted***Exception:   0.10 sec
[13:59:00:910 - 1ED68D8C0]: warning: failed to link import function (env, halide_trace_helper)
Internal error at /Users/areinking/dev/Halide/src/WasmExecutor.cpp:3180
Condition failed: call_success
Error: wasm_runtime_call_wasm_a failed: Exception: failed to call unlinked import function (env, halide_trace_helper)

      Start 235: correctness_lerp
 7/34 Test #235: correctness_lerp ...........................................Subprocess aborted***Exception:   8.75 sec
[13:59:09:660 - 1ED68D8C0]: warning: allocate 33685616 bytes memory failed
Internal error at /Users/areinking/dev/Halide/src/WasmExecutor.cpp:3146
Condition failed: wbuf
Error: hostbuf_to_wasmbuf_wamr failed

      Start 240: correctness_loop_carry
 8/34 Test #240: correctness_loop_carry .....................................Subprocess aborted***Exception:   1.64 sec
Internal error at /Users/areinking/dev/Halide/src/WasmExecutor.cpp:3180
Condition failed: call_success
Error: wasm_runtime_call_wasm_a failed: Exception: invalid local type

      Start 257: correctness_multi_splits_with_diff_tail_strategies
 9/34 Test #257: correctness_multi_splits_with_diff_tail_strategies .........Subprocess aborted***Exception:   0.10 sec
[13:59:11:402 - 1ED68D8C0]: warning: allocate 72000112 bytes memory failed
Internal error at /Users/areinking/dev/Halide/src/WasmExecutor.cpp:3146
Condition failed: wbuf
Error: hostbuf_to_wasmbuf_wamr failed

      Start 297: correctness_reduction_non_rectangular
10/34 Test #297: correctness_reduction_non_rectangular ......................Subprocess aborted***Exception:   0.52 sec
Running equality inequality bound test
Running split fuse test
Running bound depend on free variable test
Running function call inside bound test
[13:59:11:922 - 1ED68D8C0]: warning: failed to link import function (env, halide_trace_helper)
Internal error at /Users/areinking/dev/Halide/src/WasmExecutor.cpp:3180
Condition failed: call_success
Error: wasm_runtime_call_wasm_a failed: Exception: failed to call unlinked import function (env, halide_trace_helper)

      Start 303: correctness_reschedule
11/34 Test #303: correctness_reschedule .....................................Subprocess aborted***Exception:   0.10 sec
[13:59:12:020 - 1ED68D8C0]: warning: failed to link import function (env, halide_trace_helper)
Internal error at /Users/areinking/dev/Halide/src/WasmExecutor.cpp:3180
Condition failed: call_success
Error: wasm_runtime_call_wasm_a failed: Exception: failed to call unlinked import function (env, halide_trace_helper)

      Start 320: correctness_skip_stages_memoize
12/34 Test #320: correctness_skip_stages_memoize ............................Subprocess aborted***Exception:   0.10 sec
Running single_memoize_test
[13:59:12:124 - 1ED68D8C0]: warning: failed to link import function (env, halide_trace_helper)
Internal error at /Users/areinking/dev/Halide/src/WasmExecutor.cpp:3180
Condition failed: call_success
Error: wasm_runtime_call_wasm_a failed: Exception: failed to call unlinked import function (env, halide_trace_helper)

      Start 328: correctness_specialize_trim_condition
13/34 Test #328: correctness_specialize_trim_condition ......................Subprocess aborted***Exception:   0.11 sec
[13:59:12:236 - 1ED68D8C0]: warning: failed to link import function (env, halide_trace_helper)
Internal error at /Users/areinking/dev/Halide/src/WasmExecutor.cpp:3180
Condition failed: call_success
Error: wasm_runtime_call_wasm_a failed: Exception: failed to call unlinked import function (env, halide_trace_helper)

      Start 336: correctness_stencil_chain_in_update_definitions
14/34 Test #336: correctness_stencil_chain_in_update_definitions ............Subprocess aborted***Exception:   0.28 sec
[13:59:12:521 - 1ED68D8C0]: warning: failed to link import function (env, halide_trace_helper)
Internal error at /Users/areinking/dev/Halide/src/WasmExecutor.cpp:3180
Condition failed: call_success
Error: wasm_runtime_call_wasm_a failed: Exception: failed to call unlinked import function (env, halide_trace_helper)

      Start 342: correctness_strict_fma
15/34 Test #342: correctness_strict_fma .....................................Subprocess aborted***Exception:   0.36 sec
Testing float64
Testing float32
Testing float16
Warning: In function f_2, (b)float16 type operation is emulated, which is likely to slow down the performance. If your target supports native (b)float16 operations, it could be improved by adding Target feature to enable it.
Error: Buffer argument f$2 is nullptr

      Start 349: correctness_tracing
16/34 Test #349: correctness_tracing ........................................Subprocess aborted***Exception:   0.10 sec
[13:59:12:983 - 1ED68D8C0]: warning: failed to link import function (env, halide_trace_helper)
Internal error at /Users/areinking/dev/Halide/src/WasmExecutor.cpp:3180
Condition failed: call_success
Error: wasm_runtime_call_wasm_a failed: Exception: failed to call unlinked import function (env, halide_trace_helper)

      Start 351: correctness_tracing_broadcast
17/34 Test #351: correctness_tracing_broadcast ..............................Subprocess aborted***Exception:   0.10 sec
[13:59:13:085 - 1ED68D8C0]: warning: failed to link import function (env, halide_trace_helper)
Internal error at /Users/areinking/dev/Halide/src/WasmExecutor.cpp:3180
Condition failed: call_success
Error: wasm_runtime_call_wasm_a failed: Exception: failed to call unlinked import function (env, halide_trace_helper)

      Start 354: correctness_transpose_idioms
18/34 Test #354: correctness_transpose_idioms ...............................Subprocess aborted***Exception:   1.71 sec
Internal error at /Users/areinking/dev/Halide/src/WasmExecutor.cpp:3180
Condition failed: call_success
Error: wasm_runtime_call_wasm_a failed: Exception: invalid local type

      Start 364: correctness_uninitialized_read
19/34 Test #364: correctness_uninitialized_read .............................Subprocess aborted***Exception:   0.10 sec
[13:59:14:887 - 1ED68D8C0]: warning: failed to link import function (env, halide_trace_helper)
Internal error at /Users/areinking/dev/Halide/src/WasmExecutor.cpp:3180
Condition failed: call_success
Error: wasm_runtime_call_wasm_a failed: Exception: failed to call unlinked import function (env, halide_trace_helper)

      Start 379: correctness_vectorize_guard_with_if
20/34 Test #379: correctness_vectorize_guard_with_if ........................Subprocess aborted***Exception:   0.10 sec
[13:59:14:987 - 1ED68D8C0]: warning: failed to link import function (env, halide_trace_helper)
Internal error at /Users/areinking/dev/Halide/src/WasmExecutor.cpp:3180
Condition failed: call_success
Error: wasm_runtime_call_wasm_a failed: Exception: failed to call unlinked import function (env, halide_trace_helper)

      Start 405: correctness_compute_with
21/34 Test #405: correctness_compute_with ...................................Subprocess aborted***Exception:   0.19 sec
split reorder test
[13:59:15:173 - 1ED68D8C0]: warning: failed to link import function (env, halide_trace_helper)
Internal error at /Users/areinking/dev/Halide/src/WasmExecutor.cpp:3180
Condition failed: call_success
Error: wasm_runtime_call_wasm_a failed: Exception: failed to call unlinked import function (env, halide_trace_helper)

      Start 433: correctness_rfactor
22/34 Test #433: correctness_rfactor ........................................Subprocess aborted***Exception:   6.61 sec
self assignment rfactor test
simple rfactor test: checking call graphs...
simple rfactor test: checking output img correctness...
reorder split rfactor test: checking call graphs...
reorder split rfactor test: checking output img correctness...
multiple split rfactor test: checking call graphs...
multiple split rfactor test: checking output img correctness...
reorder fuse wrapper rfactor test: checking call graphs...
reorder fuse wrapper rfactor test: checking output img correctness...
non trivial lhs rfactor test: checking call graphs...
non trivial lhs rfactor test: checking output img correctness...
simple rfactor with specialization test: checking call graphs...
simple rfactor with specialization test: checking output img correctness...
rdom with predicate rfactor test: checking call graphs...
rdom with predicate rfactor test: checking output img correctness...
histogram rfactor test: checking call graphs...
histogram rfactor test: checking output img correctness...
parallel dot product rfactor test: checking call graphs...
parallel dot product rfactor test: checking output img correctness...
tuple rfactor test: checking call graphs...
tuple rfactor test: checking output img correctness...
tuple specialize rdom predicate rfactor test: checking call graphs...
tuple specialize rdom predicate rfactor test: checking output img correctness...
tuple partial reduction rfactor test: checking call graphs...
tuple partial reduction rfactor test: checking output img correctness...
check allocation bound test
[13:59:21:787 - 1ED68D8C0]: warning: failed to link import function (env, halide_trace_helper)
Internal error at /Users/areinking/dev/Halide/src/WasmExecutor.cpp:3180
Condition failed: call_success
Error: wasm_runtime_call_wasm_a failed: Exception: failed to call unlinked import function (env, halide_trace_helper)

      Start 613: performance_parallel_scenarios
23/34 Test #613: performance_parallel_scenarios .............................Subprocess aborted***Exception:   0.35 sec
memory_bound contended inner outer num_samples 10% 20% 30% 40% 50% 60% 70% 80% 90%
[13:59:22:142 - 1ED68D8C0]: warning: allocate 419430480 bytes memory failed
Internal error at /Users/areinking/dev/Halide/src/WasmExecutor.cpp:3146
Condition failed: wbuf
Error: hostbuf_to_wasmbuf_wamr failed

      Start 669: python_tutorial_lesson_04_debugging_2
24/34 Test #669: python_tutorial_lesson_04_debugging_2 ......................***Failed    0.15 sec
Evaluating gradient
Traceback (most recent call last):
  File "/Users/areinking/dev/Halide/python_bindings/tutorial/lesson_04_debugging_2.py", line 65, in <module>
    main()
    ~~~~^^
  File "/Users/areinking/dev/Halide/python_bindings/tutorial/lesson_04_debugging_2.py", line 27, in main
    gradient.realize([8, 8])
    ~~~~~~~~~~~~~~~~^^^^^^^^
halide.halide_.HalideError: Internal error at /Users/areinking/dev/Halide/src/WasmExecutor.cpp:3180
Condition failed: call_success
Error: wasm_runtime_call_wasm_a failed: Exception: failed to call unlinked import function (env, halide_trace_helper)

[13:59:22:276 - 1ED68D8C0]: warning: failed to link import function (env, halide_trace_helper)

      Start 670: python_tutorial_lesson_05_scheduling_1
25/34 Test #670: python_tutorial_lesson_05_scheduling_1 .....................***Failed    0.13 sec
Evaluating gradient row-major
Traceback (most recent call last):
  File "/Users/areinking/dev/Halide/python_bindings/tutorial/lesson_05_scheduling_1.py", line 546, in <module>
    main()
    ~~~~^^
  File "/Users/areinking/dev/Halide/python_bindings/tutorial/lesson_05_scheduling_1.py", line 33, in main
    gradient.realize([4, 4])
    ~~~~~~~~~~~~~~~~^^^^^^^^
halide.halide_.HalideError: Internal error at /Users/areinking/dev/Halide/src/WasmExecutor.cpp:3180
Condition failed: call_success
Error: wasm_runtime_call_wasm_a failed: Exception: failed to call unlinked import function (env, halide_trace_helper)

[13:59:22:408 - 1ED68D8C0]: warning: failed to link import function (env, halide_trace_helper)

      Start 671: python_tutorial_lesson_06_realizing_over_shifted_domains
26/34 Test #671: python_tutorial_lesson_06_realizing_over_shifted_domains ...***Failed    0.12 sec
Evaluating gradient from (0, 0) to (7, 7)
Traceback (most recent call last):
  File "/Users/areinking/dev/Halide/python_bindings/tutorial/lesson_06_realizing_over_shifted_domains.py", line 88, in <module>
    main()
    ~~~~^^
  File "/Users/areinking/dev/Halide/python_bindings/tutorial/lesson_06_realizing_over_shifted_domains.py", line 47, in main
    gradient.realize(result)
    ~~~~~~~~~~~~~~~~^^^^^^^^
halide.halide_.HalideError: Internal error at /Users/areinking/dev/Halide/src/WasmExecutor.cpp:3180
Condition failed: call_success
Error: wasm_runtime_call_wasm_a failed: Exception: failed to call unlinked import function (env, halide_trace_helper)

[13:59:22:533 - 1ED68D8C0]: warning: failed to link import function (env, halide_trace_helper)

      Start 673: python_tutorial_lesson_08_scheduling_2
27/34 Test #673: python_tutorial_lesson_08_scheduling_2 .....................***Failed    0.18 sec
==================================================

Evaluating producer-consumer pipeline with default schedule
Traceback (most recent call last):
  File "/Users/areinking/dev/Halide/python_bindings/tutorial/lesson_08_scheduling_2.py", line 710, in <module>
    main()
    ~~~~^^
  File "/Users/areinking/dev/Halide/python_bindings/tutorial/lesson_08_scheduling_2.py", line 46, in main
    consumer.realize([4, 4])
    ~~~~~~~~~~~~~~~~^^^^^^^^
halide.halide_.HalideError: Internal error at /Users/areinking/dev/Halide/src/WasmExecutor.cpp:3180
Condition failed: call_success
Error: wasm_runtime_call_wasm_a failed: Exception: failed to call unlinked import function (env, halide_trace_helper)

[13:59:22:715 - 1ED68D8C0]: warning: failed to link import function (env, halide_trace_helper)

      Start 674: python_tutorial_lesson_09_update_definitions
28/34 Test #674: python_tutorial_lesson_09_update_definitions ...............***Failed    0.29 sec
Traceback (most recent call last):
  File "/Users/areinking/dev/Halide/python_bindings/tutorial/lesson_09_update_definitions.py", line 670, in <module>
    main()
    ~~~~^^
  File "/Users/areinking/dev/Halide/python_bindings/tutorial/lesson_09_update_definitions.py", line 101, in main
    g.realize([4, 4])
    ~~~~~~~~~^^^^^^^^
halide.halide_.HalideError: Internal error at /Users/areinking/dev/Halide/src/WasmExecutor.cpp:3180
Condition failed: call_success
Error: wasm_runtime_call_wasm_a failed: Exception: failed to call unlinked import function (env, halide_trace_helper)

[13:59:23:005 - 1ED68D8C0]: warning: failed to link import function (env, halide_trace_helper)

      Start 682: tutorial_lesson_04_debugging_2
29/34 Test #682: tutorial_lesson_04_debugging_2 .............................Subprocess aborted***Exception:   0.10 sec
Evaluating gradient
[13:59:23:116 - 1ED68D8C0]: warning: failed to link import function (env, halide_trace_helper)
Internal error at /Users/areinking/dev/Halide/src/WasmExecutor.cpp:3180
Condition failed: call_success
Error: wasm_runtime_call_wasm_a failed: Exception: failed to call unlinked import function (env, halide_trace_helper)

      Start 683: tutorial_lesson_05_scheduling_1
30/34 Test #683: tutorial_lesson_05_scheduling_1 ............................Subprocess aborted***Exception:   0.10 sec
Evaluating gradient row-major
[13:59:23:212 - 1ED68D8C0]: warning: failed to link import function (env, halide_trace_helper)
Internal error at /Users/areinking/dev/Halide/src/WasmExecutor.cpp:3180
Condition failed: call_success
Error: wasm_runtime_call_wasm_a failed: Exception: failed to call unlinked import function (env, halide_trace_helper)

      Start 684: tutorial_lesson_06_realizing_over_shifted_domains
31/34 Test #684: tutorial_lesson_06_realizing_over_shifted_domains ..........Subprocess aborted***Exception:   0.10 sec
Evaluating gradient from (0, 0) to (7, 7)
[13:59:23:310 - 1ED68D8C0]: warning: failed to link import function (env, halide_trace_helper)
Internal error at /Users/areinking/dev/Halide/src/WasmExecutor.cpp:3180
Condition failed: call_success
Error: wasm_runtime_call_wasm_a failed: Exception: failed to call unlinked import function (env, halide_trace_helper)

      Start 686: tutorial_lesson_08_scheduling_2
32/34 Test #686: tutorial_lesson_08_scheduling_2 ............................Subprocess aborted***Exception:   0.10 sec

Evaluating producer-consumer pipeline with default schedule
[13:59:23:407 - 1ED68D8C0]: warning: failed to link import function (env, halide_trace_helper)
Internal error at /Users/areinking/dev/Halide/src/WasmExecutor.cpp:3180
Condition failed: call_success
Error: wasm_runtime_call_wasm_a failed: Exception: failed to call unlinked import function (env, halide_trace_helper)

      Start 687: tutorial_lesson_09_update_definitions
33/34 Test #687: tutorial_lesson_09_update_definitions ......................Subprocess aborted***Exception:   0.18 sec
[13:59:23:592 - 1ED68D8C0]: warning: failed to link import function (env, halide_trace_helper)
Internal error at /Users/areinking/dev/Halide/src/WasmExecutor.cpp:3180
Condition failed: call_success
Error: wasm_runtime_call_wasm_a failed: Exception: failed to call unlinked import function (env, halide_trace_helper)

      Start 701: tutorial_lesson_24_async
34/34 Test #701: tutorial_lesson_24_async ...................................Subprocess aborted***Exception:   0.10 sec
Error: halide_default_semaphore_init not implemented on this platform.
halide_default_do_parallel_tasks not implemented on this platform.


0% tests passed, 34 tests failed out of 34

Label Time Summary:
correctness        =  23.07 sec*proc (22 tests)
multithreaded      =   7.73 sec*proc (8 tests)
performance        =   0.35 sec*proc (1 test)
python             =   0.87 sec*proc (5 tests)
python_tutorial    =   0.87 sec*proc (5 tests)
tutorial           =   0.67 sec*proc (6 tests)

Total Test time (real) =  25.01 sec

The following tests FAILED:
         37 - correctness_align_bounds (Subprocess aborted)     correctness
         69 - correctness_callable_errors (Subprocess aborted)  correctness
        128 - correctness_exception (Subprocess aborted)        correctness
        144 - correctness_float16_t (Failed)                    correctness
        220 - correctness_interleave (Subprocess aborted)       correctness
        230 - correctness_iterate_over_circle (Subprocess aborted) correctness
        235 - correctness_lerp (Subprocess aborted)             correctness
        240 - correctness_loop_carry (Subprocess aborted)       correctness
        257 - correctness_multi_splits_with_diff_tail_strategies (Subprocess aborted) correctness
        297 - correctness_reduction_non_rectangular (Subprocess aborted) correctness
        303 - correctness_reschedule (Subprocess aborted)       correctness
        320 - correctness_skip_stages_memoize (Subprocess aborted) correctness
        328 - correctness_specialize_trim_condition (Subprocess aborted) correctness
        336 - correctness_stencil_chain_in_update_definitions (Subprocess aborted) correctness
        342 - correctness_strict_fma (Subprocess aborted)       correctness
        349 - correctness_tracing (Subprocess aborted)          correctness
        351 - correctness_tracing_broadcast (Subprocess aborted) correctness
        354 - correctness_transpose_idioms (Subprocess aborted) correctness
        364 - correctness_uninitialized_read (Subprocess aborted) correctness
        379 - correctness_vectorize_guard_with_if (Subprocess aborted) correctness
        405 - correctness_compute_with (Subprocess aborted)     correctness multithreaded
        433 - correctness_rfactor (Subprocess aborted)          correctness multithreaded
        613 - performance_parallel_scenarios (Subprocess aborted) multithreaded performance
        669 - python_tutorial_lesson_04_debugging_2 (Failed)    python python_tutorial
        670 - python_tutorial_lesson_05_scheduling_1 (Failed)   python python_tutorial
        671 - python_tutorial_lesson_06_realizing_over_shifted_domains (Failed) python python_tutorial
        673 - python_tutorial_lesson_08_scheduling_2 (Failed)   python python_tutorial
        674 - python_tutorial_lesson_09_update_definitions (Failed) python python_tutorial
        682 - tutorial_lesson_04_debugging_2 (Subprocess aborted) multithreaded tutorial
        683 - tutorial_lesson_05_scheduling_1 (Subprocess aborted) multithreaded tutorial
        684 - tutorial_lesson_06_realizing_over_shifted_domains (Subprocess aborted) tutorial
        686 - tutorial_lesson_08_scheduling_2 (Subprocess aborted) multithreaded tutorial
        687 - tutorial_lesson_09_update_definitions (Subprocess aborted) multithreaded tutorial
        701 - tutorial_lesson_24_async (Subprocess aborted)     multithreaded tutorial
Errors while running CTest

Once everything works locally, I can add a buildbot configuration for this backend.

soldair and others added 5 commits May 1, 2026 13:58
…jit_externs test

- Support dynamic extern callbacks in WAMR using template native dispatched wrappers.
- Raise WAMR memory heap size threshold, synchronize stack overrides configuration using environment variables HL_WASM_HEAP_SIZE, HL_WASM_STACK_SIZE.
- Renamed test to test/correctness/wasm_jit_externs.cpp with Wasm executor capability checks.
@soldair
Copy link
Copy Markdown
Author

soldair commented May 1, 2026

I reproed the errors locally. it seems like i had the wrong jit target cached. They should be resolved.

HL_JIT_TARGET=wasm-32-wasmrt ctest -j$(nproc) -R "correctness_(align_bounds|callable_errors|exception|float16_t|interleave|iterate_over_circle|lerp|loop_carry|multi_splits_with_diff_tail_strategies|reduction_non_rectangular|reschedule|skip_stages_memoize|specialize_trim_condition|stencil_chain_in_update_definitions|strict_fma|tracing|tracing_broadcast|transpose_idioms|uninitialized_read|vectorize_guard_with_if|compute_with|rfactor)"

I'm on linux so im not sure if i should have a vcpkg preset but im hoping im fine? if not ill learn about it.
Runing all the tests seems to hang at 623/743 but this is the behavior i see at head as well. I'll check back on this Monday. Thanks for your help!

@soldair soldair closed this May 1, 2026
@soldair soldair reopened this May 1, 2026
@soldair
Copy link
Copy Markdown
Author

soldair commented May 1, 2026

opps haha

@alexreinking
Copy link
Copy Markdown
Member

Note that CTest does not honor the HL_JIT_TARGET environment variable. You have to go through the Halide_TARGET cache variable.

@alexreinking
Copy link
Copy Markdown
Member

I'm still seeing a few test failures:

(halide) areinking@Alexanders-MacBook-Pro Halide % ctest --test-dir build/macOS-vcpkg --rerun-failed --output-on-failure
Test project /Users/areinking/dev/Halide/build/macOS-vcpkg
    Start  37: correctness_align_bounds
1/3 Test  #37: correctness_align_bounds .........Subprocess aborted***Exception:   0.34 sec
Internal error at /Users/areinking/dev/Halide/src/WasmExecutor.cpp:3232
Condition failed: call_success
Error: wasm_runtime_call_wasm_a failed: Exception: invalid local type

    Start  69: correctness_callable_errors
2/3 Test  #69: correctness_callable_errors ......Subprocess aborted***Exception:   0.10 sec
Saw expected: (NO ERROR)
Internal error at /Users/areinking/dev/Halide/src/WasmExecutor.cpp:3198
Condition failed: wbuf
Error: hostbuf_to_wasmbuf_wamr failed

    Start 128: correctness_exception
3/3 Test #128: correctness_exception ............Subprocess aborted***Exception:   0.10 sec
Expected compile error:
Error: Implicit cast from float32 to int in argument 1 in call to "f0" is not allowed. Use an explicit cast.

Expected compile error:
Error: Can't index into a reference to Func "f0", because it does not return a Tuple.

Expected compile error:
Error: In update definition 0 of Func "f0":
Tuple element 0 of update definition has type float32, but pure definition has type int32

Expected compile error:
Error: In update definition 0 of Func "f0":
Undefined expression in right-hand-side of update.

Expected internal error:
Internal error at /Users/areinking/dev/Halide/src/IR.cpp:40
Condition failed: a.defined()
Error: Add of undefined

Expected internal error:
Internal error at /Users/areinking/dev/Halide/src/ModulusRemainder.cpp:161
Error: modulus_remainder of bool

Internal error at /Users/areinking/dev/Halide/src/WasmExecutor.cpp:3198
Condition failed: wbuf
Error: hostbuf_to_wasmbuf_wamr failed


0% tests passed, 3 tests failed out of 3

Label Time Summary:
correctness    =   0.53 sec*proc (3 tests)

Total Test time (real) =   0.55 sec

The following tests FAILED:
         37 - correctness_align_bounds (Subprocess aborted)     correctness
         69 - correctness_callable_errors (Subprocess aborted)  correctness
        128 - correctness_exception (Subprocess aborted)        correctness
Errors while running CTest

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants