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

Compile for armv8. #2816

Merged
merged 4 commits into from
Jul 13, 2017
Merged

Compile for armv8. #2816

merged 4 commits into from
Jul 13, 2017

Conversation

hedaoyuan
Copy link
Contributor

@hedaoyuan hedaoyuan commented Jul 12, 2017

Cmake support for the compilation of armv8(Android).

@hedaoyuan hedaoyuan requested a review from Xreki July 12, 2017 05:42
@Xreki
Copy link
Contributor

Xreki commented Jul 12, 2017

I create a standalone toolchain use following command:

../android-ndk-r12b/build/tools/make-standalone-toolchain.sh \
    --arch=arm64 \
    --platform=android-21 \
    --install-dir=arm64-android-21-gcc

Here is my cmake command:

cmake -DCMAKE_SYSTEM_NAME=Android \
      -DANDROID_STANDALONE_TOOLCHAIN=$ANDROID_ARM64_TOOLCHAIN_ROOT \
      -DANDROID_ABI=arm64-v8a \
      -DCMAKE_INSTALL_PREFIX=$PROJ_ROOT/dist \
      -DCMAKE_BUILD_TYPE=RelWithDebInfo \
      -DCMAKE_C_FLAGS_RELWITHDEBINFO="-O3" \
      -DCMAKE_CXX_FLAGS_RELWITHDEBINFO="-O3" \
      -DWITH_C_API=ON \
      -DWITH_SWIG_PY=OFF \
      -DWITH_STYLE_CHECK=OFF \
      -DCMAKE_PREFIX_PATH="$JUMBO_ROOT" \
      ..

And I met some error:

[ 27%] Building CXX object proto/CMakeFiles/paddle_proto.dir/DataConfig.pb.cc.o
In file included from /usr/include/features.h:385:0,
                 from /usr/include/wchar.h:28,
                 from /home/liuyiqun01/install/android/toolchains/arm64-android-21-gcc/include/c++/4.9.x/cwchar:44,
                 from /home/liuyiqun01/install/android/toolchains/arm64-android-21-gcc/include/c++/4.9.x/bits/postypes.h:40,
                 from /home/liuyiqun01/install/android/toolchains/arm64-android-21-gcc/include/c++/4.9.x/bits/char_traits.h:40,
                 from /home/liuyiqun01/install/android/toolchains/arm64-android-21-gcc/include/c++/4.9.x/string:40,
                 from /home/liuyiqun01/github/Paddle/build_android/proto/DataConfig.pb.h:7,
                 from /home/liuyiqun01/github/Paddle/build_android/proto/DataConfig.pb.cc:5:
/usr/include/gnu/stubs.h:7:27: fatal error: gnu/stubs-32.h: No such file or directory
 # include <gnu/stubs-32.h>
                           ^
compilation terminated.
make[2]: *** [proto/CMakeFiles/paddle_proto.dir/DataConfig.pb.cc.o] Error 1
make[1]: *** [proto/CMakeFiles/paddle_proto.dir/all] Error 2
make: *** [all] Error 2

Are there any extra limits to the ndk version or android api level?

@Xreki
Copy link
Contributor

Xreki commented Jul 12, 2017

Discussed with @hedaoyuan , we found the error is caused by wrongly finding the host boost library. Current solution is to disable all the boost-related and refactor-related codes.

Copy link
Contributor

@Xreki Xreki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is almost ok and I can compile for armv8, but not run the unittests because I have no android phone of armv8 architecture.
Another change suggested to made to support cmake of higher version. Change line 196-197 in android.cmake to:

IF(ANDROID_ABI MATCHES "^armeabi(-v7a)?$")
    SET(CMAKE_ANDROID_ARM_MODE ${ANDROID_ARM_MODE})
    IF(ANDROID_ABI STREQUAL "armeabi-v7a")
        SET(CMAKE_ANDROID_ARM_NEON ${ANDROID_ARM_NEON})
    ENDIF()
ENDIF()

ELSEIF(ANDROID_ABI STREQUAL "arm64-v8a")
SET(TARGET "ARMV8")
ENDIF()
SET(OPTIONAL_ARGS HOSTCC=${HOST_C_COMPILER} TARGET=${TARGET} ARM_SOFTFP_ABI=1 USE_THREAD=0)
Copy link
Contributor

@Xreki Xreki Jul 13, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just remind here, ARM_SOFTFP_ABI=1 is of no use for ARMV8, however, it won't make any difference for the building process. And there is no need of softfp support for armv8, thus we may use the master or other branchs, if they are faster.

@@ -90,7 +90,7 @@
# including binary directory for generated headers.
include_directories(${CMAKE_CURRENT_BINARY_DIR})

if(NOT APPLE)
if(NOT APPLE AND NOT ANDROID)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove NOT APPLE in line 97, or add AND NOT ANDROID as this line.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@hedaoyuan hedaoyuan merged commit 90cf44d into PaddlePaddle:develop Jul 13, 2017
@Xreki Xreki added the Android label Sep 30, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants