#include "Halide.h"
#include <stdio.h>
int main(int argc, char **argv) {
Func brighter;
Var x, y;
Param<uint8_t> offset;
ImageParam input(type_of<uint8_t>(), 2);
std::vector<Argument> args(2);
args[0] = input;
args[1] = offset;
brighter(x, y) = input(x, y) + offset;
brighter.vectorize(x, 16).parallel(y);
brighter.compile_to_file("lesson_11_host", args, "brighter");
Target target;
target.bits = 32;
std::vector<Target::Feature> arm_features;
target.set_features(arm_features);
brighter.compile_to_file("lesson_11_arm_32_android", args, "brighter", target);
target.bits = 64;
std::vector<Target::Feature> x86_features;
target.set_features(x86_features);
brighter.compile_to_file("lesson_11_x86_64_windows", args, "brighter", target);
target.bits = 32;
std::vector<Target::Feature> armv7s_features;
target.set_features(armv7s_features);
brighter.compile_to_file("lesson_11_arm_32_ios", args, "brighter", target);
uint8_t arm_32_android_magic[] = {0x7f,
'E',
'L',
'F',
1,
1,
1};
FILE *f =
fopen(
"lesson_11_arm_32_android.o",
"rb");
if (!f || fread(header, 32, 1, f) != 1) {
printf("Object file not generated\n");
return -1;
}
if (
memcmp(header, arm_32_android_magic,
sizeof(arm_32_android_magic))) {
printf("Unexpected header bytes in 32-bit arm object file.\n");
return -1;
}
uint8_t win_64_magic[] = {0x64, 0x86};
f =
fopen(
"lesson_11_x86_64_windows.obj",
"rb");
if (!f || fread(header, 32, 1, f) != 1) {
printf("Object file not generated\n");
return -1;
}
if (
memcmp(header, win_64_magic,
sizeof(win_64_magic))) {
printf("Unexpected header bytes in 64-bit windows object file.\n");
return -1;
}
uint32_t arm_32_ios_magic[] = {0xfeedface,
12,
11,
1};
f =
fopen(
"lesson_11_arm_32_ios.o",
"rb");
if (!f || fread(header, 32, 1, f) != 1) {
printf("Object file not generated\n");
return -1;
}
if (
memcmp(header, arm_32_ios_magic,
sizeof(arm_32_ios_magic))) {
printf("Unexpected header bytes in 32-bit arm ios object file.\n");
return -1;
}
printf("Success!\n");
return 0;
}
This file defines the class FunctionDAG, which is our representation of a Halide pipeline,...
unsigned __INT8_TYPE__ uint8_t
int memcmp(const void *s1, const void *s2, size_t n)
unsigned __INT32_TYPE__ uint32_t
void * fopen(const char *, const char *)