#include <Halide.h>
#include <stdio.h>

using namespace Halide;

int main(int argc, char **argv) {
    Func f, g;
    Var x;

    f(x) = x;
    g(x) = f(x) + f(2*x);

    g.gpu_tile(x, 16);
    f.compute_at(g, Var::gpu_blocks()).gpu_threads(x);

    // The amount of shared memory required varies with x

    Image<int> out = g.realize(100);
    for (int x = 0; x < 100; x++) {
        int correct = 3*x;
        if (out(x) != correct) {
            printf("out(%d) = %d instead of %d\n",
                   x, out(x), correct);
            return -1;
        }
    }

    printf("Success!\n");
    return 0;
}

Test for shared allocations and thread blocks that depend on blockidx
Test for shared allocations and thread blocks that depend on blockidx


Former-commit-id: c34c1c917c975e513556b6475c4b4fba2e1a67b3