// Simple test showing how to use HC syntax with array_view. // The code uses AMP's array_view class, which provides automatic data synchronization // of data between the host and the accelerator. As noted below, the HCC runtime // will automatically copy data to and from the host, without the user needing // to manually perform such copies. This is an excellent mode for developers // new to GPU programming and matches the memory models provided by recent systems where // CPU and GPU share the same memory pool. Advanced programmers may prefer // more explicit control over the data movement - shown in the other vadd_hc_array and // vadd_hc_am examples. // This example shows the similarity between C++AMP and and HC for simple cases where // implicit data transfer is used - really the only difference is the namespace. // Other examples show some of the more advanced controls. #include int main(int argc, char *argv[]) { int sizeElements = 1000000; bool pass = true; // Allocate auto-managed host/device views of data: hc::array_view A(sizeElements); hc::array_view B(sizeElements); hc::array_view C(sizeElements); // Initialize host data for (int i=0; i (sizeElements), [=] (hc::index<1> idx) [[hc]] { int i = idx[0]; C[i] = A[i] + B[i]; }); for (int i=0; i