介绍

NEON,即“ARM Advanced SIMD”,是ARM从ARMv7开始提供的高级单指令多数据(SIMD)扩展。它是一种64/128位混合SIMD体系结构。NEON在网上的资料比较少,对于新手来说不太友好。一番折腾之后,终于在GIT上找到一个封装好的NEON库,Ne10,内部用汇编实现了若干基本运算。

Git地址

安装指南

预备

先安装arm-linux交叉编译器:

sudo apt-get install gcc-arm-linux-gnueabihf

sudo apt-get install g++-arm-linux-gnueabihf

否则,会出现编译错误

cc: error: unrecognized command line option ‘-mthumb-interwork’
cc: error: unrecognized command line option ‘-mthumb’
cc: error: unrecognized command line option ‘-mfpu=vfp3’

作为小白的我不知所以,抓狂很久,直到看到根目录下的GNUlinux_config.cmake才恍然大误大悟。

关于abi的介绍,可参考这篇博客

交叉编译器

编译

Native compilation on *nix platforms

编译命令

cd $NE10_PATH                       # Change directory to the location of the Ne10 source
mkdir build && cd build # Create the `build` directory and navigate into it
export NE10_LINUX_TARGET_ARCH=armv7 # Set the target architecture (can also be "aarch64")
cmake -DGNULINUX_PLATFORM=ON .. # Run CMake to generate the build files
make # Build the project

这步总是有问题,找到的编译器是gccg++,而不是gcc-arm-linux-gnueabihfg++-arm-linux-gnueabihf

-- Found assembler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works

...Cross compilation on *nix platforms...

编译命令

cd $NE10_PATH
mkdir build && cd build
export NE10_LINUX_TARGET_ARCH=armv7 # Can also be "aarch64"
cmake -DCMAKE_TOOLCHAIN_FILE=../GNUlinux_config.cmake ..
make

这步是ok的。找到了合适的编译器

-- Found assembler: /usr/bin/arm-linux-gnueabihf-as
-- Check for working C compiler: /usr/bin/arm-linux-gnueabihf-gcc
-- Check for working C compiler: /usr/bin/arm-linux-gnueabihf-gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/arm-linux-gnueabihf-g++
-- Check for working CXX compiler: /usr/bin/arm-linux-gnueabihf-g++ -- works

成功编译。

Linking C static library libNE10.a
[ 94%] Built target NE10
Scanning dependencies of target NE10_test_static
[ 95%] Building C object samples/CMakeFiles/NE10_test_static.dir/NE10_sample_intro.c.o
[ 96%] Building C object samples/CMakeFiles/NE10_test_static.dir/NE10_sample_matrix_multiply.c.o
[ 97%] Building C object samples/CMakeFiles/NE10_test_static.dir/NE10_sample_complex_fft.c.o
[ 98%] Building C object samples/CMakeFiles/NE10_test_static.dir/NE10_sample_fir.c.o
[100%] Building C object samples/CMakeFiles/NE10_test_static.dir/NE10_samples.c.o
Linking CXX executable NE10_test_static
[100%] Built target NE10_test_static

作者还提到

Additionally, for systems without hardware floating point support, the appropriate compilation options should be added to the CMAKE_C_FLAGS and CMAKE_ASM_FLAGS variables in the root CMakeLists.txt file. For example, -mfloat-abi=softfp -mfpu=neon.

运行/build/samples/NE10_test_static出现错误

bash: ./NE10_test_static: cannot execute binary file: Exec format error

应该是32位程序不能运行在64位系统上。

64位编译

编译64位程序时(armv7改为aarch64)出现问题

In file included from /home/XXX/Ne10-master/modules/imgproc/NE10_resize.neon.c:28:0:
/home/XXX/Ne10-master/modules/imgproc/NE10_resize.neon.c: In function ‘ne10_img_vresize_linear_neon’:
/home/XXX/Ne10-master/modules/imgproc/NE10_resize.neon.c:174:19: error: incompatible types when initializing type ‘int32x4_t’ using type ‘int32x2_t’
qT_0123 = vmlaq_lane_s32 (qT_0123, qS1_0123, dBeta, 1);

还没有找到问题所在。

...for Android

编译命令

cd $NE10_PATH
mkdir build && cd build
export ANDROID_NDK=/absolute/path/of/android-ndk # Change to your local ndk path
export NE10_ANDROID_TARGET_ARCH=armv7 # Can also be "aarch64"
cmake -DCMAKE_TOOLCHAIN_FILE=../android/android_config.cmake ..
make

找到编译器

-- Found assembler: /home/XXX/android-ndk-r13b//toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-as
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - failed
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - failed
-- Target architecture: armv7
-- Building type: RELEASE
-- Loaded toolchain:
/home/XXX/android-ndk-r13b/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc
/home/XXX/android-ndk-r13b/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-g++
/home/XXX/android-ndk-r13b/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-as

成功编译

Linking C static library libNE10.a
Scanning dependencies of target NE10_test_static
Linking CXX executable NE10_test_static
Scanning dependencies of target NE10_test_demo
Linking CXX shared library libNE10_test_demo.so
[100%] Built target NE10_test_demo

Android运行结果

将运算重复运行十万次。具体还需要深入理解后再分析。

# Introduction
ne10_addc_float: 0.610000
ne10_addc_float_c: 1.863000
ne10_addc_float_neon: 0.652000 # Matrix Multiply
ne10_mulmat_3x3f: 4.211000
ne10_mulmat_3x3f_c: 7.352000
ne10_mulmat_3x3f_neon: 4.246000

Ne10编译安装的更多相关文章

  1. Centos6.5下编译安装mysql 5.6

    一:卸载旧版本 使用下面的命令检查是否安装有MySQL Server rpm -qa | grep mysql 有的话通过下面的命令来卸载掉 rpm -e mysql //普通删除模式 rpm -e ...

  2. CENTOS 6.5 平台离线编译安装 PHP5.6.6

    一.下载php源码包 http://cn2.php.net/get/php-5.6.6.tar.gz/from/this/mirror 二.编译 编译之前可能会缺少一些必要的依赖包,加载一个本地yum ...

  3. Linux下编译安装Vim8.0

    什么是Vim? Vim 是经典的 UNIX 编辑器 Vi 的深度改良版本.它增加了许多功能,包括:多级撤销.格式高亮.命令行历史.在线帮助.拼写检查.文件名补完.块操作.脚本支持,等等.除了字符界面版 ...

  4. OpenSUSE下编译安装OpenFoam

    在不是Ubuntu系统下安装OpenFoam,需要采用编译安装的方式.以下以OpenSuSE为例进行编译安装. 1 软件包准备 需要下载两个程序包: OpenFOAM-4.x-version-4.1. ...

  5. 不要着急改代码,先想想--centos 6.8下编译安装tmux

    诸位读者新年好,2017开年第一篇博客,请允许我先问候一下看到这篇博客的诸位.写博客是我2017年定下的目标之一,希望我会坚持下去. 最近打算尝试一下tmux这个神器,于是有了这一篇关于思维方式的Bl ...

  6. protobuf的编译安装

    github地址:https://github.com/google/protobuf支持多种语言,有多个语言的版本,本文采用的是在centos7下编译源码进行安装. github上有详细的安装说明: ...

  7. 编译安装mysql

    参考:http://www.centoscn.com/CentosServer/www/2015/0422/5245.html 安装mysql5.6.17 1.按照标准需要给mysql创建所属用户和用 ...

  8. 编译安装zabbix3.2

    1.1 环境准备 系统环境准备:redhat 6.6 64位mysql-5.6.34php-5.6.28zabbix-3.2.1配置前先关闭iptables和SELINUX,避免安装过程中报错. # ...

  9. centos系统编译安装nginx+php环境另加独立mysql教程

    以前看过的安装nginx+php环境都带了mysql数据库了,这个是因为很多站长都是nginx+php+mysql都在同一台服务器了,那么今天我们是单独处理了,一个是nginx+php环境,然后mys ...

随机推荐

  1. 【app】Appium日志文件分析

    Appium在和客户端及手机端进行通讯的时候会输出很多日志,可以通过点击主面板的Get Raw Logs得到其原始日志: 现在我们另存到其他路径,并且以notepad工具打开进行查看 Appium日志 ...

  2. 怎么让Word形状里的文字上下左右居中

    怎么让Word形状里的文字上下左右居中? 第一:左右居中,用段落居中方法: 第二:上下居中,选定图形,单击鼠标右键并选择“设置形状格式”,在选项卡的“文本框”中,选择中部对齐 效果图:

  3. vue-15-vuex-store的用法

    vue-16-vuex 1, 介绍 对 vue 进行状态管理的, 集中存储所有组件的所有状态, 解决多个组件共享数据的问题. 即, 所有组件可以拿到同样的状态, 组件间共享数据 2, 在之前进行数据交 ...

  4. jvm详情——3、JVM基本垃圾回收算法回收策略

    JVM基本垃圾回收算法回收策略 引用计数(Reference Counting):比较古老的回收算法.原理是此对象有一个引用,即增加一个计数,删除一个引用则减少一个计数.垃圾回收时,只用收集计数为0的 ...

  5. CNN 模型压缩与加速算法综述

    本文由云+社区发表 导语:卷积神经网络日益增长的深度和尺寸为深度学习在移动端的部署带来了巨大的挑战,CNN模型压缩与加速成为了学术界和工业界都重点关注的研究领域之一. 前言 自从AlexNet一举夺得 ...

  6. 分析windows .net程序dump文件的两种方式

    1.WinDbg 按照自己系统版本下载对应windbg(https://debugging.wellisolutions.de/windbg-versions/),win10版本自动下载文件符号,体验 ...

  7. Deep learning with Python 学习笔记(11)

    总结 机器学习(machine learning)是人工智能的一个特殊子领域,其目标是仅靠观察训练数据来自动开发程序[即模型(model)].将数据转换为程序的这个过程叫作学习(learning) 深 ...

  8. 使用Asp.Net Core MVC 开发项目实践[第四篇:基于EF Core的扩展2]

    上篇我们说到了基于EFCore的基础扩展,这篇我们讲解下基于实体结合拉姆达表达式的自定义更新以及删除数据. 先说下原理:其实通过实体以及拉姆达表达式生成SQL语句去执行 第一种更新扩展: 自定义更新字 ...

  9. 加密的m3u8、ts文件合并

    加密后的ts文件不能直接合并或播放,需要使用key对每个ts文件进行解密. 分为两种情况: (1).如果ts文件已经全部下载好,则可以直接在本地通过ffmpeg快速解密合并. (2).如果ts文件没有 ...

  10. python模块之shutil

    shutil是一个用于简化文件操作的模块. 复制文件(传入源文件对象和目标文件对象) import shutil f1 = open(r'/Users/jingxing/PycharmProjects ...