Skip to content

Instantly share code, notes, and snippets.

@bmyerz
Created June 26, 2015 21:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bmyerz/a5e15d76ca94ebd7c58b to your computer and use it in GitHub Desktop.
Save bmyerz/a5e15d76ca94ebd7c58b to your computer and use it in GitHub Desktop.
Iterator for symmetric allocated vectors
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