内循环就是一个求两个距离再IF判断距离符合要求值么符合就记住。据说可以用C++AMP,但不怎么会这个,求指点!
3条回答 默认 最新
关注 这个得看你的需求,使用AMP的话, 得结合实际需求,比如:
#include
#include
using namespace concurrency;const int size = 5;
void CppAmpMethod() {
int aCPP[] = {1, 2, 3, 4, 5};
int bCPP[] = {6, 7, 8, 9, 10};
int sumCPP[size];// Create C++ AMP objects. array_view<const int, 1> a(size, aCPP); array_view<const int, 1> b(size, bCPP); array_view<int, 1> sum(size, sumCPP); sum.discard_data(); parallel_for_each( // Define the compute domain, which is the set of threads that are created. sum.extent, // Define the code to run on each thread on the accelerator. [=](index<1> idx) restrict(amp) { sum[idx] = a[idx] + b[idx]; } ); // Print the results. The expected output is "7, 9, 11, 13, 15". for (int i = 0; i < size; i++) { std::cout << sum[i] << "\n"; }
}
解决 无用评论 打赏 举报