mariusmuja/flann — pull request #114 by dougalsutherland (2013-06-26 21:26:27+00:00)
Title: don't use openmp at all if params.cores == 1

FLANN's OpenMP parallelism is great. In one of my applications, though, I need to be able to do lots of single-core searches on maybe-different indices in parallel. So I set `params.cores = 1` and went ahead and OpenMPed my worker threads. Turns out, though, that even if you only ask OpenMP for a single worker thread, it still segfaults if you do that somewhere other than the master thread.

This PR avoids this problem by checking if `params.cores == 1`, and if so, not using `#pragma omp parallel` at all. Unfortunately, this results in a lot of code duplication, which sucks, especially given the code duplication that's already there to handle the different result set types. If you can think of a better way to solve this problem I'd love to hear it.

pyunit tests all pass (except for one failure in `test_nn_autotune.py` that seems unrelated:
`test_nn_autotune_500d_100pt` gave `failed #1: targ_prec=0.700000, N=100,correctness=0.470000`). I wasn't able to run the gtest tests, because of #113.