【RK3568 CPU GPU DDR NPU定频和性能模式设置】

performance:GPU会固定工作在其支持的最高频率上,以追求最高性能。
powersave:GPU会固定工作在其支持的最低频率上,以追求最低的功耗。
userspace:早期的管理策略,系统将变频策略的决策交给了用户态应用程序,并提供相应的接口供其使用。
ondemand:userspace 是用户态的检测,效率低,
 
cur_freq 当前频率
governor 当前工作模式
 
查看GPU频率范围
# cat /sys/class/devfreq/ff9a0000.gpu/available_frequencies 
200000000 300000000 400000000 600000000 800000000 
 
查看GPU工作模式
# cat /sys/class/devfreq/ff9a0000.gpu/available_governors 
userspace powersave performance simple_ondemand
 
查看GPU最大频率
# cat /sys/class/devfreq/ff9a0000.gpu/max_freq 
0
 
查看GPU最大频率
# cat /sys/class/devfreq/ff9a0000.gpu/min_freq 
0
 
查看GPU实时工作模式及频率
# cat /sys/class/devfreq/ff9a0000.gpu/trans_stat 
   From  :   To
         :200000000300000000400000000600000000800000000   time(ms)
*200000000:       0       0       0       0     119     59866
 300000000:      68       0       0       0      75      6326
 400000000:      28      95       0       0      65     24126
 600000000:      14      23     141       0      11     29833
 800000000:       9      25      47     189       0      9766
Total transition : 909
 
查看当前GPU load情况
# cat /sys/class/devfreq/ff9a0000.gpu/load 
47@200000000Hz
 
注意:
47:当前占用GPU百分比
200000000Hz:当前占用GPU频率
200000000Hz = 200000KHz = 200MHz

定频脚本:performance.sh

# CPU定频
echo "CPU0-3 可用频率:"
cat /sys/devices/system/cpu/cpufreq/policy0/scaling_available_frequencies
echo userspace > /sys/devices/system/cpu/cpufreq/policy0/scaling_governor
echo 1992000 > /sys/devices/system/cpu/cpufreq/policy0/scaling_setspeed
echo "CPU0-3 当前频率:"
cat /sys/devices/system/cpu/cpufreq/policy0/cpuinfo_cur_freq

# NPU定频
echo "NPU 可用频率:"
cat /sys/class/devfreq/fde40000.npu/available_frequencies    
echo userspace > /sys/class/devfreq/fde40000.npu/governor
echo 900000000 > /sys/class/devfreq/fde40000.npu/userspace/set_freq
echo "NPU 当前频率:"
cat /sys/class/devfreq/fde40000.npu/cur_freq

# DDR定频
echo "DDR 可用频率:"
cat /sys/class/devfreq/dmc/available_frequencies
echo userspace > /sys/class/devfreq/dmc/governor
echo 1560000000 > /sys/class/devfreq/dmc/userspace/set_freq
echo "DDR 当前频率:"
cat /sys/class/devfreq/dmc/cur_freq

在这里插入图片描述

查看RK3588 CPU GPU DDR NPU的频率电压表
在设计上面通过ADB命令可以查看机器的频率电压信息:
CPU定频
RK3588的cpu是4个A55+4个A76,分为3组单独管理,节点分别是:

/sys/devices/system/cpu/cpufreq/policy0:(对应4个A55:CPU0-3)
affected_cpus     cpuinfo_max_freq  cpuinfo_transition_latency  scaling_available_frequencies  scaling_cur_freq  scaling_governor  scaling_min_freq  stats
cpuinfo_cur_freq  cpuinfo_min_freq  related_cpus                scaling_available_governors    scaling_driver    scaling_max_freq  scaling_setspeed

/sys/devices/system/cpu/cpufreq/policy4:(对应2个A76:CPU4-5)
affected_cpus     cpuinfo_max_freq  cpuinfo_transition_latency  scaling_available_frequencies  scaling_cur_freq  scaling_governor  scaling_min_freq  stats
cpuinfo_cur_freq  cpuinfo_min_freq  related_cpus                scaling_available_governors    scaling_driver    scaling_max_freq  scaling_setspeed

/sys/devices/system/cpu/cpufreq/policy6:(对应2个A76:CPU6-7)
affected_cpus     cpuinfo_max_freq  cpuinfo_transition_latency  scaling_available_frequencies  scaling_cur_freq  scaling_governor  scaling_min_freq  stats
cpuinfo_cur_freq  cpuinfo_min_freq  related_cpus                scaling_available_governors    scaling_driver    scaling_max_freq  scaling_setspeed
rk3588_s:/ # 

以上3个CPU是独立控制,下面以设置CPU6-7为例说明如何设置CPU6-7的频率

获取当前CPU支持的频点

rk3588_s:/ # cat /sys/devices/system/cpu/cpufreq/policy6/scaling_available_frequencies                                                                                                    
408000 600000 816000 1008000 1200000 1416000 1608000 1800000 2016000 2208000 2400000 

获取cpu运行的模式

rk3588_s:/ # cat /sys/devices/system/cpu/cpufreq/policy6/scaling_available_governors                                                                                                      
conservative ondemand userspace powersave performance schedutil 

默认是自动变频模式:schedutil(恢复的话设置为该模式即可)

设置手动定频模式:userspace

1|rk3588_s:/ $ su
rk3588_s:/ # echo userspace > /sys/devices/system/cpu/cpufreq/policy6/scaling_governor

设置频率为2016000

rk3588_s:/ # echo 2016000 > /sys/devices/system/cpu/cpufreq/policy6/scaling_setspeed

确认是否设置成功

rk3588_s:/ # cat /sys/devices/system/cpu/cpufreq/policy6/cpuinfo_cur_freq                                                                                                                 
2016000

其他两组CPU也是类似的方式进行设置,操作对应的节点即可。

GPU定频
GPU的节点路径

rk3588_s:/ # ls /sys/class/devfreq/fb000000.gpu/                                                                                                                                           
available_frequencies  cur_freq  governor  max_freq  name              power      target_freq  trans_stat
available_governors    device    load      min_freq  polling_interval  subsystem  timer        uevent

获取GPU支持的频点

rk3588_s:/ # cat /sys/class/devfreq/fb000000.gpu/available_frequencies                                                                                                                     
1000000000 900000000 800000000 700000000 600000000 500000000 400000000 300000000 200000000

获取GPU运行的模式

rk3588_s:/ # cat /sys/class/devfreq/fb000000.gpu/available_governors                                                                                                                       
dmc_ondemand userspace powersave performance simple_ondemand

默认是自动变频模式:simple_ondemand(恢复的话设置为该模式即可)

设置手动定频模式:userspace

1|rk3588_s:/ $ su
rk3588_s:/ # echo userspace > /sys/class/devfreq/fb000000.gpu/governor

设置频率为1000000000

rk3588_s:/ # echo 1000000000 > /sys/class/devfreq/fb000000.gpu/userspace/set_freq

确认是否设置成功

rk3588_s:/ # cat /sys/class/devfreq/fb000000.gpu/cur_freq                                                                                                                                  
1000000000

查看GPU的负载

rk3588_s_evb7:/ # cat /sys/class/devfreq/fb000000.gpu/load                                                                                                                                    
28@300000000Hz

DDR定频
DDR的节点路径
1|rk3588_s:/ # ls /sys/class/devfreq/dmc/

available_frequencies  cur_freq  downdifferential  load      min_freq  polling_interval  subsystem      target_freq  trans_stat  upthreshold
available_governors    device    governor          max_freq  name      power             system_status  timer        uevent

获取DDR支持的频点

rk3588_s:/ # cat /sys/class/devfreq/dmc/available_frequencies                                                                                                                              
528000000 1068000000 1560000000 2112000000

获取DDR运行的模式

rk3588_s:/ # cat /sys/class/devfreq/dmc/available_governors                                                                                                                                
dmc_ondemand userspace powersave performance simple_ondemand

默认是自动变频模式:dmc_ondemand(恢复的话设置为该模式即可)

设置手动定频模式:userspace

1|rk3588_s:/ $ su
rk3588_s:/ # echo userspace > /sys/class/devfreq/dmc/governor

设置频率为2112000000

rk3588_s:/ # echo 2112000000 > /sys/class/devfreq/dmc/userspace/set_freq

确认是否设置成功

rk3588_s:/ # cat /sys/class/devfreq/dmc/cur_freq                                                                                                                                  
2112000000

查看DDR的负载

rk3588_s_evb7:/ # cat /sys/class/devfreq/dmc/load                                                                                                                                             
7@528000000Hz

NPU定频
NPU的节点路径

1|rk3588_s:/ # ls /sys/class/devfreq/fdab0000.npu/                                                                                                                                         
available_frequencies  cur_freq  governor  max_freq  name              power      target_freq  trans_stat  userspace
available_governors    device    load      min_freq  polling_interval  subsystem  timer        uevent

获取NPU支持的频点

rk3588_s:/ # cat /sys/class/devfreq/fdab0000.npu/available_frequencies                                                                                                                     
200000000 300000000 400000000 500000000 600000000 700000000 800000000 900000000 1000000000

获取NPU运行的模式

rk3588_s:/ # cat /sys/class/devfreq/fdab0000.npu/available_governors                                                                                                                       
dmc_ondemand userspace powersave performance simple_ondemand

默认是自动变频模式:simple_ondemand(恢复的话设置为该模式即可)

设置手动定频模式:userspace

1|rk3588_s:/ $ su
rk3588_s:/ # echo userspace > /sys/class/devfreq/fdab0000.npu/governor

设置频率为1000000000

rk3588_s:/ # echo 1000000000 > /sys/class/devfreq/fdab0000.npu/userspace/set_freq

确认是否设置成功

rk3588_s:/ # cat /sys/class/devfreq/fdab0000.npu/cur_freq                                                                                                                                  
1000000000

查看NPU的负载

rk3588_s_evb7:/ # cat /sys/kernel/debug/rknpu/load                                                                                                                                            
NPU load:  Core0:  0%, Core1:  0%, Core2:  0%,

CPU性能模式

1|rk3588_s:/ $ su
rk3588_s:/ # echo performance > /sys/devices/system/cpu/cpufreq/policy6/scaling_governor

GPU性能模式

1|rk3588_s:/ $ su
rk3588_s:/ # echo performance > sys/class/devfreq/fb000000.gpu/governor

DDR性能模式

1|rk3588_s:/ $ su
rk3588_s:/ # echo performance > /sys/class/devfreq/dmc/governor

NPU性能模式

1|rk3588_s:/ $ su
rk3588_s:/ # echo performance > /sys/class/devfreq/fdab0000.npu/governor
### RK3568 芯片与 Fusion 技术信息及解决方案 #### 关于RK3568芯片的技术特性 RK3568是一款由瑞芯微电子推出的高性能处理器,采用四核ARM Cortex-A55架构设计。该款SoC集成了Mali-G52 2EE图形处理单元以及支持多种视编解码器的多媒体引擎。其具备强大的计算能力丰富的外设接口选项,适用于工业控制、智能安防等多个领域。 #### Fusion技术概述及其应用到RK3568平台的可能性分析 Fusion通常指的是不同传感器数据融合或是多模态信息集成的一种方法论,在计算机视觉机器学习等领域有着广泛的应用场景。对于基于RK3568构建的产品而言,可以考虑利用内置NPU来加速AI算法执行效率的同时实现图像识别等功能模块间的深度融合[^1]。 #### 针对具体应用场景下的优化建议 为了更好地发挥出这两者结合所带来的优势效果,可以从以下几个方面入手进行针对性调优: - **硬件层面**:充分利用RK3568内部资源如GPU/NPU等异构计算部件完成特任务卸载;同时借助高速DDR4内存带宽提升整体吞吐量表现。 - **软件框架适配**:选择合适的人工智能开发工具链(例如TensorFlow Lite, PyTorch Mobile),并针对目标模型做量化剪枝等一系列轻量化改造措施以适应嵌入式环境运行需求。 - **操作系统制化服务**:通过裁剪Linux发行版内核配置项或者移植RTOS方案等方式减少启动时间开销,并确保实时响应性能达到预期指标要求。 ```c++ // 示例代码展示如何初始化一个简单的OpenCL程序用于测试RK3568上的GPU性能 #include <CL/cl.h> int main() { cl_platform_id platform; cl_device_id device; cl_context context; cl_command_queue queue; // 获取平台ID clGetPlatformIDs(1,&platform,NULL); // 获取设备ID clGetDeviceIDs(platform, CL_DEVICE_TYPE_GPU, 1, &device, NULL); // 创建上下文 context = clCreateContext(NULL, 1, &device, NULL, NULL, NULL); // 创建命令队列 queue = clCreateCommandQueue(context, device, 0, NULL); // 这里省略了后续操作... } ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值