Can a worker/slave be used as a master node?
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Viswanath Hariharan
el 28 de Oct. de 2017
Comentada: Walter Roberson
el 17 de Jul. de 2019
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.
0 comentarios
Respuesta aceptada
Walter Roberson
el 28 de Oct. de 2017
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 comentarios
Walter Roberson
el 28 de Oct. de 2017
You can use any node as "master" if you use spmd.
Otherwise, you have to either use the client as master or as a switchboard to pass messages between the other nodes and the master node.
Más respuestas (2)
LINUS UNGEM BACHE
el 21 de Jun. de 2019
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 comentarios
Walter Roberson
el 29 de Jun. de 2019
Editada: Walter Roberson
el 29 de Jun. de 2019
You are being required to implement in this manner. Sometimes the reason for a requirement such as that is to cause you to think about implementation difficulties and how to overcome them.
Parallel processing works best when all of the below are true:
- the amount of data being transferred back and forth is small compared to the computation (overhead small)
- the computation on each worker is long enough (amortized costs)
- the computation does not involve large arrays in ways that can be well vectorized (high performance multithreaded libraries are very efficient in serial instead of parallel)
gild kone
el 17 de Jul. de 2019
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 comentario
Walter Roberson
el 17 de Jul. de 2019
This is not relevant to the Question that was asked before, so it should be in its own Question.
Ver también
Categorías
Más información sobre Parallel Computing Fundamentals en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!