I'm starting in haskell parallelism, I've successfully learned how to use some Strategies like : r0, rseq, rdeepseq, parList, parMap
. Now I'm looking further for more efficiency. So here is my question : What is the difference between parList
and parBuffer
? In which cases each strategie is efficient ?
相关问题
- multidplyr : assign functions to cluster
- Understanding do notation for simple Reader monad:
- Making Custom Instances of PersistBackend
- Haskell: What is the differrence between `Num [a]
- applying a list to an entered function to check fo
相关文章
- Is it possible to write pattern-matched functions
- Haskell underscore vs. explicit variable
- How to use doMC under Windows or alternative paral
- Top-level expression evaluation at compile time
- Stuck in the State Monad
- Parallel while loop in R
- foldr vs foldr1 usage in Haskell
- Does gfortran take advantage of DO CONCURRENT?
The paper mentions both these combinators (link here).
parList
evaluates all the items in parallel, setting them all off at once. I'd suggest that this is useful when you want to consume the entire list at once, for example in a map-fold problem. If you want to evaluate a bunch of numbers then sum them, useparList
for the evaluation, then perform the sum.parBuffer
evaluates the first n elements, and when you consume beyond that, it sets off the next n, and so on. SoparBuffer
makes sense when you are going to consume the list in chunks, starting at the beginning -- or when the list is very large (or infinite) and you won't evaluate it all. For example, if you want to find the first 10 answers from some list of expensive-to-calculate items, you can usetake 10 . filter f
withparBuffer
to parallel-evaluate consecutive chunks from the list until you've found the first ten items that you're looking for.