使用 Alea 查找内存泄漏

Finding memory leaks with Alea

我有一些脚本在 运行 一段时间后抛出 Cuda 内存不足异常。在它们内部,我使用的是预分配数组,所以我没想到这会成为问题。然而,在我将脚本转换为 .fs 文件并编译它们之后,探查器对于这项任务并不是特别有用,并且 cuda-memcheck 工具 6.5 (36) 在我使用它时抛出了 CudaInterOp 异常。 cuda-memcheck 7.0 (40) 实际上迫使我在 GPU 耗尽时重置 PC。

我现在有点不确定该做什么。如何使用 Alea 修复漏洞?

设备 reduce 的资源管理的完整用法如下所示:

// first, create module, which has the compilation stuff
use reduceModule = new DeviceReduceModule<float>(Target, <@ (+) @>) 
// second, create a reduce object, which contains temp memory for that maxItems
use reduce = reduceModule.Create(maxItems)
// third, allocate your device memory for input
use numbers = reduce.AllocateStreamBuffer(xxx)
// now you can scatter data and do reduce
numbers.Scatter(your data)
reduce.Reduce(numbers)
// now because you are using "use" keyword, the dispose() will be called implicitly