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
|
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include "HalideBuffer.h"
#include "HalideRuntime.h"
#include "max_filter.h"
#include "max_filter_auto_schedule.h"
#include "halide_benchmark.h"
#include "halide_image_io.h"
using namespace Halide::Tools;
int main(int argc, char **argv) {
if (argc != 3) {
printf("Usage: %s in out\n", argv[0]);
return 1;
}
Halide::Runtime::Buffer<float, 3> input = load_and_convert_image(argv[1]);
Halide::Runtime::Buffer<float, 3> output(input.width(), input.height(), 3);
double best_manual = benchmark([&]() {
max_filter(input, output);
output.device_sync();
});
printf("Manually-tuned time: %gms\n", best_manual * 1e3);
double best_auto = benchmark([&]() {
max_filter_auto_schedule(input, output);
output.device_sync();
});
printf("Auto-scheduled time: %gms\n", best_auto * 1e3);
convert_and_save_image(output, argv[2]);
printf("Success!\n");
return 0;
}
|