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

using namespace Halide;

int main(int argc, char **argv) {
    Var x, y;
    Var xo, xi, yo, yi;

    Func f, g;

    printf("Defining function...\n");

    f(x, y) = cast<float>(x);
    g(x, y) = f(x+1, y) + f(x-1, y);

    Target target = get_jit_target_from_environment();
    if (target.has_gpu_feature()) {
        Var xi, yi;
        g.gpu_tile(x, y, 8, 8, GPU_DEFAULT);
        f.compute_at(g, Var("blockidx")).gpu_threads(x, y, GPU_DEFAULT);
    }

    printf("Realizing function...\n");

    Image<float> im = g.realize(32, 32, target);

    for (int i = 0; i < 32; i++) {
        for (int j = 0; j < 32; j++) {
            if (im(i,j) != 2*i) {
                printf("im[%d, %d] = %f\n", i, j, im(i,j));
                return -1;
            }
        }
    }

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

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

using namespace Halide;

int main(int argc, char **argv) {
    Var x, y;
    Var xo, xi, yo, yi;

    Func f, g;

    printf("Defining function...\n");

    f(x, y) = cast<float>(x);
    g(x, y) = f(x+1, y) + f(x-1, y);

    Target target = get_jit_target_from_environment();
    // shared memory not currently working in OpenCL
    if (target.features & Target::CUDA) {
        Var xi, yi;
        g.gpu_tile(x, y, 8, 8, GPU_CUDA);
        f.compute_at(g, Var("blockidx")).gpu_threads(x, y, GPU_CUDA);
    }

    printf("Realizing function...\n");

    Image<float> im = g.realize(32, 32, target);

    for (int i = 0; i < 32; i++) {
        for (int j = 0; j < 32; j++) {
            if (im(i,j) != 2*i) {
                printf("im[%d, %d] = %f\n", i, j, im(i,j));
                return -1;
            }
        }
    }

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

Disable shared memory test for OpenCL until bugginess is resolved.
Disable shared memory test for OpenCL until bugginess is resolved.


Former-commit-id: a9b27252698ffb23d91dd013ca3470237f2b3f69