Raytrace difference using for and parfor
8 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Hello, I try to run the raytrace function of matlab to compute the rays among a transmitter site tx and multiple receiver sites rx ( an aray of RXs ). When I use the following code:
for i=1:numSites
rays{i} = raytrace(tx, rx(i), pm);
end
The rays cell array contains the true comm.Ray array concerning every TX-RX link.
On the contrary when I run the same code, with the exception that the for loop becomes a parfor one, the result changes. This time the rays cell array contains a comm.Ray array with a single propagation path (the line-of-sight) as it is running just once an then stops.
Is there a problem in the parallelization scope ?
Does anyone have a clue on that problem ?
Thank you in advance!
2 Commenti
Risposte (1)
Dheeraj
il 27 Ott 2023
Modificato: Dheeraj
il 31 Ott 2023
Hi,
As per my understanding you are trying to compute the rays among a transmitter site “tx” and multiple receiver sites “rx" using “parfor” but it is creating a ray array with single propagation path. Reason for single propagation path in rays cell array with “parfor” loop is because MATLAB parallelizes “parfor” loops by creating a separate worker process for each iteration of the loop. Each worker process has its own memory space and cannot communicate with other worker processes directly.
This means that the rays cell array is not updated with the computed propagation paths from other worker processes. As a result, only the propagation path between the transmitter and receiver that was computed by the last worker process is stored in the “rays” cell array.
To avoid this, use a “parfeval” function instead of a “parfor” loop. The “parfeval” function allows you to evaluate a function asynchronously on multiple workers and collect the results as they become available. You could use the link below to the MATLAB documentation to know more about “parfeval” from parallel computing toolbox.
Hope this helps!
0 Commenti
Vedere anche
Categorie
Scopri di più su Parallel for-Loops (parfor) in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!