jlblancoc / nanoflann

nanoflann: a C++11 header-only library for Nearest Neighbor (NN) search with KD-trees
Other
2.22k stars 488 forks source link

parallel query ? #237

Open jschueller opened 6 months ago

jschueller commented 6 months ago

hello, nanoflann supports the parallel build of the tree (by setting n_thread_build) do you think it would also be possible to benefit from multithreading when querying several points at once (for knn) ?

jlblancoc commented 6 months ago

Yes, but on the side of the client user code: 1) make sure of building the KD-tree index from one thread (even then, internally, multiple threads are used within nanoflann), wait for it to return, then 2) Use TBB, std::thread, openmp, etc. to call the query methods in parallel. Query methods are reentrant and thread-safe.

jschueller commented 6 months ago

@jlblancoc I would like the query of the k closests points of one unique reference point to use multithreading, not query the set of closest points of several reference points in parallel like you propose do you think we can take advantage of parallel computations here ?

jschueller commented 6 months ago

@jlblancoc could we consider reopening this issue ?

jlblancoc commented 6 months ago

Sure!

I think it's difficult to obtain an advantage from parallel queries, except perhaps for very very large datasets. I don't have the bandwidth to try to implement to myself in the short term, though...