2
$\begingroup$

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*)
$\endgroup$

1 Answer 1

2
$\begingroup$

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 = ...]
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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