我刚读到这个:
由于Concurrency::completion_future
似乎模仿的功能std::future
我认为我可以做类似的事情,但这个相对简单的例子失败了:
#include <assert.h>
#include <chrono>
#include <iostream>
#include <amp.h>
int main()
{
using namespace Concurrency;
int big = 1000000; // this should take a while to send back to the host
array_view<int> av(big);
parallel_for_each(extent<1>(big), [=](index<1> idx) restrict(amp)
{
av[idx] = idx[0];
});
int i = 0;
completion_future future = av.synchronize_async();
// this should be false; how could it instantly sent back so much data?
bool const gpuFinished = future.wait_for(std::chrono::seconds(0)) == std::future_status::ready;
assert(!gpuFinished); // FAIL! why?
future.wait();
system("pause");
}
为什么这个断言会失败?