GPU 性能计数器和驱动程序计数器的含义是什么?
What is the meaning of GPU performance counters and driver counters?
https://developer.nvidia.com/sites/default/files/akamai/tools/files/PerfKit_4_5_User_Guide.pdf
NVIDIA PerfKit SDK allows graphics developers access to low-level NVIDIA GPU
performance counters and NVIDIA driver counters.
我想了解这些计数器的含义?它们是某种硬件还是软件?他们是做什么的?
它们对我有什么帮助?请给出使用它们的例子。
我必须使用 Nvidia perfkit 来确定某些处理机器人的软件的性能。
It gives you access to low-level performance counters inside the
driver and hardware counters inside the GPU itself. The counters can
be used to determine exactly how your application is using the GPU,
identify performance issues, and confirm that performance problems
have been resolved.
这意味着,您可以获得有关应用程序 GPU 使用情况和性能的信息,并用于查找性能问题。
还有一些链接:
- http://www.nvidia.com/object/nvperfkit_home.html
- https://developer.nvidia.com/nvidia-perfkit
- http://docs.nvidia.com/gameworks/index.html#developertools/desktop/linux_graphics_debugger/lgd_perf_counters.htm%3FTocPath%3DDeveloper%2520Tools%7CDesktop%2520Developer%2520Tools%7CLinux%2520Graphics%2520Debugger%7C_____9
我不是图形程序员,所以我将从 computer-architecture 的角度来处理这个问题。我不知道哪些计数器对于查找 3D 图形或 GPU-computing 中的哪种瓶颈特别有用,所以不要读入我选择的计数器作为示例的任何内容。
调用图形函数时,很多繁重的工作都是由专用 GPU 硬件完成的。
但是为了保持 GPU 硬件的运行,主 CPU 上的 driver 软件 运行 必须做重要的工作,有时这可能是一个瓶颈。 "driver counters" 用于跟踪软件正在执行/等待的各种操作,还有用于跟踪 GPU 硬件实际执行操作的硬件计数器。
显卡就像一台带有处理器+内存的独立计算机,但处理器是专门的 GPU,其 instruction-set 专为做 GPU 擅长的事情而设计。但它仍然有自己的时钟并像流水线一样解码/执行指令CPU。 GPU 性能事件可以统计在此硬件上执行的 single-precision 浮点运算的数量。或者为 GPU 访问其自己的内存缓存 hit/miss 事件(它有自己的视频 RAM 缓存)。计数器由硬件 built-in 跟踪到 GPU 管道。
NVidia 的 table 为 GPU hardware events that their hardware tracks。它包括诸如 texture_busy
之类的内容,其中包含 "clock cycles the texture unit is busy"。将其与您分析的时间段的总时钟周期进行比较,可以告诉您纹理单元的硬件吞吐量接近最大化/瓶颈的程度。或 shaded_pixel_count
:发送到着色单元的光栅化像素数。在硬件事件中,它们按 GPU 硬件的哪个部分细分:有一般的“GPU”事件,如“SM “(着色器)事件,如 inst_executed_vs
"Instructions executed by vertex shaders (VS), not including replays.",以及 Cache 事件,如 l1_l2_requests
"Number of L2 requests from the L1 unit."(与 L1 未命中次数高度相关,我假设)。还有 Memory 事件,例如 sm_inst_executed_local_loads
"Local load instructions executed."
(以上示例是“适用于架构早于 Kepler 的 GPU”;事实证明,我发现的第一个 google 命中是针对旧 GPU 的页面。这不会改变基本原理:GPU 事件是 low-level 硬件可以跟踪的东西,但 CPU 上的软件通常不能。它不知道发送时是否会出现缓存未命中为 GPU 工作。)
table 将事件分为 "Graphics" 和 "Compute" API。也许某些事件是由 NVidia 的软件从实际的 HW 计数器合成的。它记录了 NVidia 的开发人员工具可以向您展示的内容,而不是硬件实际上是什么。例如inst_executed_cs_ratio
可能来自执行的计算着色器指令的计数器和执行的总指令的另一个 HW 计数器。
这些硬件性能计数器(可能)的实现非常类似于硬件CPU性能计数器,可以计算时钟周期、指令、微指令、各种停顿微架构资源等。在 x86 CPUs 上,计数器会周期性地溢出并产生中断(或在缓冲区内部记录一个样本),所以你可以更好地了解 what exactly the CPU did while running a loop, for example. But anyway, OProfile has a table of events supported by Haswell,如果你想比较什么样的CPU 可以报告与 GPU 的事件。像 NVidia 一样,有一个 l2_rqsts
的计数器,但与 GPU 不同的是,有 branch-mispredicts 的计数器和 GPU 没有的其他东西。
Driver 事件 包括如下内容:OGL driver sleeping
:"OpenGL Last frame mSec sleeping in OGL driver",或OGL vidmem bytes
"OGL Current amount of video memory (local video memory) allocated in bytes. Drawables and render targets are not counted."
还有像 OGL Frame Primitive Count
和 OGL Frame Vertex Count
这样的简单总计,以查看 driver 发送给 GPU 的总工作量。
Driver 计数器包括 cpu_load
和 cpu_00_frequency
之类的东西,用于跟踪您与 CPU-bound 的距离。
All of the software/driver counters represent a per frame accounting. These counters are accumulated and updated in the driver per frame, so even if you sample at a sub-frame rate frequency, the software counters will hold the same data (from the previous frame) until the end of the current frame.
这些是 high-level driver 在软件中跟踪的东西,而不是 low-level 在硬件中计算并查询以获得总计数的东西请求时。
GPU可能出现的性能问题有很多种,每一种都需要使用不同的性能计数器来识别和分析。您可以将彼得的回答视为起点。我将在这里讨论可供您使用的不同分析工具和库,以及如何开始使用它们。
图书馆
NVIDIA PerfKit 是一个可让您访问性能计数器的库。这意味着您必须编写代码来调用库提供的 API,以测量感兴趣的性能事件。所以使用 PerfKit 可能不是诊断性能问题的最佳方法。总之,你可以在this page. You can download it from here.
底部找到PerfKit的使用指南
CUDA 工具包带有自己的类似库,称为 CUDA 分析工具接口 (CUPTI)。可以找到用户指南 here. These slides 还讨论了如何通过 CUPTI 使用一些性能计数器。
工具
关于如何使用不同工具分析各种问题的CUDA Toolkit comes with two profiling tools, one is a command-line tool, called nvprof and the other is a GUI tool, called the Visual Profiler. These tools are built on top of CUPTI and they are much easier to use since you don't have to write any code (or just a little code), so I think you should use one of these tools. The user guides of both of these tools can be found here. Here is a video on the performance analysis with the Visual Profiler. Here is an introductory article on nvprof. Here are also a bunch of videos。
任何人都很难给你一个具体的答案,因为你不是在问一个具体的问题。但我认为我的回答和 Peter 的回答应该可以帮助您入门。
https://developer.nvidia.com/sites/default/files/akamai/tools/files/PerfKit_4_5_User_Guide.pdf
NVIDIA PerfKit SDK allows graphics developers access to low-level NVIDIA GPU
performance counters and NVIDIA driver counters.
我想了解这些计数器的含义?它们是某种硬件还是软件?他们是做什么的?
它们对我有什么帮助?请给出使用它们的例子。
我必须使用 Nvidia perfkit 来确定某些处理机器人的软件的性能。
It gives you access to low-level performance counters inside the driver and hardware counters inside the GPU itself. The counters can be used to determine exactly how your application is using the GPU, identify performance issues, and confirm that performance problems have been resolved.
这意味着,您可以获得有关应用程序 GPU 使用情况和性能的信息,并用于查找性能问题。
还有一些链接:
- http://www.nvidia.com/object/nvperfkit_home.html
- https://developer.nvidia.com/nvidia-perfkit
- http://docs.nvidia.com/gameworks/index.html#developertools/desktop/linux_graphics_debugger/lgd_perf_counters.htm%3FTocPath%3DDeveloper%2520Tools%7CDesktop%2520Developer%2520Tools%7CLinux%2520Graphics%2520Debugger%7C_____9
我不是图形程序员,所以我将从 computer-architecture 的角度来处理这个问题。我不知道哪些计数器对于查找 3D 图形或 GPU-computing 中的哪种瓶颈特别有用,所以不要读入我选择的计数器作为示例的任何内容。
调用图形函数时,很多繁重的工作都是由专用 GPU 硬件完成的。
但是为了保持 GPU 硬件的运行,主 CPU 上的 driver 软件 运行 必须做重要的工作,有时这可能是一个瓶颈。 "driver counters" 用于跟踪软件正在执行/等待的各种操作,还有用于跟踪 GPU 硬件实际执行操作的硬件计数器。
显卡就像一台带有处理器+内存的独立计算机,但处理器是专门的 GPU,其 instruction-set 专为做 GPU 擅长的事情而设计。但它仍然有自己的时钟并像流水线一样解码/执行指令CPU。 GPU 性能事件可以统计在此硬件上执行的 single-precision 浮点运算的数量。或者为 GPU 访问其自己的内存缓存 hit/miss 事件(它有自己的视频 RAM 缓存)。计数器由硬件 built-in 跟踪到 GPU 管道。
NVidia 的 table 为 GPU hardware events that their hardware tracks。它包括诸如 texture_busy
之类的内容,其中包含 "clock cycles the texture unit is busy"。将其与您分析的时间段的总时钟周期进行比较,可以告诉您纹理单元的硬件吞吐量接近最大化/瓶颈的程度。或 shaded_pixel_count
:发送到着色单元的光栅化像素数。在硬件事件中,它们按 GPU 硬件的哪个部分细分:有一般的“GPU”事件,如“SM “(着色器)事件,如 inst_executed_vs
"Instructions executed by vertex shaders (VS), not including replays.",以及 Cache 事件,如 l1_l2_requests
"Number of L2 requests from the L1 unit."(与 L1 未命中次数高度相关,我假设)。还有 Memory 事件,例如 sm_inst_executed_local_loads
"Local load instructions executed."
(以上示例是“适用于架构早于 Kepler 的 GPU”;事实证明,我发现的第一个 google 命中是针对旧 GPU 的页面。这不会改变基本原理:GPU 事件是 low-level 硬件可以跟踪的东西,但 CPU 上的软件通常不能。它不知道发送时是否会出现缓存未命中为 GPU 工作。)
table 将事件分为 "Graphics" 和 "Compute" API。也许某些事件是由 NVidia 的软件从实际的 HW 计数器合成的。它记录了 NVidia 的开发人员工具可以向您展示的内容,而不是硬件实际上是什么。例如inst_executed_cs_ratio
可能来自执行的计算着色器指令的计数器和执行的总指令的另一个 HW 计数器。
这些硬件性能计数器(可能)的实现非常类似于硬件CPU性能计数器,可以计算时钟周期、指令、微指令、各种停顿微架构资源等。在 x86 CPUs 上,计数器会周期性地溢出并产生中断(或在缓冲区内部记录一个样本),所以你可以更好地了解 what exactly the CPU did while running a loop, for example. But anyway, OProfile has a table of events supported by Haswell,如果你想比较什么样的CPU 可以报告与 GPU 的事件。像 NVidia 一样,有一个 l2_rqsts
的计数器,但与 GPU 不同的是,有 branch-mispredicts 的计数器和 GPU 没有的其他东西。
Driver 事件 包括如下内容:OGL driver sleeping
:"OpenGL Last frame mSec sleeping in OGL driver",或OGL vidmem bytes
"OGL Current amount of video memory (local video memory) allocated in bytes. Drawables and render targets are not counted."
还有像 OGL Frame Primitive Count
和 OGL Frame Vertex Count
这样的简单总计,以查看 driver 发送给 GPU 的总工作量。
Driver 计数器包括 cpu_load
和 cpu_00_frequency
之类的东西,用于跟踪您与 CPU-bound 的距离。
All of the software/driver counters represent a per frame accounting. These counters are accumulated and updated in the driver per frame, so even if you sample at a sub-frame rate frequency, the software counters will hold the same data (from the previous frame) until the end of the current frame.
这些是 high-level driver 在软件中跟踪的东西,而不是 low-level 在硬件中计算并查询以获得总计数的东西请求时。
GPU可能出现的性能问题有很多种,每一种都需要使用不同的性能计数器来识别和分析。您可以将彼得的回答视为起点。我将在这里讨论可供您使用的不同分析工具和库,以及如何开始使用它们。
图书馆
NVIDIA PerfKit 是一个可让您访问性能计数器的库。这意味着您必须编写代码来调用库提供的 API,以测量感兴趣的性能事件。所以使用 PerfKit 可能不是诊断性能问题的最佳方法。总之,你可以在this page. You can download it from here.
底部找到PerfKit的使用指南CUDA 工具包带有自己的类似库,称为 CUDA 分析工具接口 (CUPTI)。可以找到用户指南 here. These slides 还讨论了如何通过 CUPTI 使用一些性能计数器。
工具
关于如何使用不同工具分析各种问题的CUDA Toolkit comes with two profiling tools, one is a command-line tool, called nvprof and the other is a GUI tool, called the Visual Profiler. These tools are built on top of CUPTI and they are much easier to use since you don't have to write any code (or just a little code), so I think you should use one of these tools. The user guides of both of these tools can be found here. Here is a video on the performance analysis with the Visual Profiler. Here is an introductory article on nvprof. Here are also a bunch of videos。
任何人都很难给你一个具体的答案,因为你不是在问一个具体的问题。但我认为我的回答和 Peter 的回答应该可以帮助您入门。