运行时 GPGPU CUDA 内存使用统计

GPGPU CUDA memory usage statistics at runtime

如何在运行时在 CUDA C++ 中访问和输出所有类型内存的内存统计信息(已用内存、可用内存)?

全局内存、纹理内存、共享内存、本地内存、寄存器(常量内存?)

奖金问题:你能给我指出如何使用 Windows CUDA 分析器工具进行操作的文档吗?是所有卡都支持内存分析,还是只有一些特定型号可以做到?

要运行时间检查设备上的整体内存使用情况,请使用cudaMemGetInfo API. Note that there is no such thing as dedicated texture memory on NVIDIA devices. Textures are stored in global memory and there is no way to separately account for them using any of the CUDA APIs that I am aware of. You can also programmatically inquire about the size of runtime components which consume global memory (runtime heap, printf buffer, stack) using the cudaDeviceGetLimit API。

常量内存是在编译时静态分配的,您可以通过compile time switches.

获取特定翻译单元的常量内存使用情况

据我所知,无法在 运行 时间动态检查 SM 级资源使用情况(寄存器、共享内存、本地内存)。您可以使用 cudaFuncGetAttributes API.

在 运行 时间查询特定内核函数的每个线程和每个块的资源需求

Visual 分析器可以在其 detail view 中显示在 运行 时间收集的相同信息。我不是 visual profiler 的大用户,所以我不确定它是否在 运行 期间动态收集设备级内存使用情况。我当然不记得看到过类似的东西,但这并不意味着它不存在。