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.

Short question: How can you set $IterationLimit for parallel computation?

I thought just setting $IterationLimit = Infinity would work but it doesn't. I still get Iteration limit exceeded errors. A bit of sample code below:

fff[0] = 1;
fff[p_] := fff[p - 1] (*simple function*)
limit = $IterationLimit (*checking $IterationLimit*)

fff[limit + 1000] (*this should give $IterationLimit::itlim error*)

ParallelTable[fff[i], {i, limit + 1000, limit + 1004}] (*this should also give multiple $IterationLimit::itlim errors*)

$IterationLimit = Infinity; (*setting infinite $IterationLimit*)

fff[limit + 1000] (*now this should compute without errors*)

ParallelTable[fff[i], {i, limit + 1000, limit + 1004}] (*this shouldn't give any errors either but for me it throws $IterationLimit::itlim errors*)
share|improve this question
add comment

1 Answer 1

up vote 1 down vote accepted

When using parallelization in Mathematica, it is very important to understand that the "parallel threads" are completely separate kernel processes. Assume that any communication between the main kernel and subkernels needs to be explicit (though there is some automation since version 8: DistributeDefinitions is done automatically in many cases).

Since fff is defined by you, the user, in the Global` context, the definition of fff is automatically distributed to the subkernels (in v8 and later) by ParallelTable and you don't need to use DistributeDefinitions explicitly. However, $IterationLimit is a system symbol, and it won't be distributed.

If you set $IterationLimit on the main kernel, it will only have an effect on the main kernel.

The subkernels have their own $IterationLimit which you need to set separately with the aid of ParallelEvaluate. (Do not use DistributeDefinitions in this case.)

ParallelEvaluate[$IterationLimit = ...]
share|improve this answer
add comment

Your Answer

 
discard

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.