-
Notifications
You must be signed in to change notification settings - Fork 85
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
No need for synchronization? #96
Comments
Hi Nyaruko, But you are correct in raising this issue: in the case of ProbabilisticVoxel and CountingVoxel this creates a race-condition where multiple threads try to update the contents of the same voxel during insertPointCloud. This race-condition can lead to the loss of some the inserted information. I will look into ways to minimize or avoid the risk of information loss, without impacting overall performance significantly. Side-Note: On the voxel-level It's usually in the responsibility of your own code to avoid this kind of race condition from accesses to the same voxel, while the library functions are mostly designed to avoid multiple write accesses to the same voxel by multiiple threads in the same launch. |
Thanks for your notice. I ran into this problem when trying to use the raycaster in the ProbablisticVoxel as shown here. They raycaster would easily access the same voxel from multiple threads when the rays are dense (like in the case from a Lidar). |
Valid point here. I started this with the probabilistic voxels in mind, when I used them for environmental mapping over a longer period of time... I knew about the race condition but I did not interpret it as "broken" for two reasons:
i tried it with a simple thread-lock, but performance was not usable for my scenario then (had several cams in parallel). So either we have to put a clear warning in the docs or we could offer a second "correct" function. Or @cjue wraps his head around it an finds an elegant and well performing solution 😬 |
@nyaruko: yes, to my understanding of the CUDA architecture this will always have the expected result, the location will contain the expected value. A side-node on my earlier comment regarding point-cloud insertion: For VoxelLists this is usually not an issue. For example, CountingVoxelList::insertPointCloud will first create a voxel for each point and then merge all voxels with identical coordinates in a safe way during the VoxelList "make_unique" step. |
For the updateOccupancy function in the file ProbabilisticVoxel.hpp (line 44). I found it is possible that this function will be called from different threads to update the value of m_occupancy.
Will it be dangerous if the write operation in this function is not synchronized?
The text was updated successfully, but these errors were encountered: