#include "Halide.h"
#include <stdio.h>
int main(int argc, char **argv) {
std::vector<Argument> args(2);
args[0] = input;
args[1] = offset;
brighter(x, y) = input(x, y) + offset;
std::vector<Target::Feature> arm_features;
brighter.
compile_to_file(
"lesson_11_arm_32_android", args,
"brighter", target);
std::vector<Target::Feature> x86_features;
brighter.
compile_to_file(
"lesson_11_x86_64_windows", args,
"brighter", target);
std::vector<Target::Feature> 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;
}