This source file includes following definitions.
- main
#include "Halide.h"
#include <stdio.h>
#include <algorithm>
using namespace Halide;
int main(int argc, char **argv) {
{
Func f;
Var x;
RDom r(0, 100);
f(x) = 0;
f(r/2) = r/2;
f.update().allow_race_conditions().parallel(r);
Buffer<int> out = f.realize(100);
for (int i = 0; i < 100; i++) {
int correct = (i < 50) ? i : 0;
if (out(i) != correct) {
printf("out(%d) = %d instead of %d\n",
i, out(i), correct);
return -1;
}
}
}
{
Func f;
Var x;
RDom r(0, 256);
Expr permuted = (38*r*r + 193*r + 32) % 256;
f(x) = -1;
f(permuted) = r;
f.update().allow_race_conditions().vectorize(r, 4).parallel(r);
Buffer<int> out = f.realize(256);
std::sort(&out(0), &out(256));
for (int i = 0; i < 256; i++) {
if (out(i) != i) {
printf("Error: after sorting, out(%d) was %d instead of %d\n", i, out(i), i);
return -1;
}
}
}
printf("Success!\n");
return 0;
}