I have a particular code that I have to run over several different parameters. I am using ParallelDo to parallelize the process. Due to the nature of the evaluations some Kernels finish the evaluations much before the others. After that I print the data generated by that Kernel to a file and the Kernel becomes idle. Is there any way to free up the Kernel so that I can use it for a future evaluation?

If you are curious about why some Kernels finish the work before others, it's because I have to solve a differential equation for a fixed number of time periods, say N, but the parameter is the frequency, hence some time periods are much larger than the other and hence take longer to evaluate.

  • 1
    $\begingroup$ As a start, you should set Method -> "FinestGrained". This way, you will get a result faster and less time will be spent with few kernels active. Doing what you ask does not seem easy. Perhaps with ParallelSubmit, but I do not have an immediate solution. $\endgroup$
    – Szabolcs
    May 22 '20 at 16:18
  • $\begingroup$ I read up a bit on this, and it seems that this way the distribution is such that Mathematica always uses the maximum number of Kernels possible. This is a possible solution, I will check. Though I was thinking of identifying which Kernel process is completed and closing that Kernel by CloseKernels[n]. Because if I am not mistaken the Kernels have a unique number during the evaluation, but will it make the code unstable? $\endgroup$ May 23 '20 at 6:16
  • $\begingroup$ You cannot do that from ParallelDo. It might be possible if you micro-manage parallelization with ParallelSubmit. $\endgroup$
    – Szabolcs
    May 23 '20 at 7:52
  • $\begingroup$ I see thanks. Will try this. $\endgroup$ May 29 '20 at 5:23

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.