How to Run raytrace or siteviewer related program in Parallel Computing Toolbox?

5 Ansichten (letzte 30 Tage)
I am attempting to simulate coverage for different 'txsites' across various osm maps, aiming to expedite the process through parallelization. However, it appears that 'siteviewer' is not compatible with the Parallel Computing Toolbox.
1. I tried to create a 'siteviewer' object within a parallel loop:
pm = propagationModel("raytracing", ...
"Method", "sbr", ...
"MaxNumReflections", 5);
osmMaps = ["hongkong.osm","chicago.osm","manhattan.osm"];
lats = [22.27,41.87,40.71];
lons = [114.15,-87.63,-74.00];
parfor i=1:3
viewer = siteviewer('Buildings', osmMaps(i), 'Terrain', "none", 'Basemap', "darkwater");
txs = txsite(Latitude=lats(i),Longitude=lons(i));
pd = coverage(txs, pm, 'Map', viewer);
disp(pd);
close(viewer);
end
The above code resulted in the following error: Error using siteviewer, Timeout waiting for response. Despite adjusting several initialization parameters, the error persisted. When I changed 'parfor' to 'for', the program ran without any errors. My understanding is that 'siteviewer' objects cannot be created within 'parfor'.
2. Consequently, I altered my parallelization strategy by creating the 'siteviewer' object in advance and referencing it within the 'parfor' loop:
viewer = siteviewer('Buildings', 'hongkong.osm', 'Terrain', "none", 'Basemap', "darkwater");
lats = [22.27,22.273,22.275];
lons = [114.15,114.152,114.154];
parfor i = 1:3
txs = txsite(Latitude=lats(i),Longitude=lons(i)); % Each iteration, 'txs' are at different locations.
pd = coverage(txs, pm, 'Map', viewer);
end
close(viewer);
Referencing the 'viewer' object within 'parfor' still led to errors.
Output: Warning: While loading an object of class 'siteviewer':
Variables of this type are not subscriptable using dot indexing.
3. Further,I examined the source code of the 'coverage' function and debugged the parallel code.
viewer = siteviewer('Buildings', 'hongkong', 'Terrain', "none", 'Basemap', "darkwater");
future = parfeval(@()viewer, 1); % Assuming 'viewer' is already created.
[~, thisResult] = fetchNext([future]);
% Output: Warning: While loading an object of class 'siteviewer':
% Variables of this type are not subscriptable using dot indexing.
future = parfeval(@()siteviewer.all, 1); % Assuming existing 'siteviewer' objects.
[~, thisResult] = fetchNext([future]);
% Output: thisResult = 0x0 cell
future = parfeval(@()siteviewer.current, 1); % Assuming existing 'siteviewer' objects.
[~, thisResult] = fetchNext([future]);
%Output: error using siteviewer, Timeout waiting for response.
I am puzzled, as the computation for Ray Tracing is slow, cannot be expedited using GPU acceleration, nor can it utilize the Parallel Computing Toolbox, resulting in low efficiency. Is there any solution to run 'coverage' in parallel?
I have consulted many Q&As, including the following: answer_link
However, this Answer is evidently incorrect; the 1000 rays within a cell are identical, failing to achieve parallel acceleration, and moreover, the rays were computed incorrectly. Based on the issues I've encountered, 'raytrace' in a parallel loop is unable to access previously created 'viewer' objects, and the 'Map' in 'raytrace(tx,rx)' differs from the one I defined, leading to incorrect results.

Antworten (1)

Alan
Alan am 1 Jul. 2024
Hi 伟林 ,
I’ve faced the same issue with siteviewer while running it inside parfor. There is an undocumented fix for this, which is to provide the name-value pair “Hidden”, and true as follows:
viewer = siteviewer('Buildings', osmMaps(i), 'Terrain', "none", 'Basemap', "darkwater", "Hidden", true);
But the downside is that there will be no visuals. On the other hand, the propagation data obtained with “parfor” do match with that obtained from using “for”.
Regards.

Kategorien

Mehr zu Propagation and Channel Models finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by