[concurrency-interest] Fork/Join Use cases

Aleksandar Prokopec aleksandar.prokopec at gmail.com
Fri Dec 12 03:37:11 EST 2014


Hi Richard,

I always found fork/join to be a very foundational, and serving as a solid thread pool implementation that works really well, and doesn't blow up, which the JDK otherwise lacked. In many cases it serves as a building block for other frameworks, since one of the advantages is that all the other abstractions can optionally share the same computational resources. But since you said that you're not interested in futures, parallel collections, Rx, actors...

For concrete code, one of the applications that comes to mind is parallel sorting. You might want to search for Doug Lea's parallel array implementation to see it.
Otherwise, I'm sure you could easily use fj to implement minimax algorithms for chess AI, a constraint solving problem, typechecking in a compiler, or concurrently issuing a request to several web services.
It's maybe not the best for the continuously running applications such as simulation engines, or streaming applications, which need to react to requests or continuously produce output as part of a pipeline, but as soon as you can identify a bulk of computation with finite batches of work that can be parallelized, it's likely to be a good candidate for fork/join parallelization.

To find more use cases, it might make sense to search for online examples of Cilk code, as it was one of the first to employ the fork/join model.

Richard Warburton <richard.warburton at gmail.com> wrote:
>Hi,
>
>Something I have noticed with fork/join is the absence of clear-cut and
>common motivating examples and use cases. Many times people provide
>examples of fork/join code that only solves a simple problem. For
>example
>calculates Fibonacci numbers or performs a merge sort. This is great
>for
>the educational purpose of understanding the API but isn't so
>convincing of
>the efficacy of fork/join as a general parallel programming framework.
>
>What I would like to see is an example of a more complex use of fork
>join.
>For example something like training a neural network. Now its that I
>can't
>see how such a problem don't fit into the fork/join model - but the
>question is why one would conclude it to be such a general model as to
>warrant inclusion into Java SE. Other than problems whose algorithms
>naturally follow a recursive structure (eg fibonacci) everytime I try
>to
>fit a parallel programming problem into the fork/join model in my head
>it
>doesn't seem to offer me much over the ability to run a series of
>parallel
>threads.
>
>I'm ruling out the simpler problems alone because implementing such
>tasks
>in parallel is often not difficult enough to warrant a framework or of
>particular use. I'm not looking for:
>
>a. Other parallel programming frameworks which depend upon fork/join
>(eg:
>parallel streams). I'm asking for actual direct application level usage
>of
>fork/join.
>
>b. Other models - I'm just asking about fork/join.
>
>c. Fitting problems into fork/join which can be made to work but either
>have as code that's as complex as using threads or have poor
>performance.
>The ideal example would have also some kind of open source code with
>comparisons in other approaches, but I appreciate I'm asking for a lot
>here
>when trying to satisfy my own understanding.
>
>regards,
>
>  Richard Warburton
>
>  http://insightfullogic.com
>  @RichardWarburto <http://twitter.com/richardwarburto>
>
>
>------------------------------------------------------------------------
>
>_______________________________________________
>Concurrency-interest mailing list
>Concurrency-interest at cs.oswego.edu
>http://cs.oswego.edu/mailman/listinfo/concurrency-interest

-- 
Sent from my Android phone with K-9 Mail. Please excuse my brevity.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://cs.oswego.edu/pipermail/concurrency-interest/attachments/20141212/fa304d80/attachment-0001.html>


More information about the Concurrency-interest mailing list