1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
|
#include "Halide.h"
#include <stdio.h>
using namespace Halide;
int main(int argc, char **argv) {
// Test various possible pieces of syntax for tracking the various
// definitions of a Func. Mostly we just want to make sure they
// compile.
RDom r(0, 16);
Func f;
Var x;
Func ref;
{
Stage pure =
f(x) = x;
Stage fix_first =
f(0) = 1;
Stage rewrites[] = {
f(r * 2) = 13,
f(r * 4) = 14};
struct {
Stage a, b, c;
} more_updates = {
f(3 * r) = 4,
f(2 * r) = 8,
f(5 * r) = 2};
f.compute_root();
pure.vectorize(x, 4);
rewrites[0].parallel(r);
rewrites[1].vectorize(r, 4);
more_updates.a.vectorize(r, 4);
more_updates.b.vectorize(r, 4);
more_updates.c.vectorize(r, 4);
f.update().unscheduled(); // fix_first isn't scheduled
}
// Define the same thing without all the weird syntax and without
// any scheduling.
{
ref(x) = x;
ref(0) = 1;
ref(r * 2) = 13;
ref(r * 4) = 14;
ref(3 * r) = 4;
ref(2 * r) = 8;
ref(5 * r) = 2;
}
Buffer<int> result = f.realize({128});
Buffer<int> result_ref = ref.realize({128});
RDom check(result);
uint32_t error = evaluate<uint32_t>(
maximum(abs(result(check) - result_ref(check))));
if (error) {
printf("There was a difference between using named updates and not.\n");
return 1;
}
printf("Success!\n");
return 0;
}
|