Can a worker/slave be used as a master node?

조회 수: 6(최근 30일)
Viswanath Hariharan
Viswanath Hariharan 2017년 10월 28일
댓글: Walter Roberson 2019년 7월 17일
I am using the parallel computing toolbox. I have a general question though. I am trying to implement a Branch and Bounds algorithm for non-convex optimization. There has to be a master node and a bunch of worker nodes/slaves. Each time the slave solves a problem, it has to report back to the master node and the master node has to analyze and send a new problem back to any of the slaves which are unassigned.
Let's say we have 100 workers available. Can we use one of the workers out of the 100 as the master node? Or is the term 'Master Node' reserved for the Client (Desktop MATLAB)? Or have I got the whole concept wrong?
I really need guidance on this. Thank you.

채택된 답변

Walter Roberson
Walter Roberson 2017년 10월 28일
If you were to use spmd then you could pick any of the nodes to labSend() to . spmd() allows arbitrary communication between nodes.
The other facilities in the Parallel Computing toolbox do not allow workers to send data to each other directly.
I notice from your other question that you found pollable data queue. That is best documented as allowing data to be sent from worker to client. It is also possible to construct one backwards to send data from the client to the worker. It is not possible to use one to send worker to worker, though (Mathworks employees have said): in order to send worker to worker you would have to have the worker send to the client and the client forward on to the other worker.
You could also call out to mex routines to interface to MPI, but spmd already uses MPI...
  댓글 수: 2
Viswanath Hariharan
Viswanath Hariharan 2017년 10월 28일
Thank you so much for clarifying this for me.

댓글을 달려면 로그인하십시오.

추가 답변(2개)

LINUS UNGEM BACHE
LINUS UNGEM BACHE 2019년 6월 21일
i am trying to write down a parallel code of ant colony algorithm using the master/slave strategy. please i dont know how the master/slave works. Can you help me ?
  댓글 수: 15
LINUS UNGEM BACHE
LINUS UNGEM BACHE 2019년 6월 29일
Ok thanks

댓글을 달려면 로그인하십시오.


gild kone
gild kone 2019년 7월 17일
I have a matlab code for solving eigenvalues and eigenvectors problems but the ways is that i can normally plot differents eigenvalues of my matrix which depend on the varible x=-1:1. My problem is that I don't know how to plot in 3D the corresponding eigenvectors ( ie xlabel: x=-1:1, ylabel: y=-1:1 and Zlabel: z=eigenvectors )
This the correpondint code :
close all;clear all; U =0.9; f= 39; nx=f;T=1;
x=-3.086476993000499:3.096476993000599; y=x;
A=zeros(nx,nx); B=zeros(nx,nx); mat=zeros(nx,nx);
for kappa=1:numel(x) % nu=1:f-1
Rep = T.*(2.0.*cos(x(kappa)/2.0).*cos(x(kappa).*f/2.0)); Imp = 0.0;
Req = T.*(1.0 + cos(x(kappa))); Imq = T.*(sin(x(kappa)));
A(1,1)=U ; A(1,2)=sqrt(2.0)*Req; A(2,1)=sqrt(2.0)*Req;
B(1,2)=sqrt(2.0)*Imq; B(2,1)=-sqrt(2.0)*Imq;
for i=2:nx-1
A(i,i+1)=Req; A(i+1,i)=Req ;B(i,i+1)=Imq; B(i+1,i)=-Imq;
end
A(nx,nx)=Rep ; B(nx,nx)=Imp;
for i=nx:-1:1
for j=nx:-1:1
mat(i,j)=A(i,j);
mat(i,j+nx)=B(i,j);
mat(i+nx,j)=-B(i,j);
mat(i+nx,j+nx)=A(i,j);
end
end
[v,d0] = eig(mat); % eigenvectors and eigenvalues
%vv=v(:,kappa) ; v0=vv/norm(vv); C0=v0.*v0 % give us \c0\^2
dd=d(:,kappa); d0=dd/norm(dd); z=d0*d0' ; surf(z);
%d0(kappa,:)=eig(mat); for eigenvalue only
end
plot(d0,'r-');
  댓글 수: 1
Walter Roberson
Walter Roberson 2019년 7월 17일
This is not relevant to the Question that was asked before, so it should be in its own Question.

댓글을 달려면 로그인하십시오.

Community Treasure Hunt

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

Start Hunting!

Translated by