This source file includes following definitions.
- tick
- main
#include "brighten_planar.h"
#include "brighten_interleaved.h"
#include "brighten_either.h"
#include "brighten_specialized.h"
#include "HalideBuffer.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include "clock.h"
double tick(const char *name) {
static double t_old = 0;
double t_new = current_time();
double dt = t_new - t_old;
if (name) {
printf("%s: %f\n", name, dt);
}
t_old = t_new;
return dt;
}
int main(int argc, char **argv) {
Halide::Runtime::Buffer<uint8_t> planar_input(1024, 768, 3);
Halide::Runtime::Buffer<uint8_t> planar_output(1024, 768, 3);
Halide::Runtime::Buffer<uint8_t> interleaved_input =
Halide::Runtime::Buffer<uint8_t>::make_interleaved(1024, 768, 3);
Halide::Runtime::Buffer<uint8_t> interleaved_output =
Halide::Runtime::Buffer<uint8_t>::make_interleaved(1024, 768, 3);
assert(planar_input.dim(0).stride() == 1);
assert(planar_output.dim(0).stride() == 1);
assert(interleaved_input.dim(0).stride() == 3);
assert(interleaved_output.dim(0).stride() == 3);
assert(interleaved_input.dim(2).stride() == 1);
assert(interleaved_output.dim(2).stride() == 1);
tick(NULL);
for (int i = 0; i < 1000; i++) {
brighten_planar(planar_input, 1, planar_output);
}
double planar_time = tick("brighten_planar");
for (int i = 0; i < 1000; i++) {
brighten_interleaved(interleaved_input, 1, interleaved_output);
}
double interleaved_time = tick("brighten_interleaved");
assert(planar_time < interleaved_time);
for (int i = 0; i < 1000; i++) {
brighten_either(planar_input, 1, planar_output);
}
double either_planar_time = tick("brighten_either on planar images");
assert(planar_time < either_planar_time);
for (int i = 0; i < 1000; i++) {
brighten_either(interleaved_input, 1, interleaved_output);
}
double either_interleaved_time = tick("brighten_either on interleaved images");
assert(interleaved_time < either_interleaved_time);
for (int i = 0; i < 1000; i++) {
brighten_specialized(planar_input, 1, planar_output);
}
double specialized_planar_time = tick("brighten_specialized on planar images");
assert(specialized_planar_time < 1.5 * planar_time);
for (int i = 0; i < 1000; i++) {
brighten_specialized(interleaved_input, 1, interleaved_output);
}
double specialized_interleaved_time = tick("brighten_specialized on interleaved images");
assert(specialized_interleaved_time < 1.5 * interleaved_time);
return 0;
}