Created
June 26, 2015 21:12
-
-
Save bmyerz/a5e15d76ca94ebd7c58b to your computer and use it in GitHub Desktop.
Iterator for symmetric allocated vectors
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
template <GlobalCompletionEvent* GCE=&impl::local_gce, typename T, typename F> | |
void forall(GlobalAddress<aligned_vector<T>> symmetric_array, F loop_body) { | |
auto origin = mycore(); | |
GCE->enroll(cores()); | |
on_all_cores([=] { | |
auto num_elements = symmetric_array->vector.size(); | |
forall_here<SyncMode::Async,GCE>( 0, num_elements, [=](int64_t start, int64_t iters) { | |
for (int64_t j=start; j<start+iters; j++) { | |
auto el = symmetric_array->vector[j]; | |
loop_body(el); | |
} | |
}); | |
GCE->send_completion(origin); | |
GCE->wait(); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment