当前位置:   article > 正文

Hexagon DSP系列记录(一)_adsp calculator

adsp calculator

Hexagon DSP系列记录

参考:80-VB419-108_Hexagon_DSP_User_Guide.pdf

SM8150 chipset

The processing units include a Kryo CPU, an Adreno 640, and four separate DSPs, each devoted to a specific application space: sensor (sDSP), modem (mDSP), audio (aDSP), and compute (cDSP)
Compared to the host CPU, the DSPs typically run at lower clock speeds but provide more parallelism opportunities at the instruction level. This makes the DSPs better alternatives to the CPU for power consumption. As a result, it is preferable to offload as many large compute-intensive tasks as possible onto the DSPs to reduce the overall power consumption of the devices.
在这里插入图片描述

Using the DSP offers several benefits:
  • For fixed-point computation, the Hexagon DSP is generally much lower in power consumption, and free from thermal concerns, compared to the CPU.
  • In many cases that vectorize well on HVX, the DSP performs the same computations in less time (while at a lower clock) than multiple CPU cores.
  • Moving large blocks of computational software to the DSP keeps the CPU unburdened for other tasks that might work well only on the CPU.

Communication between the CPU and DSP is done through shared memory with interrupts. Because the CPU and DSP do not share a cache, maintenance operations are required upon all buffers transacted between them. These can take a minimum of a few hundred microseconds. Depending on system clock settings and CPU sleep modes enabled, the overhead for each invocation to the DSP could extend to several milliseconds (this is explained in greater details in Section 3.6). Hence it is preferable to offload large tasks onto the DSP instead of invoking it for small trivial tasks.
CPU调用DSP开销数量级:几百微秒~几个毫秒。

QAIC是啥?

IDL compiler,通过QAIC将foo.idl生成foo.h/foo_sub.c/foo_skel.c,foo.idl为开发者定义的接口文件。

FastRPC是啥?

FastRPC机制(fast remote procedure calls, docs/Technologies_FastRPC.html)将计算任务从CPU发送到DSP。数据传输涉及ION memory。
FastRPC主要接口:rpcmem_init/rpcmem_alloc/rpcmem_free/rpcmem_deinit
Multi-domain指:cDSP, aDSP, mDSP, or SLPI(Sensor Low Power Island, sDSP).
引入multi-domain framework,用来指定或拆分任务运行在具体的某个或多个(并行运行)DSP上。
FastRPC Docs: Hexagon_SDK/3.5.2/docs/APIs_FastRPC.html
代码示例可参考:Hexagon_SDK\3.5.2\examples\common\calculator_multi_domains

Run the main function on Hexagon DSP,可参考C:\Qualcomm\Hexagon_SDK\3.5.2\examples\common\run_main_on_hexagonSrc

Manage the DSP performance and power,主要接口HAP_power_set/get/destroy
可参考file:///C:/Qualcomm/Hexagon_SDK/3.5.2/docs/DSP%20Power%20%26%20Perf.html

QuRT是啥?

The QuRT™ operating system is a real-time operating system (RTOS) for the Qualcomm Hexagon™ processor.
QuRT supports real-time priority-based preemptive multithreading.
It supports multithreading, thread communication and synchronization, interrupt handling, and memory management.
QuRT offers the following features:
• Low overhead (both in memory and processing)
• Simplicity of implementation
• Ease of porting standalone user programs to QuRT environment
• Ease of modification to accommodate specific target requirements

Make.d

类似make的跨平台编译系统,用来生成库与可执行文件等,参考
Hexagon_SDK/3.5.2/build/make.d/UsersGuide.html
Hexagon_SDK/3.5.2/docs/Environments_Build%20System.html

编译与运行calculator实例

手机型号sm8150,步骤如下:

$cd C:\Qualcomm\Hexagon_SDK\3.5.2\examples\common\calculator
//----Generate testsig start----该部分操作每台手机只需执行一次
$adb devices
List of devices attached
970828c5        device
//使用上一步的信息970828c5,生成签名文件,期间需要按y同意
$python ../../../tools/elfsigner/elfsigner.py -t 0x970828c5 -o ../../../tools/elfsigner/testsigs
$adb shell mkdir /vendor/lib/rfsa/dsp/testsig
$adb push ../../../tools/elfsigner/testsigs/testsig-0x970828c5.so /vendor/lib/rfsa/dsp/testsig
//----Generate testsig end----
//编译Android平台Debug版本的aarch64位库,tree指依赖库一起编译,不加tree,编译或运行时可能出错
$make V=android_Debug_aarch64 tree
$make V=hexagon_Debug_dynamic_toolv83_v66 tree
// 编译的hexagon库保存在hexagon_Debug_dynamic_toolv83_v66/ship
$adb shell mkdir /vendor/lib/rfsa/dsp/sdk
$adb push .\hexagon_Debug_dynamic_toolv83_v66\ship\libcalculator_skel.so /vendor/lib/rfsa/dsp/sdk
// 编译的可执行文件保存在android_Debug_aarch64 /ship
$adb push .\android_Debug_aarch64\ship\calculator /vendor/bin
$adb shell chomod +x /vendor/bin/calculator 
$adb shell export ADSP_LIBRARY_PATH="/vendor/lib/rfsa/dsp/sdk\;/vendor/lib/rfsa/dsp/testsig;" /vendor/bin/calculator 0 1000
// 成功输出如下,
---Starting calculator test

---Allocate 4000 bytes from ION heap
---Creating sequence of numbers from 0 to 999

---Compute sum on the DSP
---Sum = 499500
---Success
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/很楠不爱3/article/detail/383555
推荐阅读
相关标签
  

闽ICP备14008679号