0
votes

I'm trying to use the Halide-lang AOT and cross compilation tutorials. What I would like to do is cross AOT compile a Halide program for a Cortex A9 embedded Linux target.

I've modified the lesson_11_cross_compilation.cpp with the following changes:

Target target;
target.os = Target::Linux; // The operating system
target.arch = Target::ARM;   // The CPU architecture
target.bits = 32;            // The bit-width of the architecture
std::vector<Target::Feature> arm_features; // A list of features to set
arm_features.push_back(Target::ARMv7s);
target.set_features(arm_features);
brighter.compile_to_file("lesson_11_arm_32_linux", args, target); // Pass the target as the last argument.
brighter.compile_to_c("lession_11.c", args, "foo", target);

I compile this with the g++ command listed at the top of the lesson_11_cross_compilation.cpp file. This produces the lession_11 executable. I run the executable and I get a lesson_11_arm_32_linux.h/o files.

I then run my cross compiler on that file to try and generate a program for my target using the following command line:

/opt/Xilinx/SDK/2014.2/gnu/arm/lin/bin/arm-xilinx-linux-gnueabi-g++ -o test -std=c++11 -lpthread lesson_10_aot_compilation_run.cpp lesson_11_arm_32_linux.o -mfpu=neon-vfpv4 /opt/Xilinx/SDK/2014.2/gnu/arm/lin/bin/../lib/gcc/arm-xilinx-linux-gnueabi/4.8.1/../../../../arm-xilinx-linux-gnueabi/bin/ld: error: lesson_11_arm_32_linux.o uses VFP register arguments, test does not /opt/Xilinx/SDK/2014.2/gnu/arm/lin/bin/../lib/gcc/arm-xilinx-linux-gnueabi/4.8.1/../../../../arm-xilinx-linux-gnueabi/bin/ld: failed to merge target specific data of file lesson_11_arm_32_linux.o collect2: error: ld returned 1 exit status

It seems Halide generates code that uses the VFP. I've tried changing the -mfpu option and -mfloat-abi=softfp, soft, and hard. Nothing works. Is there a way to configure Halide to generate a certain type of FPU instructions?

1

1 Answers

0
votes

I don't think you want armv7s for the cortex-a9. For 32-bit arm Halide assumes a cortex-a9 unless you have armv7s enabled.

If you have a 'gnueabihf' toolchain you can use instead, that should work (hard floats). If you're willing to compile Halide yourself, you could also modify CodeGen_ARM::use_soft_float_abi() (https://github.com/halide/Halide/blob/master/src/CodeGen_ARM.cpp#L1252) to do what you want.

We should probably add a target flag that selects the float abi.