1
$\begingroup$

Is there any chance to make the solution by @David here

https://mathematica.stackexchange.com/a/1562/21606

more robust in the following sense: In my case, some parallel kernels die regularly during intensive computation. Of course, the newly resurrected ones are not part of kernels - leading to a bunch of warnings every now and then. Is it somehow possible to update the list kernels kind of dynamically everytime a new kernel appears (which is only if a kernel died and is resurrected)?

For completeness I will just copy paste the code from the original answer.

(* Pattern that translates the kernel's ID to
   a number from 1 to $KernelCount *)
kernels = ParallelTable[$KernelID -> i, {i, $KernelCount}];
SetSharedVariable[kernels]; (* for Mathematica 7 *)

(* This is the list that will display each kernel's current operation *)
SetSharedVariable[currentNumber]
currentNumber = ConstantArray[0, Length@kernels];

PrintTemporary["Current calculations:"];
PrintTemporary@Dynamic[currentNumber];

(* Start the computation *)
ParallelTable[
    Pause@RandomReal[{0, .25}]; (* Long calculation *)
    currentNumber[[$KernelID /. kernels]] = i,
    {i, 100},
    Method -> "FinestGrained"
]
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.