你如何配置文件 &优化 CUDA 内核? [英] How Do You Profile & Optimize CUDA Kernels?

查看:27
本文介绍了你如何配置文件 &优化 CUDA 内核?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对 CUDA 可视化分析器和占用电子表格有些熟悉,尽管我可能没有尽可能地利用它们.分析和优化 CUDA 代码不像分析 &优化在 CPU 上运行的代码.因此,我希望从您的经验中学习如何充分利用我的代码.

I am somewhat familiar with the CUDA visual profiler and the occupancy spreadsheet, although I am probably not leveraging them as well as I could. Profiling & optimizing CUDA code is not like profiling & optimizing code that runs on a CPU. So I am hoping to learn from your experiences about how to get the most out of my code.

最近有一篇帖子在寻找最快的代码来识别自我编号,并且我提供了一个 CUDA 实现.我对这段代码的速度并不满意,但我不知道正确的问题是什么以及我可以从什么工具中获得答案.

There was a post recently looking for the fastest possible code to identify self numbers, and I provided a CUDA implementation. I'm not satisfied that this code is as fast as it can be, but I'm at a loss as to figure out both what the right questions are and what tool I can get the answers from.

您如何确定使您的 CUDA 内核执行得更快的方法?

How do you identify ways to make your CUDA kernels perform faster?

推荐答案

如果您在 Linux 上进行开发,那么 CUDA Visual Profiler 会为您提供大量信息,但知道如何处理它可能有点棘手.在 Windows 上,您还可以使用 CUDA Visual Profiler,或者(在 Vista/7/2008 上)您可以使用 Nexus,它与 Visual Studio 完美集成,并为您提供组合的主机和 GPU 配置文件信息.

If you're developing on Linux then the CUDA Visual Profiler gives you a whole load of information, knowing what to do with it can be a little tricky. On Windows you can also use the CUDA Visual Profiler, or (on Vista/7/2008) you can use Nexus which integrates nicely with Visual Studio and gives you combined host and GPU profile information.

获得数据后,您需要知道如何解释它.GTC 的 Advanced CUDA C 演示文稿提供了一些有用的提示.需要注意的主要事项是:

Once you've got the data, you need to know how to interpret it. The Advanced CUDA C presentation from GTC has some useful tips. The main things to look out for are:

  • 最佳内存访问:您需要知道您希望代码做什么,然后查找异常.因此,如果您总是加载浮点数,并且每个线程从数组加载不同的浮点数,那么您将只看到 64 字节的加载(在当前的硬件上).任何其他负载都是低效的.分析信息可能会在未来的硬件中得到改进.
  • 最小化序列化:warp serialize"计数器表明您有共享内存库冲突或持续序列化,演示文稿更详细地介绍了如何处理此问题,SDK 也是如此(例如减少示例)
  • 重叠 I/O 和计算:这是 Nexus 真正闪耀的地方(您可以使用 cudaEvents 手动获取相同的信息),如果您有大量数据传输,您希望重叠计算和 I/O
  • 执行配置:占用率计算器可以帮助解决这个问题,但简单的方法,比如评论计算以衡量预期带宽和实测带宽确实很有用(反之亦然对于计算吞吐量)

这只是一个开始,请查看 NVIDIA 网站上的 GTC 演示和其他网络研讨会.

This is just a start, check out the GTC presentation and the other webinars on the NVIDIA website.

这篇关于你如何配置文件 &优化 CUDA 内核?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆