当前位置 博文首页 > 丁劲犇技术发布空间:建议在RaspberryPi 4b 上使用 64位官方镜像

    丁劲犇技术发布空间:建议在RaspberryPi 4b 上使用 64位官方镜像

    作者:[db:作者] 时间:2021-09-19 22:45

    RaspberryPi 4 采用了Broadcom BCM2711处理器,是一块64位芯片。然而,目前官网的RaspberryPI OS 考虑到处理器兼容性,都是基于32位的Debain Arm架构。之前一直看到网上说,官方的64位测试版性能提升,但没有试过。此次下载了64位的官网镜像,进行了测试,不比不知道,一比吓一跳。特此记录。

    1 树莓派4B介绍

    树莓派4B 是一款采用了博通BCM2711处理器的Arm64卡片计算机。从一些资料来看,与其说它是一种单片机或者开发板,不如说是一个PC机。1

    首先因为它的价格、能耗、接口、功能都更像PC机,另外就是它的硬件并不是完全开放的,不能说是一个友好的开发板。这个板子作为学习简单的Arm架构开发,控制一些基于串口、USB、GPIO的硬件设备,还是不错的选择。

    在这里插入图片描述

    项目参数
    核心CPU:Broadcom BCM2711,1.5 GHz,64-bit,4核心,ARM Cortex-A72 架构,1MB shared L2 cache RAM:1、2、4 GB LPDDR4-3200 RAM (shared with GPU)
    网络以太网:10/100/1000 Mbit/s 无线网:b/g/n/ac 双频 2.4/5 GHz 蓝牙:5.0
    多媒体GPU:Broadcom VideoCore VI @ 500 MHz HDMI:micro-HDMI DSI:板载排线
    外围设备17× GPIO plus the same specific functions, HAT, and an additional 4× UART, 4× SPI, and 4× I2C connectors

    这个板子的性能已经显著与STM32单片机产生质的区别,接口特性也基本符合PC机的范畴。事实上,树莓派的本意也不是做单片机,而是做所有人都买得起的计算机,普及不发达地区的计算机教育。因此,它的大量驱动也是独一份,人家压根没有想到给第三方厂家复刻。

    2 64位系统尝试

    树莓派官方系统是RaspberryPi OS,一款在Debain上深度定制的操作系统。为了兼容各代硬件,尽管4代已经高配到8GB RAM,官方仍旧没有推出64位的发行版。目前,64位的发行版只推出了 Beta,因为仍旧有以下问题没有解决:

    • 视频加速驱动,Chrome和VLC只能软件播放。(经测试,区别不大)
    • 没有Wolfram Mathematica 软件(这个很要命)。2

    不过,随着官方开发团队的不断努力,目前VLC已经释出,且Chrome的性能和32位上也没有大的差异。
    从网址https://downloads.raspberrypi.org/raspios_arm64/images/下载最新镜像,写入SD卡后,即可尝试该系统。

    笔者选取的是V30的256GB高速SD卡,8G顶配版本,附带铝合金被动散热。

    2.1 OpenMP素数快速求取,15倍

    我们使用笔者写的OpenMP素数求取程序,分别在同一个配置、不同操作系统下运行,对比如下:

    32位系统:

    Batch 1048576 ,80214 primes, last Primer: 1114111 , 576613 / s
    Batch 1053160 ,73684 primes, last Primer: 2167261 , 381935 / s
    Batch 1103492 ,74527 primes, last Primer: 3270737 , 309095 / s
    Batch 1134620 ,74723 primes, last Primer: 4405381 , 275835 / s
    Batch 1157146 ,75096 primes, last Primer: 5562517 , 243509 / s
    Batch 1174788 ,75119 primes, last Primer: 6737317 , 223804 / s
    Batch 1189280 ,75257 primes, last Primer: 7926593 , 212956 / s
    Batch 1201576 ,75247 primes, last Primer: 9128153 , 199646 / s
    

    64位系统:

    Batch 1048576 ,80214 primes, last Primer: 1114111 , 3755886 / s
    Batch 1053160 ,73684 primes, last Primer: 2167261 , 3778342 / s
    Batch 1103492 ,74527 primes, last Primer: 3270737 , 3590787 / s
    Batch 1134620 ,74723 primes, last Primer: 4405381 , 3515944 / s
    Batch 1157146 ,75096 primes, last Primer: 5562517 , 3331344 / s
    Batch 1174788 ,75119 primes, last Primer: 6737317 , 3254026 / s
    Batch 1189280 ,75257 primes, last Primer: 7926593 , 3138231 / s
    Batch 1201576 ,75247 primes, last Primer: 9128153 , 3041471 / s
    

    速度相差 15倍!

    2.2 视频播放,几乎一制

    1920x1080,CPU 20%-40%,两个操作系统基本没有差别。
    在这里插入图片描述

    Play

    2.3 sysbench,6倍

    需要注意,64位镜像暂时需要从源码编译sysbench.
    32Bit:

    pi@rbp4bgh:~ $ sysbench --test=cpu --cpu-max-prime=20000 run --num-threads=4
    sysbench 0.4.12:  multi-threaded system evaluation benchmark
    
    Running the test with following options:
    Number of threads: 4
    
    Doing CPU performance benchmark
    
    Threads started!
    Done.
    
    Maximum prime number checked in CPU test: 20000
    
    
    Test execution summary:
        total time:                          63.2772s
        total number of events:              10000
        total time taken by event execution: 253.0857
        per-request statistics:
             min:                                 24.49ms
             avg:                                 25.31ms
             max:                                 73.81ms
             approx.  95 percentile:              26.10ms
    
    Threads fairness:
        events (avg/stddev):           2500.0000/4.58
        execution time (avg/stddev):   63.2714/0.00
    
    
    

    64bit:

    sysbench cpu --cpu-max-prime=20000 run --threads=4
    sysbench 1.1.0-5657d59 (using bundled LuaJIT 2.1.0-beta3)
    
    Running the test with following options:
    Number of threads: 4
    Initializing random number generator from current time
    
    
    Prime numbers limit: 20000
    
    Initializing worker threads...
    
    Threads started!
    
    CPU speed:
        events per second:  2244.41
    
    Throughput:
        events/s (eps):                      2244.4124
        time elapsed:                        10.0017s
        total number of events:              22448
    
    Latency (ms):
             min:                                    1.70
             avg:                                    1.78
             max:                                   21.47
             95th percentile:                        2.14
             sum:                                39980.16
    
    Threads fairness:
        events (avg/stddev):           5612.0000/74.63
        execution time (avg/stddev):   9.9950/0.00
    
    

    2.4 Octave 浮点矩阵求逆,2倍

    32

    a=rand(800,800);tic;p=pinv(a);toc;
    Elapsed time is 28.9755 seconds.
    

    64

     a=rand(800,800);tic;p=pinv(a);toc;
    Elapsed time is 12.3227 seconds.
    

    3 小结

    由于笔者的2块SD卡容量不同,没有做性能比对。不过,从开机速度来看,64位比32位快了3倍多。建议有条件的小伙伴直接上64位的OS!


    1. http://bbs.eeworld.com.cn/thread-1110657-1-1.html ??

    2. https://www.raspberrypi.org/forums/viewtopic.php?t=275370 ??

    cs