Info

This question is closed. Reopen it to edit or answer.

When working with, e.g., two parallel processes, with the PCT, is the RAM memory partitioned in two?

1 view (last 30 days)
Giovanni De Luca
Giovanni De Luca on 7 Dec 2013
Closed: MATLAB Answer Bot on 20 Aug 2021
Hi. Assuming I have a function my_fnc with input parameters two very-large size matrices A and B , and a (column) vector vec of two elements, and the function returns a scalar. I want to execute it in parallel with the PCT, calling two parallel workers:
C=cell(1,2);
parfor i=1:2
sc = my_fnc( A,B,vec(1,i) );
C(1,i) = {sc};
end
This is just an example, I know the index of the parfor should be greater.. Then, I wonder:
  1. Before starting the computation by the two workers, is the RAM memory, available for MATLAB, partitioned into two, as the number of called workers, in order to assign each of them the memory resources? If it is, is it done just when calling the matlabpool open 2 command?
  2. Are the matrices A and B sent serially (in time) to each workers? I mean, first A, B and vec(1,1) are sent to worker1 (corresponding to the parfor index i=1) and secondly A, B and vec(1,2) to worker2, or vice versa (I know the order is not relevant). Or the other way around: assuming A and B won't be modified into my_fnc, and MATLAB recognizes it, can A and B be read at the same time by the two workers, whilst vec has to be sent serially (in time) since it has two different values?
The second question is more important for me, since when A and B are very large (in terms of bytes), and the execution time of my_fnc is very expensive but it is "the same" for each workers (balanced workload), it is difficult to have the results synchronized. Of course, when the execution time of my_fnc is largely greater than the data transfer (no matter how big the index i of the parfor is), this asynchronization may be negligible. Thank you in advance.

Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!