Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fastest way to run a perfect binary tree #3

Open
cheng-hsiang-chiu opened this issue Apr 5, 2023 · 0 comments
Open

Fastest way to run a perfect binary tree #3

cheng-hsiang-chiu opened this issue Apr 5, 2023 · 0 comments

Comments

@cheng-hsiang-chiu
Copy link

Hello,

I am using OpenCilk to run a DAG of a perfect binary tree, shown in the following.
DAG
Each node performs some computations and edges are the dependencies between nodes.

To run the DAG, I write the following code,
std::vector results(7);
for (size_t l = 0; l <= 2; ++l) {
if (l == 0) {
results[l] = computation(l);
}
else {
int count = std::pow(2, l);
for (int c = 0; c < count; ++c) {
cilk_spawn compuation(results[count-1+c]); // e.g. node t3 needs the data stored in results[1]
}
cilk_sync;
}
}

The code does a level synchronization.
For example in the figure above, node t1 and node t2 must complete before nodes t3-t6 start.
However, this implementation is not the fastest way to run the above DAG because node t2 can run in parallel with t3 and t4.
How do I modify the code to achieve a higher parallelism? Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant