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've a construct that reads

ParallelTable[
 MyFunction[i],
 {i, 16}
]

Now, MyFunction[i] takes an amount of time to be evaluated which is a decreasing function of i. When I evaluate with multiple kernels however, mathematica assigns close values of i to the same kernels. In this example it has assigned i=1,2 to kernel 8 and i=3,4 to kernel 7, and this is of course not optimized at all. Out of 8 cores I get a speedup of only 2.49 which is quite unsatisfactory, due to the fact that a huge part of the work was made by 2 kernels leaving the other 6 with a relatively low load.

Parallel Kernel Status screenshot at the end of the evaluation

Is there a way to explicitly assign values of i to the kernels?

share|improve this question
1  
Try using Method -> "FinestGrained" option in ParallelTable. Alternatively, you could randomize your iterator, like ParallelTable[MyFunction[i], {i, RandomSample[Range[16]]}], and then reorder the result back. –  Leonid Shifrin Oct 9 '13 at 14:16
add comment

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.