[mlpack-git] master: Book-keeping of number of threads used (afcc881)
gitdub at mlpack.org
gitdub at mlpack.org
Fri Jul 8 14:36:38 EDT 2016
Repository : https://github.com/mlpack/mlpack
On branch : master
Link : https://github.com/mlpack/mlpack/compare/34cf8d94f79c9a72ff4199676033b060cd039fcd...425324bf7fb7c86c85d10a909d8a59d4f69b7164
>---------------------------------------------------------------
commit afcc8815234f10ef0bdf162bb392b2f272baa349
Author: Yannis Mentekidis <mentekid at gmail.com>
Date: Sun Jun 19 14:44:57 2016 +0300
Book-keeping of number of threads used
>---------------------------------------------------------------
afcc8815234f10ef0bdf162bb392b2f272baa349
src/mlpack/methods/lsh/lsh_search_impl.hpp | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/src/mlpack/methods/lsh/lsh_search_impl.hpp b/src/mlpack/methods/lsh/lsh_search_impl.hpp
index a7e3be7..8ac794c 100644
--- a/src/mlpack/methods/lsh/lsh_search_impl.hpp
+++ b/src/mlpack/methods/lsh/lsh_search_impl.hpp
@@ -32,7 +32,7 @@ LSHSearch(const arma::mat& referenceSet,
bucketSize(bucketSize),
distanceEvaluations(0),
maxThreads(omp_get_max_threads()),
- numThreadsUsed(0)
+ numThreadsUsed(1)
{
// Pass work to training function.
Train(referenceSet, numProj, numTables, hashWidthIn, secondHashSize,
@@ -56,7 +56,7 @@ LSHSearch(const arma::mat& referenceSet,
bucketSize(bucketSize),
distanceEvaluations(0),
maxThreads(omp_get_max_threads()),
- numThreadsUsed(0)
+ numThreadsUsed(1)
{
// Pass work to training function
Train(referenceSet, numProj, numTables, hashWidthIn, secondHashSize,
@@ -75,7 +75,7 @@ LSHSearch<SortPolicy>::LSHSearch() :
bucketSize(500),
distanceEvaluations(0),
maxThreads(omp_get_max_threads()),
- numThreadsUsed(0)
+ numThreadsUsed(1)
{
// Nothing to do.
}
@@ -549,7 +549,7 @@ Search(const size_t k,
// Master thread updates the number of threads used
if (i == 0 && omp_get_thread_num() == 0)
{
- numThreadsUsed+=omp_get_num_threads();
+ numThreadsUsed+=omp_get_num_threads(); //
Log::Info
<< "Using "<< numThreadsUsed << " threads to process queries." << endl;
}
@@ -568,8 +568,13 @@ Search(const size_t k,
// candidates.
for (size_t j = 0; j < refIndices.n_elem; j++)
BaseCase(i, (size_t) refIndices[j], resultingNeighbors, distances);
+
}
+ // parallel region over, reset number of threads to 1
+ numThreadsUsed = omp_get_num_threads();
+
+
Timer::Stop("computing_neighbors");
distanceEvaluations += avgIndicesReturned;
More information about the mlpack-git
mailing list