ethz-asl / maplab

A Modular and Multi-Modal Mapping Framework
https://maplab.asl.ethz.ch
Apache License 2.0
2.61k stars 721 forks source link

Build maplab on ARMv7-A (32bit) #7

Closed Alabate closed 6 years ago

Alabate commented 6 years ago

First of all, thank you for this awesome project.

I'd like to use the online part of maplab on an embedded 32bit ARM cpu. I didn't find any way to build only the online part, so I tried to build the whole project and it fails on those errors:

How much work would be required to make it compatible with this architecture ?

dymczykm commented 6 years ago

Hi, thanks a lot for your question.

To be honest, the amount of work is difficult to predict, but I think it's worth a try. It's also hard to say what will be the impact on performance as you're lacking SSE optimization that Eigen broadly uses (and Eigen matrices are present all over the project).

1) This Id problem in maplab_common is rather easy to fix, you just need to hack in a routine to generate a unique id on a 32-bit machine. As you can see, id is composed of two 64-bit values so you just need to properly initialize them (make sure the id space is 128bit not 64bit to avoid Id clashes).

2) -mssse3 flag is just to enable Eigen optimizations using SSE3. You can probably kick out this flag for now and see what happens, I don't think we strictly depend on SSE, it was just to promote the optimization by the compiler.

Another issue you may encounter are Eigen alignment issues (we might be missing proper alignment in some places), which show up much more often on 32-bit machines. On the other hand, they are resulting from x86 SSE optimizations, not sure if Eigen has some ARM-specific code (NEON?) that might cause them.

Alabate commented 6 years ago

Ok, so I managed to build and start a bag. I'm giving you the diff of my workspace, to let anyone do the same. But those are really dirty modifications, sometimes even useless or just dumb (like in descriptor-projection where I tried to add 3 times the same thing in the CMakeLists.txt because it wouldn't work). We have to find clean ways to fix the same problems.

https://gist.github.com/Alabate/c1017c4f0a6c3b9e5e6db75ddbcddf0b

Alabate commented 6 years ago

As you can see, most of modifications are removing the -mssse3 to add -mfpu=neon instead. How could we do this in a clean way ?

What do you think ?

fabianbl commented 6 years ago

@Alabate Thanks a lot for your efforts to port maplab to ARM based devices and for sharing your diff. Regarding your remarks: I agree, ANDROID is not a good flag name for this purpose, but having a global cmake flag which is set based on the processor architecture sounds like a good idea. Potentially, we can also replace the script from aslam_cv_common with a combination of FindARM.cmake and FindSSE.cmake and then set the -mssse3 or -mfpu=neon flags based on this. I think we can put this script just in aslam_cv_common and then copy it to the two other repos that also use it. As I'm currently also building maplab on an Odroid, I will try to put something together and tag you, ok?

fabianbl commented 6 years ago

Actually a think this script might do the job.

bidbest commented 6 years ago

Guys, thanks for the amazing project. As @Alabate I was trying to make it work on the Nvidia TX1. Like you point out, the extensive use of -mssse3 is the biggest concern. Regarding the dependencies, I manage to compile:

doxygen_catkin -> ok catkin_simple -> ok gflags -> ok glogs -> ok (use lates version from git, remove the patch in the make, have libunwind-dev libunwind8-dev pre installed) Voxblox -> ok Opencv3_catkin -> ok

the rest still trying out, especially aslam pkg (-mssse3) and brisk. Brisk released a v2, and it should implement NEON. Still need to try it.

Keep you update and thanks for the work!

Changliu52 commented 6 years ago

Could this be a simple fix - https://github.com/JakobEngel/dso/pull/59 ?

thien94 commented 6 years ago

@bidbest Have you managed to build brisk on the TX1? When I remove the -msse3 option I get error: fatal error: emmintrin.h: No such file or directory I found this SSE2NEON.h, maybe this could help?

bidbest commented 6 years ago

@hoangthien94 Diden't try it yet. I'm currently working on x86 processors, will try again on arm in the future. If I remember correctly emmintrin.h file is considered only when flagh sse3 is present. You can try to test Brisk v2, that should support NEON., and hope it will not conflict with the rest of maplab.

fabianbl commented 6 years ago

@hoangthien94 We are working on porting maplab to ARM. Regarding ethz-asl/brisk repo, you can alreay checkout the feature/port-to-arm branch there which should do the job.

megamindhe commented 6 years ago

Hi @fabianbl, I have tried the feature/port-to-arm branch ,but it still failed when building brisk with following errors:

c++: error: unrecognized command line option ‘-mfpu=neon’

My device is Nvidia Jetson TX2 which's architecture is aarch64.

$ uname -a
Linux CAR01-CU03 4.4.38 #1 SMP PREEMPT Tue Oct 10 15:24:32 CST 2017 aarch64 aarch64 aarch64 GNU/Linux
fabianbl commented 6 years ago

Hi @megamindhe . Thank you a lot for your report. Unfortunately, we weren't able yet to test this on an armv8 architecture (but will do so soon). Apparently, for these processors, no specifications for using advanced SIMD are necessary (see here). For now, you can simply comment out all occurrences of -mfpu=neon (e.g. here in ethz-asl/ethzasl_brisk).

fabianbl commented 6 years ago

We released an experimental pre-release branch which adds build compatibility for armv7 and armv8 processors (along with some other changes).

You can test it by checking out the branch pre-release-january in both the maplab and the maplab_dependencies repo:

git pull
git checkout pre-release-january
git submodule init
git submodule update --recursive

After this, clean the catkin workspace and rebuild it:

catkin clean
catkin build maplab

We are happy to hear if this works for you.

dan9thsense commented 6 years ago

I tried building on a Jetson tx2, ubuntu 16.04, ROS kinetic, with the experimental pre-release branch. The initial try failed with an "internal compiler error" while building rovio. Looking at the logfile, the error occurred right after:

[ 94%] Built target feature_tracker_node

On the second try, it succeeded with rovio but failed while building vi_map (46/91), with this error:

Errors << vi_map:cmake /home/nvidia/maplab_ws/logs/vi_map/build.cmake.000.log
CMake Error at /home/nvidia/maplab_ws/devel/share/catkin_simple/cmake/catkin_simple-extras.cmake:38 (find_package): By not providing "Findbenchmark_catkin.cmake" in CMAKE_MODULE_PATH this project has asked CMake to find a package configuration file provided by "benchmark_catkin", but CMake did not find one.

Could not find a package configuration file provided by "benchmark_catkin" with any of the following names:

benchmark_catkinConfig.cmake
benchmark_catkin-config.cmake
fabianbl commented 6 years ago

@dan9thsense Thank you for your report. I think what you can do is:

cd ~/maplab_ws/src/maplab_dependencies
git submodule init
git submodule update

This will initialize and checkout benchmark_catkin which was not there in the master branch. Forgot to mention this, I now added it to the description above.

mfehr commented 6 years ago

@fabianbl I added your instructions to the PR description as well, thx.

dan9thsense commented 6 years ago

Good news! With that change the entire package builds successfully.