halide / Halide

a language for fast, portable data-parallel computation
https://halide-lang.org
Other
5.89k stars 1.07k forks source link

Fix and test HelloiOS app #6536

Open Infinoid opened 2 years ago

Infinoid commented 2 years ago

Based on gitter discussion, the HelloiOS app seems to have developed some bit-rot.

Here are the issues I see:

I think that at a minimum, this fix is needed:

@@ -129,17 +129,18 @@ public:
                     .unroll(c)
                     .gpu_tile(y, yi, 8);
             }
+            RVar rxi{"rxi"}, ryi{"ryi"};
             new_state.update(4)
                 .reorder(c, clobber.x)
                 .unroll(c)
-                .gpu_tile(clobber.x, clobber.y, 1, 1);
+                .gpu_tile(clobber.x, clobber.y, rxi, ryi, 1, 1);

             state.dim(0).set_stride(3);
             state.dim(2).set_stride(1).set_extent(3);

I don't have xcode or an iOS device, so I can't test any further than building/generating the Halide pipelines. But after applying the above fix, apparently this failure occurs at runtime:

Assertion failed: (i >= 0 && i < this->dimensions()), function dim, file HalideBuffer.h, line 496.

Infinoid commented 2 years ago

Here's how I tested the parts I could. It's based on a shell script embedded within the xcode project file.

#!/bin/bash

set -ex

c++ reaction_diffusion_2_generator.cpp ../../../tools/GenGen.cpp \
    -std=c++17 \
    -fno-rtti \
    -I ../../../build/include \
    -I ../../../tools \
    -L ../../../build/lib \
    -L ../../../build/src \
    -lHalide \
    -Wl,-rpath,../../../build/lib \
    -Wl,-rpath,../../../build/src \
    -o ./reaction_diffusion_2_generator

echo assuming iOS target
TARGET=arm-64-ios
echo TARGET=$TARGET

#non-GPU
for GEN in init update render; do
    ./reaction_diffusion_2_generator -g reaction_diffusion_2_${GEN} -f reaction_diffusion_2_${GEN} -n reaction_diffusion_2_${GEN} -o . target=${TARGET}-user_context
done

# Metal
for GEN in init update render; do
    ./reaction_diffusion_2_generator -g reaction_diffusion_2_${GEN} -f reaction_diffusion_2_metal_${GEN} -n reaction_diffusion_2_metal_${GEN} -o . target=${TARGET}-metal-user_context
done