1.1. Focused Profiling
不需要对程序做任何修改就可以进行profiling,说明依赖的是GPU上的硬件计数器等等,和程序无关。但是可以通过一些开始和结束标识来标记profiling开始和结束的位置,来达到更好的效果,几种典型的场景适合这种固定区域的profiling:
event nvprof –query-events,事件是一种硬件计数器,在kernel运行期间不断累计;
metric nvprof –query-metrics 度量是根据一种或多种计数器计算得到的该kernel特有的运行特征
1.2 Marking Regions of CPU Activity
Visual Profiler可以看到所有cpu线程如何调用cuda kernel,为了看到CPU线程在执行GPU函数之外的执行轨迹,需要使用NVIDIA Tools Extension API (NVTX)来修改应用程序,nvprof同样支持。
1.3. Naming CPU and CUDA Resources
You can use the NVIDIA Tools Extension API to assign custom names for your CPU and GPU resources. Your custom names will then be displayed in the Timeline View.
1.4. Flush Profile Data
性能数据默认收集到缓存中,以低优先级落盘,为防止性能数据没及时下盘。可以在所有线程退出之前,调用cuProfilerStop() 强制刷盘。
https://docs.nvidia.com/cuda/profiler-users-guide/index.html#profiling-overview
https://docs.nvidia.com/cuda/cupti/r_main.html#r_main
图形界面,可以看到程序运行的性能测量结果。很强大,很多功能,需要具体下载下来使用一次才能体会。具体TODO:
命令行,可以分析程序运行的性能测量结果。默认输出到std::err,可以用–log-file看来做重定向。
有非常多的options,cuda/cpu/print/IO 等等options,还有一些执行模式和控制模式可以指定。具体TODO,需要每个指令尝试一下,或者才有需要的时候可以查询解决问题。
You can profile your remote application directly from nsight or the Visual Profiler.
Or you can use nvprof to collect the profile data on the remote system and then use nvvp on the host system to view and analyze the data.
TODO尝试运行一次
提供API接口,完成两个功能
TODO
MPI程序也可以使用nvprof来进行性能分析。
mpirun -np 2 nvprof –annotate-mpi openmpi ./my_mpi_app
TODO
You can collect profiling data for a CUDA application using Multi-Process Service(MPS) with nvprof and then view the timeline by importing the data in the Visual Profiler.
TODO
没特别理解什么意思。大概是说程序中不同的片段彼此之间的依赖关系,可以通过这个工具进行分析。
TODO
根据硬件事件计数器计算得到的一些性能衡量指标。可根据实际情况进行查询。