This source file includes following definitions.
- main
#include <stdio.h>
#include "Halide.h"
#include <algorithm>
using namespace Halide;
int main(int argc, char **argv) {
Var x, y;
Func f, g;
int W = 1024*10/4, H = 1024;
printf("Defining function...\n");
f(x, y) = max(x, y);
g(x, y) = clamp(f(x, y), 20, 100);
Target target = get_jit_target_from_environment();
if (target.has_gpu_feature() || target.has_feature(Target::OpenGLCompute)) {
Var xi, yi;
f.compute_root().gpu_tile(x, y, xi, yi, 16, 16);
g.compute_root().gpu_tile(x, y, xi, yi, 16, 16);
}
printf("Realizing function...\n");
Buffer<int> img = g.realize(W, H, target);
for (int i = 0; i < W; i++) {
for (int j = 0; j < H; j++) {
int m = std::max(i,j);
if (img(i, j) != (m < 20 ? 20 :
m > 100 ? 100 :
m)) {
printf("img[%d, %d] = %d\n", i, j, img(i, j));
return -1;
}
}
}
printf("Success!\n");
return 0;
}