Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
Alabate opened this issue Dec 4, 2017 · 17 comments
Closed

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

Alabate opened this issue Dec 4, 2017 · 17 comments
Labels

Comments

@Alabate
Copy link
Contributor

Alabate commented Dec 4, 2017

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:

  • maplab_common assert 64bit systems:
Errors     << maplab_common:make /home/balyo/maplab/logs/maplab_common/build.make.001.log                                                                                                    
/home/balyo/maplab/src/maplab/common/maplab-common/src/unique-id.cc: In function 'void common::internal::generateUnique128BitHash(uint64_t*)':
/home/balyo/maplab/src/maplab/common/maplab-common/src/unique-id.cc:9:3: error: static assertion failed: Please adapt the below to your non-64-bit system.
   static_assert(
   ^
make[2]: *** [CMakeFiles/maplab_common.dir/src/unique-id.cc.o] Error 1
make[2]: *** Waiting for unfinished jobs....
make[1]: *** [CMakeFiles/maplab_common.dir/all] Error 2
make: *** [all] Error 2
cd /home/balyo/maplab/build/maplab_common; catkin build --get-env maplab_common | catkin env -si  /usr/bin/make --jobserver-fds=6,7 -j; cd -
  • rovio use x86-specific option:
Errors     << rovio:make /home/balyo/maplab/logs/rovio/build.make.000.log                                                                                                                    
c++: error: unrecognized command line option '-mssse3'
make[2]: *** [CMakeFiles/rovio.dir/src/CameraCalibration.cpp.o] Error 1
make[2]: *** Waiting for unfinished jobs....

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

@dymczykm
Copy link
Contributor

dymczykm commented Dec 5, 2017

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
Copy link
Contributor Author

Alabate commented Dec 7, 2017

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 Alabate changed the title Build the online part of maplab for ARMv7-A (32bit) Build maplab on ARMv7-A (32bit) Dec 7, 2017
@Alabate
Copy link
Contributor Author

Alabate commented Dec 7, 2017

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 ?

  • I see on some part of the project that there is an ANDROID flag in cmake that enable neon. We could use this flag in every part of the project. In this case a simple parameter in the catkin worskpace would enable the arm build. However, I don't think ANDROID is a good name for a such flag, because android is not the only arm system and android can be installed on x86.
  • In aslam_cv2/aslam_cv_common/cmake/export_flags.cmake there is also the IS_ARM_ARCHITECTURE flag which is generated by the following script. This could also be a good solution, the name of the flag is definitely better. But in this case, we have to put this script somewhere and include it in every CMakeFile.txt. We could put it in every repo that need it, or in another simple repo which would be a dependency.
set(IS_ARM_ARCHITECTURE FALSE)
execute_process(COMMAND uname -m COMMAND tr -d '\n' OUTPUT_VARIABLE ARCHITECTURE)
if (ARCHITECTURE MATCHES "^(arm)")
  set(IS_ARM_ARCHITECTURE TRUE)
endif()

What do you think ?

@fabianbl
Copy link
Contributor

fabianbl commented Dec 7, 2017

@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
Copy link
Contributor

fabianbl commented Dec 7, 2017

Actually a think this script might do the job.

@bidbest
Copy link

bidbest commented Dec 8, 2017

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
Copy link

Could this be a simple fix - JakobEngel/dso#59 ?

@thien94
Copy link

thien94 commented Dec 15, 2017

@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
Copy link

bidbest commented Dec 15, 2017

@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
Copy link
Contributor

@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
Copy link

megamindhe commented Dec 17, 2017

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
Copy link
Contributor

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
Copy link
Contributor

fabianbl commented Jan 24, 2018

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
Copy link

dan9thsense commented Jan 30, 2018

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
Copy link
Contributor

@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
Copy link
Contributor

mfehr commented Jan 30, 2018

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

@dan9thsense
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

9 participants