this is a highly theoretical question about my parallelization approach.
First of all, I want to inform everybody that I do not claim that I am the 'inventor' of that approach but I couldn't find any information about something like that.
I will explain my idea through example.
I assume that every task that is a dependency of dress-up pizza task is CPU bounded, so I make sense to execute it on another thread
Usually approach
- Compute dependencies of dress-up pizza on other threads
- Join every thread
- Execute Dress up pizza task
I got the idea that if we don't care about which thread is executing the dress-up pizza task we can avoid joining threads simply by executing that task on a thread that finishes last.
We could store the result of every task on struct with an additional field for the atomic counter.
Pseudo-code example
struct pizza_dependencies {
cheese,
olives,
dough,
counter
}
fn grate_the_cheese(dependencies){
dependencies.cheese = cheese
if dependencies.counter == 2 {
dress_up_pizza(dependencies)
} else {
couter += 1
}
}
The rest of the tasks would be implemented the same way. Counter by default is 0.
- What would be the advantages/disadvantages of such an approach?
- Is there any better/faster way of doing this?
- Is some research/project using a similar approach?
I really want to know what do you think about my idea, have a great day :)