Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I have an associative binary operation '.', which I often use in this sort of way:

result = expr1 . expr2 . expr3 . expr4

The '.' operation is very fast, but the individual subexpressions are often hard to compute. So I would like my '.' operation to automatically parallelize itself, evaluating each of the separate subexpressions in separate kernels before finally taking the results and actually performing the operation.

How can I achieve this in Mathematica? It seems there are several challenges. One is to prevent the subexpressions evaluating before the '.' operation is evaluated.

share|improve this question
    
Why don't you evaluate the subexpression in parallel first, and perform the . only afterwards? I don't understand why you need to couple these two things. Fold[myDot, dotIdentity, Parallelize[{expr1, expr2, expr3, expr4}]] –  Szabolcs Oct 16 '13 at 18:02
    
Because I use this everywhere. Having to separately parallelize everything would be a real pain. –  Jamie Vicary Oct 16 '13 at 18:04
    
I think Parallelize should be able to handle this properly if your . has attribute Flat, but I'm not 100% sure. Otherwise try ParallelCombine[Identity, Unevaluated[expr1.expr2.expr3.expr4]]. Search for "associative operations" here. –  Szabolcs Oct 16 '13 at 18:14
add comment

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.