Thursday, April 12, 2012 4:05 PM
I'm experimenting with C++ AMP and the code below is giving me trouble. It gets compiled to a DLL and called from a C# app. I'm calling the function in a loop (in C#), and that works fine as long as the number of iterations is low. Then I hit some limit and calling the function again will give an error.
What's really strange is that if I create the array without specifying accelerator views (just the extent), it seems to work fine for any number of iterations.
What's going on here?
static array<float, 2> *inputArrayPtr;
extern "C" __declspec ( dllexport ) void _stdcall CopyMyData(
float* input, int m, int n)
concurrency::extent<2> inEx(m, n);
inputArrayPtr = NULL;
inputArrayPtr = new array<float, 2>(inEx, cpuAccelerator.default_view, defaultAccelerator.default_view);
Thursday, April 12, 2012 9:46 PMOwner
This seems to be due to a known issue in some GPU drivers - even on deleting staging arrays, the driver chooses to be lazy about the deletion and eventually runs out of memory. We have addressed this issue in the C++ AMP runtime since Beta.
For now, a potential workaround would be to call "defaultAccelerator.default_view.flush()" after deleting the "inputArrayPtr". Can you try this to see if it helps?
Amit K Agarwal
Friday, April 13, 2012 1:13 PM
Thanks for the info, Amit.
I tried "defaultAccelerator.default_view.flush()" as you suggested, but I still got the error. Then I replaced that call with "defaultAccelerator.default_view.wait()" and now my code runs for any number of iterations.
My original problem is solved, but now I'm wondering why wait() works and flush() does not. Is flush() asynchronous?
- Marked As Answer by tevo Friday, April 13, 2012 1:13 PM
Friday, April 13, 2012 8:00 PMOwner
Tevo, you are right. This appears to be an issue with NVidia drivers only. Thanks for reporting it - we will bring this issue to their attention. "flush" is expected to synchronously delete any released device resources (staging buffer in your case) as described here.
Amit K Agarwal
- Marked As Answer by tevo Friday, April 13, 2012 8:30 PM