I decided to use the new lazily allocated array_view in VS2013, but there seems to be a synchronization problem with derived views. My root view is linear to allow reshaping and other operations that can only be done on rank 1 views.
If I create a linear view and a derived shaped view, then initialize through the shaped view, the modification is not synchronized with the linear view. I think the problem is that the linear view has not been lazily initialized anywhere yet, so the AMP runtime is not connecting them, even though they do seem to have the same master buffer pointer. After initialization, if I use the linear view in a parallel_for_each, it's just all 0's. Things like synchronize and refresh don't seem to make any difference.
Am I missing something?
Thanks, Ed
Consider:
#include <amp.h> using namespace concurrency; int _tmain(int argc, _TCHAR* argv[]) { array_view<float, 1> linear_view(6); array_view<float, 2> shaped_view = linear_view.view_as(extent<2>(3, 2)); // shaped initialize on CPU for (int i = 1, r = 0; r < shaped_view.extent[0]; ++r) { for (int c = 0; c < shaped_view.extent[1]; ++c) { shaped_view(r, c) = (float)i++; } } // linear operation, we'll just do a simple copy array_view<float, 1> result(linear_view.extent); parallel_for_each(result.extent, [=](index<1>& idx) restrict(amp) { result[idx] = linear_view[idx]; }); // these should all be 1.0 float lval = linear_view(0); // 1.0 good float sval = shaped_view(0, 0); // 1.0 good float rval = result(0); // 0.0 NOT GOOD!!, should be 1.0 return 0; }