From 0f296ee9bf64ec572246cf5e6ea2e5a5d21289df Mon Sep 17 00:00:00 2001 From: nihuini Date: Fri, 23 Jul 2021 14:46:42 +0800 Subject: [PATCH] update build tutorial for d1 and ls2k --- README.md | 4 ++- docs/how-to-build/how-to-build.md | 53 +++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 584a1f2f9..f095d768c 100644 --- a/README.md +++ b/README.md @@ -63,7 +63,7 @@ ncnn 是一个为手机端极致优化的高性能神经网络前向计算框架 ### HowTo -**[how to build ncnn library](https://github.com/Tencent/ncnn/wiki/how-to-build) on Linux / Windows / MacOS / Raspberry Pi3 / Android / NVIDIA Jetson / iOS / WebAssembly** +**[how to build ncnn library](https://github.com/Tencent/ncnn/wiki/how-to-build) on Linux / Windows / MacOS / Raspberry Pi3 / Android / NVIDIA Jetson / iOS / WebAssembly / AllWinner D1 / Loongson 2K1000** * [Build for Linux / NVIDIA Jetson / Raspberry Pi3](https://github.com/Tencent/ncnn/wiki/how-to-build#build-for-linux) * [Build for Windows x64 using VS2017](https://github.com/Tencent/ncnn/wiki/how-to-build#build-for-windows-x64-using-visual-studio-community-2017) @@ -73,6 +73,8 @@ ncnn 是一个为手机端极致优化的高性能神经网络前向计算框架 * [Build for Android](https://github.com/Tencent/ncnn/wiki/how-to-build#build-for-android) * [Build for iOS on MacOS with xcode](https://github.com/Tencent/ncnn/wiki/how-to-build#build-for-ios-on-macos-with-xcode) * [Build for WebAssembly](https://github.com/Tencent/ncnn/wiki/how-to-build#build-for-webassembly) +* [Build for AllWinner D1](https://github.com/Tencent/ncnn/wiki/how-to-build#build-for-allwinner-d1) +* [Build for Loongson 2K1000](https://github.com/Tencent/ncnn/wiki/how-to-build#build-for-loongson-2k1000) **[download prebuild binary package for android and ios](https://github.com/Tencent/ncnn/releases)** diff --git a/docs/how-to-build/how-to-build.md b/docs/how-to-build/how-to-build.md index e79430afe..a5540c4c9 100644 --- a/docs/how-to-build/how-to-build.md +++ b/docs/how-to-build/how-to-build.md @@ -14,6 +14,8 @@ $ git submodule update --init * [Build for Android](#build-for-android) * [Build for iOS on MacOS with xcode](#build-for-ios-on-macos-with-xcode) * [Build for WebAssembly](#build-for-webassembly) +* [Build for AllWinner D1](#build-for-allwinner-d1) +* [Build for Loongson 2K1000](#build-for-loongson-2k1000) *** @@ -555,3 +557,54 @@ cmake --build . --target install ``` Pick `build-XYZ/install` folder for further usage. + +*** + +### Build for AllWinner D1 + +Download c906 toolchain package from https://occ.t-head.cn/community/download?id=3913221581316624384 + +```shell +tar -xf riscv64-linux-x86_64-20210512.tar.gz +export RISCV_ROOT_PATH=/home/nihui/osd/riscv64-linux-x86_64-20210512 +``` + +Build ncnn with riscv-v vector and simpleocv enabled: +```shell +mkdir -p build-c906 +cd build-c906 +cmake -DCMAKE_TOOLCHAIN_FILE=../toolchains/c906.toolchain.cmake \ + -DCMAKE_BUILD_TYPE=relwithdebinfo -DNCNN_OPENMP=OFF -DNCNN_THREADS=OFF -DNCNN_RUNTIME_CPU=OFF -DNCNN_RVV=ON \ + -DNCNN_SIMPLEOCV=ON -DNCNN_BUILD_EXAMPLES=ON .. +cmake --build . -j 4 +cmake --build . --target install +``` + +Pick `build-c906/install` folder for further usage. + +You can upload binary inside `build-c906/examples` folder and run on D1 board for testing. + +*** + +### Build for Loongson 2K1000 + +For gcc version < 8.5, you need to fix msa.h header for workaround msa fmadd bug. + +Open ```/usr/lib/gcc/mips64el-linux-gnuabi64/8/include/msa.h```, find ```__msa_fmadd_w``` and apply changes as the following +```c +// #define __msa_fmadd_w __builtin_msa_fmadd_w +#define __msa_fmadd_w(a, b, c) __builtin_msa_fmadd_w(c, b, a) +``` + +Build ncnn with mips msa and simpleocv enabled: +```shell +mkdir -p build +cd build +cmake -DNCNN_DISABLE_RTTI=ON -DNCNN_DISABLE_EXCEPTION=ON -DNCNN_RUNTIME_CPU=OFF -DNCNN_MSA=ON -DNCNN_MMI=ON -DNCNN_SIMPLEOCV=ON .. +cmake --build . -j 2 +cmake --build . --target install +``` + +Pick `build/install` folder for further usage. + +You can run binary inside `build/examples` folder for testing.