当前位置:网站首页>NEON优化:性能优化常见问题QA
NEON优化:性能优化常见问题QA
2022-07-06 17:22:00 【来知晓】
NEON优化:性能优化常见问题QA
NEON优化系列文章:
本文将日常遇到的NEON优化问题总结记录于此。
CPU主频Mhz和开销MCPS的关系是啥?
- 主频Mhz并不直接代表运算速度MCPS
- 主频:1.8GHz=1800MHz,也即理论最大1800MCPS,主频是开销计算的理论天花板
功耗与开销的关系?
- 通常开销指的时间复杂度开销,多少M开销的变化,对应多少mA功耗的变化,由于涉及到硬件优化及具体器件性能,无法理论计算出来。
软仿的MIPS数和硬仿的MIPS数差异以及MCPS?
- CPU情况不一样,软仿最多CPI为1,也即一般MCPS会比MIPS大。但手机的芯片比较牛,能做到CPI<1.
armv7/armv8a,arm64-v7/arm64-v8a的区别?Cortex-A9/A8/A53/A55的区别?
首先,armv7/v8是Architecture架构,cortex是具体的processor处理器,架构几年甚至十年一更新,处理器年年都翻新。
其次,对armv7-A/armv8-A/armv8-M分类划定
总体
- v7/v8表示第几代
- -A/-M/-R表示Application/Microcontroller/Real-time,适配手机电脑、嵌入式设备等不同平台
- v8-a,2011年发布,armv8-a后的a跟cortex-a是对应一致的
armv8-a架构
- 有32也有64位,32位processor:cortex-a32;64位processor:cortex-a34/cortex-a53;
armv7-a架构
- 只有32位,对应processor:cortex-a5/a7/…/a17
更多细节见:wiki
什么是MCPS?
- MCPS,每秒百万次周期,衡量时间开销的指标
- MIPS,每秒百万条指令数,一般一条指令对应一个或多个计算周期,故通常MIPS比MCPS数据小
向量线和N元素结构是什么意思?
- 向量线数,相当于1个NEON寄存器里有多少个对应基础数据类型值(int16/uint32/float32等)。
- n元素结构,相当于n个NEON寄存器。
NEON指令中有的加q,有的不加q,有何区别?
- 操作符后的q,如vmulq, 表示128位满位宽寄存器运算
- v后的q,如vqrdmulh,q表示饱和运算,溢位后,为自动限制在数据类型的最大范围内。
- rdmul表示向量与标量进行加倍乘运算的具体操作意义。
- hq表示高位饱和,lq表示低位饱和。
NEON中的正常指令、宽指令、窄指令、饱和指令、长指令分别指什么?
- 正常指令:生成大小相同且类型通常与操作数向量相同到结果向量
- 长指令:对双字向量操作数执行运算,生产四字向量到结果。所生成的元素一般是操作数元素宽度到两倍,并属于同一类型。L标记,如VMOVL。
- 宽指令:一个双字向量操作数和一个四字向量操作数执行运算,生成四字向量结果。W标记,如VADDW。
- 窄指令:四字向量操作数执行运算,并生成双字向量结果,所生成的元素一般是操作数元素宽度的一半。N标记,如VMOVN。
- 饱和指令:当超过数据类型指定到范围则自动限制在该范围内。Q标记,如VQSHRUN
NEON变量的命名规则是什么?
没有统一的规则,如果想要规范些,可采用以下命名方式。
变量类型 变量名:
vTNnVar解释
- v,表示向量运算
- T,表示变量的类型,分别用s表示有符号整型,u表示无符号整型,f表示浮点
- N,表示变量元素所占位宽,如s32,u16,f32中的数字即N,表示元素占位
- n,表示向量线元素结构,如x4,x4x2
- Var,表示变量自定义的名字
举例
定义:int16x4x2_t vs16x4x2Tmp;
解释:元素为int16,存4x2的二维向量(注意2是行,4是列,从后往前套壳),即val[0]/val[1]分别存4个向量线,变量名为tmp
详细:
vs16x4x2Tmp变量名的v表示vector,s16表示16位有符号数,x4表示4个向量线,x2表示2个元素,Tmp为实际变量名。
两个元素分别是vs16x4x2Tmp.val[0]和vs16x4x2Tmp.val[1],其类型就是int16x4,4个向量线分别存着四个数据,且是从连续内存交叉读取写入到vs16x4x2Tmp中的。
比如:
short tmp[8] = { 0 1 2 3 4 5 6 7}; vs16x4x2Tmp = vld2q_s16(tmp); // 得到的结果是 vs16x4x2Tmp.val[0]: 0 2 4 6 vs16x4x2Tmp.val[1]: 1 3 5 7
定义:float32x2_t vf32x2Tmp;
解释:元素为float32,存两个元素的一维向量,变量名为tmp
NEON变量中的.val[0]/.val[1]表示什么?
- 代表数据类型对应的向量线结构,分别索引寄存器所对应的数值。
查看反汇编代码时,如何判断代码是否存在互锁?
- 在rvds中,查看反汇编代码,选中一段原始C代码,会自动对应相应的反汇编代码,如果CPI旁边那列存在
黑点,则表示代码间存在互锁。
边栏推荐
- 重上吹麻滩——段芝堂创始人翟立冬游记
- What kind of experience is it to realize real-time collaboration in jupyter
- 新手如何入门学习PostgreSQL?
- New feature of Oracle 19C: automatic DML redirection of ADG, enhanced read-write separation -- ADG_ REDIRECT_ DML
- 「精致店主理人」青年创业孵化营·首期顺德场圆满结束!
- Tensorflow GPU installation
- Part IV: STM32 interrupt control programming
- BFS realizes breadth first traversal of adjacency matrix (with examples)
- 【批處理DOS-CMD命令-匯總和小結】-字符串搜索、查找、篩選命令(find、findstr),Find和findstr的區別和辨析
- Leetcode (547) - number of provinces
猜你喜欢

Trace tool for MySQL further implementation plan

Dell笔记本周期性闪屏故障

Tensorflow GPU installation

深度学习之环境配置 jupyter notebook

Come on, don't spread it out. Fashion cloud secretly takes you to collect "cloud" wool, and then secretly builds a personal website to be the king of scrolls, hehe
![[Batch dos - cmd Command - Summary and Summary] - String search, find, Filter Commands (FIND, findstr), differentiation and Analysis of Find and findstr](/img/4a/0dcc28f76ce99982f930c21d0d76c3.png)
[Batch dos - cmd Command - Summary and Summary] - String search, find, Filter Commands (FIND, findstr), differentiation and Analysis of Find and findstr

Part IV: STM32 interrupt control programming

Building a dream in the digital era, the Xi'an station of the city chain science and Technology Strategy Summit ended smoothly

【案例分享】网络环路检测基本功能配置

Chapter II proxy and cookies of urllib Library
随机推荐
The printf function is realized through the serial port, and the serial port data reception is realized by interrupt
ActiveReportsJS 3.1中文版|||ActiveReportsJS 3.1英文版
「笔记」折半搜索(Meet in the Middle)
《安富莱嵌入式周报》第272期:2022.06.27--2022.07.03
[100 cases of JVM tuning practice] 04 - Method area tuning practice (Part 1)
A brief history of deep learning (II)
Link sharing of STM32 development materials
pyflink的安装和测试
深度学习简史(二)
Do you understand this patch of the interface control devaxpress WinForms skin editor?
[Batch dos - cmd Command - Summary and Summary] - String search, find, Filter Commands (FIND, findstr), differentiation and Analysis of Find and findstr
Learning notes 5: ram and ROM
Chenglian premium products has completed the first step to enter the international capital market by taking shares in halber international
What kind of experience is it to realize real-time collaboration in jupyter
Building a dream in the digital era, the Xi'an station of the city chain science and Technology Strategy Summit ended smoothly
Zabbix 5.0:通过LLD方式自动化监控阿里云RDS
[batch dos-cmd command - summary and summary] - jump, cycle, condition commands (goto, errorlevel, if, for [read, segment, extract string]), CMD command error summary, CMD error
Configuring OSPF basic functions for Huawei devices
How to get started and improve test development?
Provincial and urban level three coordinate boundary data CSV to JSON