toradex的个人空间 https://blog.eetop.cn/1539194 [收藏] [复制] [分享] [RSS]

空间首页 动态 记录 日志 相册 主题 分享 留言板 个人资料

日志

NXP iMX8QM多核应用开发性能测试

已有 1760 次阅读| 2019-11-12 12:28 |系统分类:嵌入式| ARM, Linux, iMX8, iMX8QM, NXP

By Toradex 胡珊逢

1). 简介

NXP发布的i.MX8处理器具有多种规格,最高配置的i.MX8QM具有双核Cortex-A72和四核Cortex-A53。这种大小核组合的处理器,为用户带来更大的性能灵活性,利用高性能的大核快速完成运算,低性能小核则提供优化的功耗表现。下面我们将以Apalis iMX8QM核心板为例,介绍如何利用这种特性,并观察功耗差异。

 

 

2). 单核性能测试

a). Cortex-A72最高时钟1.6GHzCortex-A53最高为1.2GHzCortex-A72Cortex-A53在架构也上存在很大的差异,虽然同属于ARMv8.0-A,但是在流水线深度、乱序执行、缓存等特性上却有所不同,从而带来处理性能的差异。理论上Cortex-A72性能会高于Cortex-A53

 

b). 为了测试在Cortex-A72Cortex-A53上的单核性能表现我们将使用encode-flac测试压缩一个WAV音频文件所消耗的时间。该工具是单线程运行,适合做单核计算测试。

 

./ 首先下载SDK,编译encode-flac

-------------------------------

$ . environment-setup-aarch64-tdx-linux

$ cd encode-flac

$ ./configure --prefix=~/encode-flac-bin  --host=aarch64-tdx-linux --build=x86_64-linux

$ make

$ make install

-------------------------------

 

./ ~/encode-flac-bin 能找到到本次测试所需的flac程序。Taskset工具能够指定应用运行在哪个处理器上面。Taskset通过设置CPU掩码来选择CPU。我们可以用cpufreq-info 命令查看所有可用的CPU

-------------------------------

# cpufreq-info

cpufrequtils 008: cpufreq-info (C) Dominik Brodowski 2004-2009

Report errors and bugs to cpufreq@vger.kernel.org, please.

analyzing CPU 0:

  driver: imx8-cpufreq

  CPUs which run at the same hardware frequency: 0 1 2 3

  CPUs which need to have their frequency coordinated by software: 0 1 2 3

  maximum transition latency: 61.0 us.

  hardware limits: 600 MHz - 1.20 GHz

  available frequency steps: 600 MHz, 900 MHz, 1.10 GHz, 1.20 GHz

  available cpufreq governors: interactive, conservative, userspace, powersave, ondemand, performance, schedutil

  current policy: frequency should be within 600 MHz and 1.20 GHz.

                  The governor "performance" may decide which speed to use

                  within this range.

  current CPU frequency is 1.20 GHz (asserted by call to hardware).

  cpufreq stats: 600 MHz:59.80%, 900 MHz:0.06%, 1.10 GHz:0.04%, 1.20 GHz:40.11%  (240)

......

analyzing CPU 5:

  driver: imx8-cpufreq

  CPUs which run at the same hardware frequency: 4 5

  CPUs which need to have their frequency coordinated by software: 4 5

  maximum transition latency: 61.0 us.

  hardware limits: 600 MHz - 1.60 GHz

  available frequency steps: 600 MHz, 1.06 GHz, 1.30 GHz, 1.60 GHz

  available cpufreq governors: interactive, conservative, userspace, powersave, ondemand, performance, schedutil

  current policy: frequency should be within 600 MHz and 1.60 GHz.

                  The governor "performance" may decide which speed to use

                  within this range.

  current CPU frequency is 1.60 GHz (asserted by call to hardware).

  cpufreq stats: 600 MHz:69.45%, 1.06 GHz:0.05%, 1.30 GHz:0.01%, 1.60 GHz:30.49%  (153)

-------------------------------

 

./ 这里总共有CPU 0CPU 5,其中CPU 0CPU 3Cortex-A53CPU 4CPU 5Cortex-A72

                                              image001.png

例如0x30表示允许使用两个A72核心,0x10表示只使用一个A72,同样0x01表示只使用一个A53,而0x3F则表示使用所有的处理器核心。需要注意的是,这里是指用taskset工具指定某一个程序所使用的处理器核心,不被指定的处理器核心仍处于工作状态,只是不用其来运行该程序。因此taskset并不能启到关闭处理器核心的功能。

 

c). 我们将配合编译好的encode-flactaskset工具来观察i.MX8QM不同核心的计算机能力以及功耗的差异。

 

在空闲状态下,我们通过功率计查看Ixora底板和Apalis iMX8QM 模块以及电源适配器的功耗(本文测试仅连接以太网和调试串口和散热器风扇,不连接包括显示器在内的其他设备)为7.6W

 

./ 在一个A53内核上运行

-------------------------------

root@apalis-imx8:~# taskset 0x0f time ./flac --best ./Perfect.wav -f -o output 2>&1

flac 1.3.2

Copyright (C) 2000-2009  Josh Coalson, 2011-2016  Xiph.Org Foundation

flac comes with ABSOLUTELY NO WARRANTY.  This is free software, and you are

welcome to redistribute it under certain conditions.  Type `flac' for details.

 

Perfect.wav: WARNING: skipping unknown chunk 'LIST' (use --keep-foreign-metadata to keep)

Perfect.wav: wrote 29478930 bytes, ratio=0.634

real  0m 41.21s

user 0m 40.90s

sys    0m 0.21s

-------------------------------

 

压缩一个wav文件耗时41.2秒,功耗7.9W

image002.png

上图我们看到,单线程的encode-flac仅在一个A53处理器上满负荷运行。

 

./ 在一个A72内核上运行

-------------------------------

root@apalis-imx8:~# taskset 0x20 time ./flac --best ./Perfect.wav -f -o output 2>&1

 

flac 1.3.2

Copyright (C) 2000-2009  Josh Coalson, 2011-2016  Xiph.Org Foundation

flac comes with ABSOLUTELY NO WARRANTY.  This is free software, and you are

welcome to redistribute it under certain conditions.  Type `flac' for details.

 

Perfect.wav: WARNING: skipping unknown chunk 'LIST' (use --keep-foreign-metadata to keep)

Perfect.wav: wrote 29478930 bytes, ratio=0.634

real  0m 9.23s

user 0m 9.06s

sys    0m 0.13s

-------------------------------

 

压缩一个wav文件耗时9.2秒,功耗9.5W

image003.png

上图我们看到,单线程的encode-flac仅在一个A72处理器上满负荷运行。

 

image004.png

单核性能和功耗对比

 

 

3). 多核性能测试

a). 我们将使用一个简单C++全局光照渲染器smallpt在多个CPU上借助OpenMP实现多线程运算,测量在不同核心上完成渲染所需要的时间以及功耗。通过下面命令编译smallpt

-------------------------------

$ ./configure --prefix=/home/ben/temp_ram  --host=aarch64-tdx-linux --build=x86_64-linux

$ make

-------------------------------

 

b). 为了充分释放所有核心的计算能力我们将所有的CPU都配置为可用的最高时钟这时候请务必使用良好的散热器件为处理器降温。

-------------------------------

root@apalis-imx8:~# echo performance > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor

root@apalis-imx8:~# echo performance > /sys/devices/system/cpu/cpu4/cpufreq/scaling_governor

-------------------------------

 

此时空闲状态下的Ixora底板和Apalis iMX8QM 模块以及电源适配器的功耗为7.9W

 

./ 4A53同时运行

-------------------------------

root@apalis-imx8:~# taskset 0x0f time ./smallpt 100

Rendering (100 spp) 100.00%

real  3m 19.25s

user 13m 9.33s

sys    0m 0.09s

-------------------------------

 

image005.png

功耗为8.9W,耗时319秒。上图中看到4A53核心处于满负荷状态。

 

./ 2A72同时运行

-------------------------------

root@apalis-imx8:~# taskset 0x30 time ./smallpt 100

Rendering (100 spp) 100.00%

real  2m 58.71s

user 5m 56.20s

sys    0m 0.03s

-------------------------------

 

image006.png

功耗为10.3W,耗时258秒。上图中看到2A72核心处于满负荷状态。

 

./ 4A532A72同时运行

-------------------------------

root@apalis-imx8:~# taskset 0x3f time ./smallpt 100

Rendering (100 spp) 100.00%

real  1m34.648s

user 9m20.123s

sys    0m0.127s

-------------------------------

 

image007.png

功耗为11.4W,耗时134秒。上图中看到2A724A53核心处于均满负荷状态。

 

image008.png

多核性能和功耗对比

 

 

4). 总结

Apalis iMX8QM计算机模块能够利用A72核心强劲的计算能力迅速完成运算任务,甚至是调用iMX8QM所有6个核心发挥其最大的CPU计算能力,而在A53核心上则能够以较低的功耗执行,这种组合方式为嵌入式产品在功耗和性能上提供了灵活的选择。除此之外Apalis iMX8QM还具有DSP、双核GPU以及Cortex-M4,能够借助DSP指令、OpenCL并行计算带来更多的算力,同时M4还可以以更低的功耗运行。本次测试采用了Toradex Linux v3.0b2 BSP随着模块本身和软件的进一步完善该模块会有更佳的表现。


点赞

评论 (0 个评论)

facelist

您需要登录后才可以评论 登录 | 注册

  • 关注TA
  • 加好友
  • 联系TA
  • 0

    周排名
  • 0

    月排名
  • 0

    总排名
  • 0

    关注
  • 3

    粉丝
  • 0

    好友
  • 1

    获赞
  • 2

    评论
  • 13923

    访问数
关闭

站长推荐 上一条 /1 下一条

小黑屋| 关于我们| 联系我们| 在线咨询| 隐私声明| EETOP 创芯网
( 京ICP备:10050787号 京公网安备:11010502037710 )

GMT+8, 2024-3-28 21:43 , Processed in 0.013857 second(s), 7 queries , Gzip On, Redis On.

eetop公众号 创芯大讲堂 创芯人才网
返回顶部