hku-mars / ikd-Tree

This repository provides implementation of an incremental k-d tree for robotic applications.
GNU General Public License v2.0
630 stars 174 forks source link

I wonder whether Nearest_Search support multi-thread operation ? #6

Closed Woodpecker0 closed 3 years ago

Woodpecker0 commented 3 years ago

Thanks for your work, it's elegant and useful.

I would like to use nearest search in a openmp section, eg:

`

pragma omp parallel for num_threads(4)

for (int i = 0; i < laserCloudSurfLastDSNum; i++) { PointType pointOri, pointSel, coeff; std::vector pointSearchInd; std::vector pointSearchSqDis;

pointOri = laserCloudSurfLastDS->points[i];
pointAssociateToMap(&pointOri, &pointSel); 
kdtreeSurfFromMap->nearestKSearch(pointSel, 5, pointSearchInd, pointSearchSqDis); //replaced by ikd-tree

} ` Is it possible to do multiple search at the same time ? It seems that a mutex is used within the Nearest_Search(), which means that parallel operations actually save no time. Am i right ?

Ecstasy-EC commented 3 years ago

Sorry for my late reply.

Our ikd-Tree supports multi-thread nearest search. The mutex locks are only used to avoid memory conflicts in lazy label updates thus the multi-thread operations definitely save time. We have already tested the multi-thread nearest search in our LIO applications using the openmp. So don't worry about this.

Woodpecker0 commented 3 years ago

thank you

Yixi Cai @.***> 于 2021年6月2日周三 下午12:34写道:

Closed #6 https://github.com/hku-mars/ikd-Tree/issues/6.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/hku-mars/ikd-Tree/issues/6#event-4829350781, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABN7JXKVCC6AG3VAWEXZ43LTQWYEBANCNFSM43WR77ZA .