Mali Offline Compiler - 官方视频教学 - 笔录

news2024/9/24 0:18:27

文章目录

  • 目的
  • Mali Offline Compiler 使用实例视频
    • 分析 shader
    • malioc 命令
    • 制定你想要分析的 shader
    • 制定你想要分析的着色器对应的 GPU
    • 实例解析内容
    • 硬件结构 & 驱动 & Shader 类型信息
    • 寄存器、是否堆溢出、16-bit 算术占比
      • 寄存器的使用量减少
      • 浮点精度优化
      • 堆溢出与否
      • 16-bit 算术占比
    • 算术,加载/写入、插值、纹理 等单元
      • 定位瓶颈
    • 换个 Mali-G78 r1p1 GPU
    • FMA(乘加加速器), CVT(算术类型转换), SFU(特殊单元)
    • cycles占比介绍说明
    • Shader Properties (属性部分)
    • 是否使用到 通用计算
      • 尽可能移植到 CPU 上执行
    • 是否有 alpha test, alpha-to-coverage
    • 是否有使用 later ZS testing 和 later ZS update,以及性能影响说明
      • 应该尽可能少 discard
    • 输出报告
      • 输出json报告,制定自己的dashboard
  • References
  • 扩展


目的

便于后续不用反复观看视频
直接截图 + 字幕说明,文档化

如果你喜欢的话,也可以直接再 油管上直接,选择:搜索视频,查看字幕来定位播放对应时间进度内容
在这里插入图片描述


Mali Offline Compiler 使用实例视频

参考:Arm Mali GPU Training - Episode 3.5: Mali Offline Compiler


分析 shader

命令行 ls 列出文件
在这里插入图片描述
比如这个 shader 用于游戏中 角色溶解的效果
请添加图片描述
在这里插入图片描述

使用 maili offline compiler 分析的示例


malioc 命令

在这里插入图片描述


制定你想要分析的 shader

在这里插入图片描述

制定你想要分析的着色器对应的 GPU

在这里插入图片描述
这里使用的是 Mali-072 型号的 GPU
在这里插入图片描述

实例解析内容

在这里插入图片描述


硬件结构 & 驱动 & Shader 类型信息

第一部分是:

  • 硬件 : Mali-G72 r0p3
  • 结构 : Bifrost
  • 驱动 : r25p0-00rel0
  • Shader 类型 : OpenGL ES Fragment, OpenGL ES 片源着
    在这里插入图片描述

寄存器、是否堆溢出、16-bit 算术占比

之后还有

  • 使用到的 registers : 64 个
  • Uniform registers : 26 个
  • Stack spilling : false, 没有堆栈溢出
  • 16-bit arithmetic : 2%,16位算术占 2%
    在这里插入图片描述

寄存器的使用量减少

但是留意,这个 GPU 最大 registers 是 32 个
在这里插入图片描述

可用的物理寄存器池被分配给正在执行的着色器线程
the available physical register pool is divided, among the shader threads aht are executing

因此,减少工作寄存器的使用,可以增加可以同时执行的线程数量,有助于保持GPU繁忙
so, reducting work register usage, can increase the number of threads that can be executed simultaneously, helping to keep the GPU busy


浮点精度优化

在这里插入图片描述

为了减少工作寄存器的使用,尝试将精度从高32位降低到中16位
To reduce work register usage, try reducing precision from highp, 32-bit to mediump, 16-bit

这使得GPU可以在每个寄存器中存储两倍的变量。
This enables the GPU to store twice as many variables per register.


堆溢出与否

在这里插入图片描述

对于Valhall和Bifrost GPU,我们可以看到是否有任何变量溢出到堆栈内存,如果是,每个线程溢出多少字节。
For Valhall and Bifrost GPUs, we can see whether any variables are spilled to stack memory, and if so, how many bytes per thread are spilled.

溢出到堆栈的着色器对于GPU来说是昂贵的,所以如果你看到堆栈溢出,尝试通过降低变量精度,减少变量的有效范围或简化着色器程序来减少寄存器压力
Shaders that spill to stack are expensive for a GPU to process, so if you see stack spilling going on, try to reduce register pressure, by reducing variable precision, reducing the live ranges of variables, or by simplifying the shader program


16-bit 算术占比

在这里插入图片描述

在这里,您可以看到以16位或更低精度执行的算术运算的百分比。
Here you can see the percentage of arithmetic operations, that are performed at 16-bit precision or lower.

在这里插入图片描述

这里的数字越高越好,因为使用mediump选择的16位精度比32位精度的高速度快两倍。
A higher number here is better, because 16-bit precision, selected with mediump, is twice as fast as highp at 32-bit precision.

在这里插入图片描述

这里的数字越高越好,因为使用mediump选择的16位精度比32位精度的高速度快两倍。我们可以看到,只有2%的算法计算是在16位精度下完成的。这意味着着色器在大多数计算中使用32位精度。如果我们将精度从高降低到中,着色器将更有效地运行。这样既降低了能耗,又降低了寄存器压力,使性能翻倍。有些情况下总是需要高分辨率,例如位置和深度计算,但在许多情况下,当将精度降低到中档时,屏幕上几乎没有明显的差异。
A higher number here is better, because 16-bit precision, selected with mediump, is twice as fast as highp at 32-bit precision. We can see that only 2% of artihmetic computation is done at 16-bit precision. This means that the shader is using 32-bit precision highp for most of its calculations. The shader will operate more efficiently if we reduce precision from highp to mediump. This reduces both energy consumption and register pressure, and can double the performance. There are situations where highp is always required, such as for position and depth calculations, but in many cases there is little noticeable difference on-screen when reducing precision to mediump


算术,加载/写入、插值、纹理 等单元

接下来,有一个近似的周期成本分解
在这里插入图片描述

  • A = Arithmetic - 算术
  • LS = Load/Store - 加载/写入
  • V = Varying - 插值其
  • T = Texture - 纹理

对于Mali着色器核心中的主要功能单元,算术单元,加载/存储单元,插值单元和纹理单元。
for the major functional units in the Mali shader core, the arithmetic unit, the load/store unit, the varying unit, and the texture unit.

在最短路径周期和最长路径周期中,周期成本最高的单元是一个很好的候选优化对象。
The unit with the hightest cycle cost in either or both of the shortest path cycles, and longest path cycles, is a good candidate to optimize.

定位瓶颈

在这里插入图片描述

在这里,我们可以看到算术单位是使用最频繁的。我们可以通过减少数学运算的次数来优化它,或者降低计算的精度。
Here, we can see that the arithmetic unit is the most heavily used. We can optimize it by reducing the number of mathematical operations that it performs, or the precision of the those calculations.

在这里插入图片描述
其实 Bound 也会告诉你,瓶颈在哪个部分,比如上图都是在 A 的部分,也就是 算术部分


换个 Mali-G78 r1p1 GPU

在这里插入图片描述

在这里插入图片描述


FMA(乘加加速器), CVT(算术类型转换), SFU(特殊单元)

在这里插入图片描述

对于基于Valhall的GPU,如Mali-G78,算法成本显示为FMA, CVT和SFU管道的分解。
For Valhall-based GPUs, such as the Mali-G78, arithmetic cost is shown broken down by FMA, CVT and SFU pipelines.

  • FMA - Fused multiply accumulate - “熔合乘法累积”(Fused Multiply Accumulate),这是一种结合了乘法和加法的指令,可以通过一条指令实现递归计算。
    • 其中最主要的是新增的3操作数指令(3-Operand Instructions)和熔合乘法累积(Fused Multiply Accumulate,FMAC)指令,这两条指令都可以大幅提高操作效率,简化代码。
  • CVT - Arithmetic conversion - CVT算术转换
    • 隐式类型转换 又称为“标准转换”,包括以下几种情况: 1) 算术转换(Arithmetic conversion) : 在混合类型的算术表达式中, 最宽的数据类型成为目标转换类型。
  • SFU - Special functions unit - 特殊功能单元

cycles占比介绍说明

在这里插入图片描述

所有Valhall GPU都实现了两个并行处理引擎,每个都包含自己的一组算术流水线。
All Valhall GPUs implement two parallel processing engines, each containing their own set of arithmetic pipelines.

The data presented in the report is normalized based on the number of engines in the design, to give an overall cost for the targeted shader core, not just for a single engine.
报告中的数据是基于设计中的引擎数量进行归一化的,以给出目标着色器核心的总体成本,而不仅仅是单个引擎的成本。


Shader Properties (属性部分)

在这里插入图片描述


在这里插入图片描述

着色器属性(shader properties)部分给出了着色器使用的语言特性的信息,这些特性可能会影响着色器执行的性能。
The shader properties section, gives information about the shader’s use of language features that can impact the performance of shader execution.


是否使用到 通用计算

在这里插入图片描述

尽可能移植到 CPU 上执行

在这里插入图片描述

我们可以看到这个着色器包含了统一计算。这种计算将为drawcall或compute dispatch中的每个线程产生相同的结果。Mali驱动程序可以优化这种方式,但它仍然有成本,所以你应该将这种计算从着色器代码中移出,转移到CPU上,在绘制时执行。
We can see that this shader contains uniform computation. This kind of computation will produce the same answer for every thread in the drawcall or compute dispatch. The Mali driver can optimize the way, but it still has a cost, so you should move this kind of computation out of the shader code, and on to the CPU, to be executed at draw time.


是否有 alpha test, alpha-to-coverage

在这里插入图片描述

这告诉我们着色器可以修改片段覆盖掩码。片段覆盖掩码确定每个像素中的哪些样本点被片段覆盖,使用discard语句删除低于alpha阈值的片段。
This tells us that the shader can modify the fragment coverage mask. The fragment coverage mask determines which sample points in each pixel are covered by a fragment, using the discard statement to drop fragments that are below an alpha threshold.


是否有使用 later ZS testing 和 later ZS update,以及性能影响说明

在这里插入图片描述

覆盖范围可修改的着色器必须使用 later ZS更新,这会降低 early ZS测试的效率和同一坐标下later fragments 的调度效率。
Shaders with modifiable coverage must use a later ZS update, which can reduce efficiency of early ZS testing and fragment scheduling for later fragments at the same coordinate.


应该尽可能少 discard

在这里插入图片描述

你应该尽可能减少在fragment着色器中使用discard语句和alpha-to-coverage语句。
You shold minimize the use of discard statements and alpha-to-coverage in fragment shaders where possible.


在这里插入图片描述

幸运的是,这个着色器不会强制 Later ZS测试,Later ZS测试会完全禁用 Early ZS测试和 HSR 隐藏表面的删除,从而导致显著的效率损失。
Fortunately, this shader does not force a later ZS test, which would completely disable early ZS testing and hidden surface removal a significant efficiency loss.


输出报告

在这里插入图片描述

在这里插入图片描述

You can export this report to a file, by running the command with this extra command line option.
通过运行带有额外命令行选项的命令,您可以将此报告导出到文件。


输出json报告,制定自己的dashboard

在这里插入图片描述

如果你在持续集成环境中工作,你还可以将Mali离线编译器报告导出为机器可读的JSON文件,这样你就可以构建自己的仪表板来监控着色器的性能。
If you are working within a continuous integration enviroment, you can also export Mali Offline Compiler reports as machine-readable JSON files, so that you can build your own dashboard to monitor shader performance over time.

在这里插入图片描述


在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

安装目录中提供了示例报告和JSON模式定义。
Sample reports and JSON schema definitions are provided in the installation directory.


检查帮助页面以查看所有可用选项的列表。
在这里插入图片描述


References

  • Arm Mali GPU Training - Episode 3.5: Mali Offline Compiler

扩展

  • Mali GPU Counter
  • Mali Offline Compiler
  • Mali Graphics Debugger
  • 使用Mali Graphics Debugger调优Unity程序(Killer示例)

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/728112.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

基于Java+vue前后端分离学习交流论坛设计实现(源码+lw+部署文档+讲解等)

博主介绍:✌全网粉丝30W,csdn特邀作者、博客专家、CSDN新星计划导师、Java领域优质创作者,博客之星、掘金/华为云/阿里云/InfoQ等平台优质作者、专注于Java技术领域和毕业项目实战✌ 🍅文末获取源码联系🍅 👇🏻 精彩专…

easyExcel实现动态导出需要的字段列

easyExcel实现动态导出需要的字段列 实体概况 package excel;import com.alibaba.excel.annotation.ExcelIgnore; import com.alibaba.excel.annotation.ExcelProperty; import com.alibaba.excel.annotation.write.style.ColumnWidth; import com.alibaba.excel.annotation.…

C++学习笔记-第11单元 标准模板库介绍

第11单元 标准模板库介绍 文章目录 第11单元 标准模板库介绍单元导读11.1 标准模板库(STL)基础11.2 STL容器简介11.3 STL迭代器简介11.3.1 使用迭代器访问容器中的元素11.3.2 迭代器类型11.3.3 迭代器支持的运算符操作 11.4 顺序容器11.4.1 顺序容器的逻辑结构11.4.2 代码展示s…

Vue组件库Element-快速入门

目录 什么是Element 快速入门 什么是Element Element:是饿了么团队研发的,一套为开发者、设计师和产品经理准备的基于Vue2.0的桌面端组件库组件:组成网页的部件,例如超链接、按钮、图片、表单、表格、分页条等官网:…

avoidLabelOverlap无效果,echarts环形标签重叠,echarts数据重叠

在开发echarts环形图时,会出现数据重叠的现象.比如下面这情况.不可能为了数据将环形图变得太小,这样环形图太小也不美观.后来在官网上查找有一个avoidLabelOverlap属性,结果加上去后也没啥用 解决方法: 除了加上面:avoidLabelOverlap:true以外,还要加另外一个属性:minAngle:1…

win10系统中Pensieve(Sigcomm17)算法部署与运行

win10系统中Pensieve算法部署与运行 一、环境配置1、Anaconda环境配置2、Pycharm安装3、Pensieve安装包配置4、Pensieve数据集生成5、Pensieve代码运行6、Pensieve代码修改 一、环境配置 1、Anaconda环境配置 下载并且安装 Anaconda 官网下载地址:https://www.ana…

【Java基础教程】(六)程序概念篇 · 末:全面讲解Java方法的定义及应用、方法重载及递归~

Java基础教程之程序概念 末 本节学习目标1️⃣ 方法的定义与使用1.1 概念🔍 在编写代码时,怎么判断什么情况下应该定义方法? 1.2 方法重载1.3 方法递归 🌾 总结 本节学习目标 掌握Java中方法的定义结构、方法重载的概念与应用;…

EulerOS2.0SP10操作系统Esxi虚拟机安装手记

本文记录了在 Esxi7.0平台上新建虚拟机安装华为EulerOS2.0SP10国产操作系统的过程,仅供参考。 一、新建虚拟机 1、在VCenter上选中集群,右键选择新建虚拟机 2、在新建虚拟机视图点NEXT 3、输入虚拟机名称(自定义),选…

Apikit 自学日记:如何引用全局变量

引用全局变量 一、什么是全局变量 全局变量可以在测试过程中动态取值以及赋值,比如:使用登录接口获取 token,将 token 值赋值给自定义全局变量 global_token,然后在另一个需要使用该token的接口中,使用 {{global_toke…

css,less,scss中的深度选择器,结合elementUi使用

css中深度选择器用到的是 >>>加类名 可以很方便的找到自己想要修改的样式 lees中用到 /deep/ 加类名 scss中用到::v-deep 加类名

【软件工具使用体验NFC】读取nfc里的内容和写入nfc的内容 tagInfo和TagWritter两款软件的使用和下载

教程目录 教程简介所需环境和版本资源免费下载执行过程tagInfo的使用:tagWritter的使用:my dataset的解释: 结束语 教程简介 这篇内容主要是前段时间开发了一个小程序的时候涉及到了通过小程序读写nfc标签的内容,当时还特地和我们…

特征模型仿真例1:参数辨识

题目 考虑被控对象 G ( s ) 3 s 4 s 4 5 s 3 10 s 2 6 s 4 G(s)\frac{3 s4}{s^{4}5 s^{3}10 s^{2}6 s4} G(s)s45s310s26s43s4​ 和特征模型 y ( k ) ϕ T ( k − 1 ) θ ( k ) y(k)\boldsymbol{\phi}^{\mathrm{T}}(k-1)\boldsymbol{\theta}(k) y(k)ϕT(k−1)θ(k) 其…

谁告诉我这是什么文件,怎么了?活不起了?得靠这个冲业绩?

TIM 从一年前就卸载了,今天整理磁盘才发现还有这么多文件,想着没什么用直接删掉得了,没想到他娘的死活删不掉,好多文件一个一个删才找到这玩意,所有能查找运行程序的地方都找遍了,死活没找到在哪打开了&…

第一章 系统服务监控-SpringBootAdmin

前言 本来想用一节就写完SpringBootAdmin的,但随着研究的深入发现一节应该是不够的,网上的资料也不会非常系统,官网的例子有些已经好几年没更新了,所以接下来还是系统性的来写下吧 第一节 完成基础配置,暴露所有端点…

​如何从任何地方访问办公室电脑?

​远程办公已然成为了一种常见的办公方式,在远程工作期间访问办公室电脑获取必要的文件或信息非常重要。与远程访问同一网络中的电脑不同,使用Windows远程桌面从外部访问办公室电脑需要进行端口转发。对于很多人来说,端口转发可能有点复杂。那…

SpringBoot整合RestTemplate用法讲解(完整详细)

前言:本篇主要介绍了RestTemplate中的GET,POST,PUT,DELETE、文件上传和文件下载6大常用的功能,每一个方法和每一行代码都进行了详细的讲解,代码都是亲自测试过的,整篇博客写完以后自己也是受益匪…

缓存穿透、缓存击穿、缓存雪崩详解以及解决方案

缓存穿透、缓存击穿、缓存雪崩详解以及解决方案 一。缓存穿透 查询一个不存在的数据,mysql查询不到数据也不会直接写入缓存,就会导致每次请求都查数据库 方案一: 方案二: 二。缓存击穿 给某一个key设置了过期时间&#xff0…

Mongdb之Robo3T

🏆今日学习目标: 🍀MyBatis详解 ✅创作者:林在闪闪发光 ⏰预计时间:30分钟 🎉个人主页:林在闪闪发光的个人主页 🍁林在闪闪发光的个人社区,欢迎你的加入: 林在闪闪发光的…

2023年PTA行业研究报告

第一章 行业概况 精对苯二甲酸(Pure Terephthalic Acid,简称PTA)是一种主要用于制造聚酯纤维和塑料的关键化学品。PTA是一种白色结晶固体,可通过对苯二酮在催化剂的作用下进行氧化得到。它是聚对苯二甲酸乙二醇酯(PET…

机器视觉三维重建

推荐:将 NSDT场景编辑器 加入你的3D开发工具链。 1、Meshroom ⭐4,474 Meshroom是一款基于AliceVision摄影测量计算机视觉框架的免费开源三维重建软件。 https://github.com/alicevision/meshroom 2、Openmvg ⭐2,829 Openmvg库根据三维计算机视觉和结构的运动。…