#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;
target.
os = Target::Android;
target.
arch = Target::ARM;
std::vector<Target::Feature> arm_features;
brighter.
compile_to_file(
"lesson_11_arm_32_android", args,
"brighter", target);
target.
os = Target::Windows;
target.
arch = Target::X86;
std::vector<Target::Feature> x86_features;
x86_features.push_back(Target::AVX);
x86_features.push_back(Target::SSE41);
brighter.
compile_to_file(
"lesson_11_x86_64_windows", args,
"brighter", target);
target.
arch = Target::ARM;
std::vector<Target::Feature> armv7s_features;
armv7s_features.push_back(Target::ARMv7s);
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;
}
void compile_to_file(const std::string &filename_prefix, const std::vector< Argument > &args, const std::string &fn_name="", const Target &target=get_target_from_environment())
Compile to object file and header pair, with the given arguments.
Func & parallel(const VarOrRVar &var)
Mark a dimension to be traversed in parallel.
Func & vectorize(const VarOrRVar &var)
Mark a dimension to be computed all-at-once as a single vector.
An Image parameter to a halide pipeline.
A scalar parameter to a halide pipeline.
A Halide variable, to be used when defining functions.
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
A struct representing a target machine and os to generate code for.
void set_features(const std::vector< Feature > &features_to_set, bool value=true)
enum Halide::Target::Arch arch
int bits
The bit-width of the target machine.
enum Halide::Target::OS os