Cudagrind:Valgrind对CUDA的扩展
Cudagrind: A Valgrind Extension for CUDA
摘要:
Valgrind,特别是包含的工具Memcheck,提供了一种简单可靠的方法来检查程序中内存操作的正确性。这以一种非侵入性的方式工作,Valgrind将程序转换为中间代码,并在仿真CPU上执行。重量级工具Memcheck使用它来保存程序使用的内存的完整影子副本并跟踪对它的访问。这允许检测内存泄漏并检查访问的有效性。虽然适用于各种各样的程序,但当涉及基于加速器的编程模型时,这种方法仍然失败。在这些设备上运行的代码与在主机上运行的代码是分开的。对设备内存的访问和内核的启动由正在使用的驱动程序提供的API处理。因此,Valgrind无法理解器械上正在运行的仪器操作。为了规避这个限制,引入了一组新的包装函数。这些封装了CUDA驱动程序API函数的一个子集,该函数负责在设备上分配(取消)内存区域以及相应的内存复制操作。这允许检查内存是否在传输过程中完全分配,以及通过Valgrind提供的功能,从主机传输到设备的内存是否已定义和可寻址。通过这种技术,可以检测到许多常见的编程错误,这些错误很难通过其他方式进行调试。这些包装器与Valgrind工具Memcheck的组合被称为Cudagrind。
英文摘要:
Valgrind, and specifically the included tool Memcheck, offers an easy and reliable way for checking the correctness of memory operations in programs. This works in an unintrusive way where Valgrind translates the program into intermediate code and executes it on an emulated CPU. The heavy weight tool Memcheck uses this to keep a full shadow copy of the memory used by a program and tracking accesses to it. This allows the detection of memory leaks and checking the validity of accesses. Though suited for a wide variety of programs, this approach still fails when accelerator based programming models are involved. The code running on these devices is separate from the code running on the host. Access to memory on the device and starting of kernels is being handled by an API provided by the driver being used. Hence Valgrind is unable to understand and instrument operations being run on the device. To circumvent this limitation a new set of wrapper functions have been introduced. These wrap a subset of the CUDA Driver API function that is responsible for (de-)allocation memory regions on the device and the respective memory copy operations. This allows to check whether memory is fully allocated during a transfer and, through the functionality provided by Valgrind, whether the memory transfered to the device from the host is defined and addressable. Through this technique it is possible to detect a number of common programming mistakes, which are very difficult to debug by other means. The combination of these wrappers together with the Valgrind tool Memcheck is being called Cudagrind.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。