SPMD to process different iteration on different worker
Ältere Kommentare anzeigen
I'm trying to use the spmd to process different iteration. The current problem I have is the spmd function is repeating the same processing on different worker. I have tried to use parfor but the parfor cannot guarantee the iteration is process in order. What I am looking for is to have the iteration process in order. For example, from 0>1>2>3>4,.... Below is the sample code.
clear
clc
iCellNum = 1;
activeUeNums = 1;
tic
ticBytes(gcp)
for ttiNum = 1 : 20
spmd
if true
fprintf('%s processing subframe: %d\n', getTimeNow, ttiNum-1);
end
end
end
toc
tocBytes(gcp)
Antworten (1)
It's not entirely clear to me quite what you're after. You might want for (drange) which spreads the iterations of a for loop over different workers in spmd.
parpool("local");
spmd
for ii = drange(1:20)
fprintf('Worker %d processing iteration %d\n', labindex, ii);
end
end
4 Kommentare
Yi Xien Yap
am 3 Aug. 2022
Walter Roberson
am 3 Aug. 2022
Suppose that worker 1 finished iteration 4 before worker 2 begins iteration 5. Should worker 1 start the next available iteration (5), or should it be strictly round-robin that worker 1 does 1:3:end and 2 does 2:3:end?
Yi Xien Yap
am 3 Aug. 2022
Walter Roberson
am 3 Aug. 2022
Do you need spmd specifically? That is, are you doing labSend(), or using labBarrier to control access to a resource?
If not then consider queuing a bunch of jobs using parfeval.
Kategorien
Mehr zu Parallel for-Loops (parfor) finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!