查看原文
其他

高通的Hexagon DSP

2017-03-31 唐杉 StarryHeavensAbove

前面分别讨论了一下CEVA,Synopsys,Cadence的DSP,原本没打算聊高通的Hexagon DSP。一方面高通这个DSP是内部使用,并不算是个公开的IP;另外公开资料也比较少,不太好讨论。不过Hexagon DSP虽是高通自用,但按照高通芯片的出货量,这个DSP的市场占有率是很高的,相当重要。同时,这个DSP经过的几代演进,它的设计和trade-off有很多值得思考的地方。正好最近看到一个关于Hexagon DSP的比较好的公开信息:BDTi的关于它的benchmark说明[1-3]。下面就基于这篇文章进行一下分析。另外,在高通的开发者网站上有Hexagon DSP SDK和相关文档(包括指令集),大家可以自己参考。

1

简单回顾

Hexagon的编号是QDSP6,表示高通的第6代DSP核,其v1版本大约是2006年左右开始用的。目前已经是这个系列的第六个版本,可以看出其发展的历史之久远。v6版本又会根据feature的不同细分为更多的子版本,[1]中主要讨论的是QDSP680。下表是几代QDSP6的一些关键参数(来自wikipedia)。

另外,一些版本间重要变化如下:

  • v4版本:开始向用户和开发者提供的编程接口和相应的SDK;

  • v5版本:支持Byte-vector操作(“a particularly appealing enhancement in embedded vision and imaging applications, which generally require less data precision than audio (for example) and benefit from more operations per second”)和浮点运算(“which helps with high dynamic range audio and location (GPS, etc.) processing applications, among others, and which also simplifies the initial porting of floating point-based software that originates with PC-developed code”);

  • v6版本:增加向量指令HVX(Hexagon Vector Instruction),满足图像和视频处理的要求。

从以上这些版本间的演进可以看出,QDSP6的设计目标是支持多种应用的。如下图可以看出,在Snapdragon 820中,首先包括一个“Compute DSP”,作为协处理器支持Audio,Voice,Image/Video和Computer Vision这些方面的功能;第二个Hexagon 680位于“low power island”,作为sensor处理子系统,实现sensor hub的功能(这个核肯定没有HVX)。第三个DSP是在通信基带(modem)部分,不过这个DSP还是基于更早的v5版本,应该是为了赶时间。不知道现在是不是已经替换成v6的架构了。

2

多线程(Multi-threading)

QDSP6和我们之前讨论的DSP核最大的区别是它支持硬件多线程。所以QDSP6除了支持指令并行(VLIW 超长指令字)和数据并行(SIMD,单指令多数据)之外,还支持Thread并行(单核支持任务并行)。也就是说可以在一个处理器核上同时运行不同的线程,比如一个是语音编码,一个是图像增强,等等。每个QDSP6的thread都是硬件支持的,有独立的寄存器堆,按照“round-robin”的模式运行。在[2]中给出了QDSP6 v4核的3个thread执行序列(最好情况):

First clock (cycle): First instruction for first thread

Second clock: First instruction for second thread

Third clock: First instruction for third thread

Fourth clock: Second instruction for first thread

Fifth clock: Second instruction for second thread

Sixth clock: Second instruction for third thread

Etc.

其实,要实现硬件多线程需要不少额外的开销,在嵌入式DSP中并不多见。我们之前介绍CEVA和Tensilica都没有采用QDSP6这种比较通用的架构,而是把DSP核分成不同的系列产品,分别针对语音,图像和通信基带等几大应用。这样的优势是更有针对性,效率更高。另一方面,更丰富和有针对性的产品线对于DSP IP厂商也有好处。而高通的DSP是内部使用,更重视DSP核的灵活性,希望一个DSP核能够满足多种要求,似乎也是一个合理的考虑(个人看法)。


从第一节的表中可以看出,随着版本的演进,QDSP6并行线程数并不是逐渐增加的,v4/v5减少了线程的数量,而到v6又有所增加。高通解释这种变化是源于对以下因素进行trade-off的结果。

  • Code's ability (or lack thereof) to efficiently use all available core threads

这一条反映了DSP code(Application)的需求和特征

  • Core design complexity

  • Core die size

  • Maximum core clock speed, and

  • Static and dynamic core power consumption

另外,从v5开始,多线程的机制从比较简单的“round robin”方式改进为比较先进的动态多线程 DMT (dynamic multithreading)。在这种机制下,如果一个线程由于cache miss,中断等原因,没有准备好运行,就会被自动跳过。这样就避免了过多的等待,可以实现更高的效率。一些实现细节如下:

“Since Hexagon uses a VLIW (very large instruction word) approach, each thread is able to execute up to four simultaneous instruction "slots" within in a given clock cycle; up to two of the four "slots" are also SIMD (single instruction, multiple data)-capable for even greater potential computation throughput. At a base level, each thread is scalar in nature, supporting both fixed- and (thanks to the previously mentioned v5 enhancements) floating-point arithmetic operations. Each thread "engine" contains a bank of 32-bit registers, and the scalar units all share common and variable-sized L1 data and instruction caches, along with a unified L2 cache.”

3

向量指令HVX (Hexagon Vector Instruction)

Hexagon 680中最重要的新功能是其新增的HVX(Hexagon Vector Instruction)。HVX只支持定点运算,支持8,16和32bit的SIMD操作,每个HVX单元可以支持最大1024bit宽的向量操作。这个显然是应对图像和视频处理的需求。一些实现的细节包括:

“Each HVX unit also includes a bank of 32 1024-bit registers that can be split into two banks of 32 512-bit registers. Thus with two HVX units, the Hexagon v6 can operate on 1024-bit vectors in up to two simultaneous hardware threads, or operate on 512-bit vectors in up to four simultaneous hardware threads. As with the scalar units, each HVX unit is a four-vector-slot VLIW architecture, allowing for a maximum of four vector operations per VLIW instruction packet."

4

系统实例

下图是Snapdragon 820中,DSP通过cache和系统中的其它模块通信的示意。

下图是芯片布局,大家可以感受一下。

最后再提醒一下,在高通的开发者网站上有Hexagon DSP的指令集文档。要了解这个处理器的细节,最好花点时间看看。

T.S.

参考:均来自www.bdti.com

1. “Qualcomm's QDSP6 v6: Imaging and Vision Enhancements Via Vector Extensions”

2. “QDSP6 V4: BDTI Benchmark Results and Implementation Details Of Qualcomm's DSP Core”

3. “Qualcomm's QDSP6 v5: Benchmarking Results Confirm That Floating-Point Support Has Arrived”

长按左侧二维码关注

您可能也对以下帖子感兴趣

文章有问题?点此查看未经处理的缓存