How can i communicate the shared memory with the parallel computing toolbox?

I am new to this shared memory concepts. I am not that much familiar with PCT also. kindly Give answers. two functions named Function send and function answer both are sharing the data between them but the problem is both are executed by opening the files in separate command window.Refer to this link i have obtained the shared memory concepts. https://in.mathworks.com/help/matlab/import_export/share-memory-between-applications.html
So that i thought to communicate both files in parpool.How to communicate between the two mfiles using parallel computing toolbox which is already sharing data between them?

4 Comments

At any one time in the parallel situation, how many copies of "send" would be running and how many "answer" would be running? Would each "send" need to communicate with exactly one "answer" or would each "send" need to communicate with all the "answer"? Is the current situation that "send" runs and writes to a file and returns and then "answer" runs and reads from the file, and returns and then send runs again and so on, and you just want to change it so that one of each is running at the same time using the parallel routines?
Thanks alot for your answer Walter Roberson.Initially im trying for one "send" exactly with one "answer". Current situation is "send" runs and have to send that value to "answer"."answer" need not to be resend any values. I have created the parpool operation under your guidance only thank you for that.Here is the code
delete(gcp);
parpool('AttachedFiles',{'send.m','answer.m'})
addpath('C:\Users\SUBATHRA\Documents\MATLAB');
poolobj = gcp('nocreate'); % If no pool, do not create new one.
if isempty(poolobj)
poolsize = 0;
else
poolsize = poolobj.NumWorkers
end
spmd
first_run = true;
for i=1:.1:1
if labindex == 1
if first_run
first_run = false;
end
A_output = send(5);
labSend(A_output, 2);
else
B_parameters = labReceive()
B_output = answer(B_parameters);
end
end
You should change
spmd
to
spmd(poolsize)
I am not sure why your first_run flag is there?
No use of first_run flag here. I have changed spmd(poolsize).The pool is started but there is no sharing of data. How to share the data using the parallel pool to the shared memory programs.

Sign in to comment.

Answers (0)

Asked:

on 12 Mar 2018

Commented:

on 13 Mar 2018

Community Treasure Hunt

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

Start Hunting!