Skip to main content
Became Hot Network Question
added 299 characters in body
Source Link
seva011
  • 356
  • 1
  • 9

Assume I have 10 cores in a CPU. And I run ParallelMap on them:

LaunchKernels[10];
ParallelMap[F1,L1];

where L1 is a list of the dimension {10,1} and F1 is whatever function. Thus, all 10 cores start working hard computing F1, each core computes F1 for a pointed element in L1. The issue is that each of the cores finish its work in their own time, and when some are being idle with finished tasks, the others continue computing.

Now, assume, I have to compute several sequent ParallelMaps commands:

LaunchKernels[10];
ParallelMap[F1,L1];
ParallelMap[F2,L2];
...

With such the order of commands, Mathematica implements the lines step by step and cannot run the second ParallelMap until all elements in the first become computed. (Please, see UPD below)

Are there ways to load the idle cores with the second task, not waiting for the ending of the first one? I can assign 5 cores for “task 1” and 5 for “task 2”, but I am sure there are more efficient and elegant ways.

P.S. I am pretty new in Mathematica, and might not know the propper nomenclature and key words. Please, refer me to the topics I duplicate or comment here.

UPD After @Domen 's response below, I have to specify the condition: I would like to have access to the output of the finished calculations made with ParallelMap[F1,L1], while ParallelMap[F1,L1] is still being run.

Assume I have 10 cores in a CPU. And I run ParallelMap on them:

LaunchKernels[10];
ParallelMap[F1,L1];

where L1 is a list of the dimension {10,1} and F1 is whatever function. Thus, all 10 cores start working hard computing F1, each core computes F1 for a pointed element in L1. The issue is that each of the cores finish its work in their own time, and when some are being idle with finished tasks, the others continue computing.

Now, assume, I have to compute several sequent ParallelMaps commands:

LaunchKernels[10];
ParallelMap[F1,L1];
ParallelMap[F2,L2];
...

With such the order of commands, Mathematica implements the lines step by step and cannot run the second ParallelMap until all elements in the first become computed.

Are there ways to load the idle cores with the second task, not waiting for the ending of the first one? I can assign 5 cores for “task 1” and 5 for “task 2”, but I am sure there are more efficient and elegant ways.

P.S. I am pretty new in Mathematica, and might not know the propper nomenclature and key words. Please, refer me to the topics I duplicate or comment here.

Assume I have 10 cores in a CPU. And I run ParallelMap on them:

LaunchKernels[10];
ParallelMap[F1,L1];

where L1 is a list of the dimension {10,1} and F1 is whatever function. Thus, all 10 cores start working hard computing F1, each core computes F1 for a pointed element in L1. The issue is that each of the cores finish its work in their own time, and when some are being idle with finished tasks, the others continue computing.

Now, assume, I have to compute several sequent ParallelMaps commands:

LaunchKernels[10];
ParallelMap[F1,L1];
ParallelMap[F2,L2];
...

With such the order of commands, Mathematica implements the lines step by step and cannot run the second ParallelMap until all elements in the first become computed. (Please, see UPD below)

Are there ways to load the idle cores with the second task, not waiting for the ending of the first one? I can assign 5 cores for “task 1” and 5 for “task 2”, but I am sure there are more efficient and elegant ways.

P.S. I am pretty new in Mathematica, and might not know the propper nomenclature and key words. Please, refer me to the topics I duplicate or comment here.

UPD After @Domen 's response below, I have to specify the condition: I would like to have access to the output of the finished calculations made with ParallelMap[F1,L1], while ParallelMap[F1,L1] is still being run.

edited title
Link
user64494
  • 29.1k
  • 4
  • 29
  • 56

Effecticve Effective use of idle cores when useusing parallelization

Minor typos.
Link
E. Chan-López
  • 31.1k
  • 3
  • 29
  • 50

Effecticve use of idle cores when use parallizationparallelization

edited title
Link
user64494
  • 29.1k
  • 4
  • 29
  • 56
Loading
Source Link
seva011
  • 356
  • 1
  • 9
Loading