Hi I'm going to code a GPU based version of Dijkstra search, and since I have just started Learning C++ AMP my knowledge is quite limited.
I guess there is a simple answer, but here goes:
//Create GPU array views of the data array_view<const size_t, 1> V(n_nodes, v); //All vertices (nodes) array_view<const size_t, 2> E(n_nodes, nn, e); //All edges array_view<const size_t, 2> W(n_nodes, nn, w); //Weights array_view<int, 1> M(n_nodes, m); //Mask array array_view<float, 1> C(n_nodes, c); //Cost array array_view<float, 1> U(n_nodes, u); //Updating cost array // Run the following code on the GPU // --------------------------------- //while M not Empty do (or while there are still some M[idx] == 1) // { parallel_for_each(V.extent, [V, E, W, M, C, U] (index<1> idx) restrict(amp) { if (M[idx] == 1) { //Update cost in C and U //Update mask array M, setting several more M[newIdx] = 1; //Think of it as a wavefront propagating in all direction through the graph } }); //Wait for all threads to finish updating M. // I do not want to copy back to CPU between iterations! // } // ------------- (end GPU code)
As you can see from the code above what I want to acomplish is to iterate on the GPU, performing some sort of while loop (see comments in code). For each iteration I want to perform a parallel execution over all vertices (V) in my graph, then wait until all threads are finished updating the Mask array (M), and then perform the next iteration.
So my question is how can I perform the iterations on the GPU. I dont want to copy Mask array(M) between the GPU and CPU between each operation. I just want to use the updated Mask array on the GPU in the next iteration. How can I perform something like
the while loop indicated in the code comments above?