[mlpack-git] [mlpack/mlpack] LSHSearch Parallelization (#700)

Ryan Curtin notifications at github.com
Thu Jul 7 16:18:32 EDT 2016


> +  arma::mat rdata;
> +  arma::mat qdata;
> +  data::Load(trainSet, rdata, true);
> +  data::Load(testSet, qdata, true);
> +
> +  // Where to store neighbors and distances
> +  arma::Mat<size_t> sequentialNeighbors;
> +  arma::Mat<size_t> parallelNeighbors;
> +  arma::mat distances;
> +
> +  // Construct an LSH object. By default, it uses the maximum number of threads
> +  LSHSearch<> lshTest(rdata, numProj, numTables); //default parameters
> +  lshTest.Search(qdata, k, parallelNeighbors, distances);
> +
> +  // Now perform same search but with 1 thread
> +  lshTest.MaxThreads(1);

If you did remove the `MaxThreads()` member from `LSHSearch`, you could easily replicate the same functionality by just calling `omp_set_num_threads(1)` before the second call to `lshTest.Search()`.  (Maybe you would want to restore the original number of threads afterwards for other OpenMP tests.)

---
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/mlpack/mlpack/pull/700/files/c4c8ff950be8a06e06084764f188095c650b7a60#r69978737
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.cc.gatech.edu/pipermail/mlpack-git/attachments/20160707/10097076/attachment.html>


More information about the mlpack-git mailing list