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

Add the support of the cross-compiling for iOS devices #3764

Merged
merged 20 commits into from
Sep 20, 2017

Conversation

Xreki
Copy link
Contributor

@Xreki Xreki commented Aug 30, 2017

Xcode is used as the toolchain for cross-compiling for iOS devices. Make sure Xcode is installed on your Mac.

Use the following CMake command

cmake -DCMAKE_INSTALL_PREFIX=/home/liuyiqun/paddle \
      -DCMAKE_SYSTEM_NAME=iOS \
      -DIOS_PLATFORM=OS \
      -DCMAKE_OSX_ARCHITECTURES="arm64" \
      -DWITH_C_API=ON \
      -DUSE_EIGEN_FOR_BLAS=ON \
      -DWITH_TESTING=OFF \
      -DWITH_SWIG_PY=OFF \
      -DWITH_STYLE_CHECK=OFF \
      -DCMAKE_BUILD_TYPE=Release \
      ..
make
make install

Set -DIOS_USE_VECLIB_FOR_BLAS=ON to use veclib, such as

cmake -DCMAKE_INSTALL_PREFIX=/home/liuyiqun/paddle \
      -DCMAKE_SYSTEM_NAME=iOS \
      -DIOS_PLATFORM=OS \
      -DCMAKE_OSX_ARCHITECTURES="arm64" \
      -DIOS_USE_VECLIB_FOR_BLAS=ON \
      -DWITH_C_API=ON \
      -DWITH_TESTING=OFF \
      -DWITH_SWIG_PY=OFF \
      -DWITH_STYLE_CHECK=OFF \
      -DCMAKE_BUILD_TYPE=Release \
      ..

When neither IOS_USE_VECLIB_FOR_BLAS nor USE_EIGEN_FOR_BLAS is set , OpenBLAS will be used. You can change CMAKE_OSX_ARCHITECTURES to "armv7", but note OpenBLAS can not be built for armv7.

TODO:

  • Support multiple architectures through a single make process
  • Fix the linking problem

@Xreki Xreki requested review from NHZlX and hedaoyuan August 30, 2017 11:08
…r Android and iOS.

Recover the mistakenly deleted WARPCTC variable in cmake.
@NHZlX
Copy link
Contributor

NHZlX commented Aug 30, 2017

look forward to the support for armv7 and simulator

@Xreki Xreki force-pushed the build_ios branch 8 times, most recently from d0d0db6 to 473bf59 Compare September 5, 2017 01:55
hedaoyuan
hedaoyuan previously approved these changes Sep 19, 2017
Copy link
Contributor

@hedaoyuan hedaoyuan left a comment

Choose a reason for hiding this comment

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

赞!

CMakeLists.txt Outdated
if(ANDROID)
if(${CMAKE_SYSTEM_VERSION} VERSION_LESS "16")
if(ANDROID OR IOS)
if(ANDROID AND ${CMAKE_SYSTEM_VERSION} VERSION_LESS "16")
Copy link
Contributor

Choose a reason for hiding this comment

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

这个ANDROID判断需要提到外面,否则后面那个elseif分支有问题。

Copy link
Contributor Author

@Xreki Xreki Sep 20, 2017

Choose a reason for hiding this comment

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

对的,merge的时候没注意。Done。


IF(CMAKE_CROSSCOMPILING)
SET(OPTIONAL_ARGS HOSTCC=${HOST_C_COMPILER})
GET_FILENAME_COMPONENT(CROSS_SUFFIX ${CMAKE_C_COMPILER} DIRECTORY)
SET(CROSS_SUFFIX ${CROSS_SUFFIX}/)
IF(ANDROID)
# arm_soft_fp_abi branch of OpenBLAS to support softfp
# https://github.com/xianyi/OpenBLAS/tree/arm_soft_fp_abi
Copy link
Contributor

Choose a reason for hiding this comment

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

目前看起来好像没有必要用arm_soft_fp_abi分支,这个分支的所有commit已经都合入develop了。

This branch is 242 commits behind develop.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

这个分支的修改内容似乎并没有合入master或者develop分支,从两个分支的Makefile.arm看的出来:

ifeq ($(CORE), ARMV7)
ifeq ($(OSNAME), Android)
ifeq ($(ARM_SOFTFP_ABI), 1)
CCOMMON_OPT += -mfpu=neon -march=armv7-a
FCOMMON_OPT += -mfpu=neon -march=armv7-a
else
CCOMMON_OPT += -mfpu=neon -march=armv7-a -Wl,--no-warn-mismatch
FCOMMON_OPT += -mfpu=neon -march=armv7-a -Wl,--no-warn-mismatch
endif
else
CCOMMON_OPT += -mfpu=vfpv3 -march=armv7-a
FCOMMON_OPT += -mfpu=vfpv3 -march=armv7-a
endif
endif

Copy link
Contributor

Choose a reason for hiding this comment

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

arm_soft_fp_abi分支只显示This branch is 242 commits behind develop.说明它已经merge到develop了,否则应该会显示commits ahead of develop这类的。至于,develop的Makefile.arm与arm_soft_fp_abi的不一样可能是develop后来又修改了。
ps,我用develop的编译跑了一下,好像没发现比arm_soft_fp_abi慢。

Copy link
Contributor Author

Choose a reason for hiding this comment

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

我验证一下,下一个PR修复吧。

@Xreki Xreki merged commit a9202e8 into PaddlePaddle:develop Sep 20, 2017
@Xreki Xreki added the iOS label Sep 30, 2017
@Xreki Xreki deleted the build_ios branch November 14, 2018 02:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants