[mlpack-git] master: Workaround for OpenMP 2.0 (based on dt_utils.cpp) (b92d465)
gitdub at mlpack.org
gitdub at mlpack.org
Fri Jul 8 08:14:54 EDT 2016
Repository : https://github.com/mlpack/mlpack
On branch : master
Link : https://github.com/mlpack/mlpack/compare/34cf8d94f79c9a72ff4199676033b060cd039fcd...425324bf7fb7c86c85d10a909d8a59d4f69b7164
>---------------------------------------------------------------
commit b92d46527c5d8b1487e4aa4810359292292107f1
Author: Yannis Mentekidis <mentekid at gmail.com>
Date: Fri Jul 8 13:14:54 2016 +0100
Workaround for OpenMP 2.0 (based on dt_utils.cpp)
>---------------------------------------------------------------
b92d46527c5d8b1487e4aa4810359292292107f1
CMakeLists.txt | 2 +-
src/mlpack/methods/lsh/lsh_search_impl.hpp | 22 +++++++++++++++++++---
2 files changed, 20 insertions(+), 4 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 2f91fb6..02e9803 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -236,7 +236,7 @@ add_definitions(-DBOOST_TEST_DYN_LINK)
# This way we can skip calls to functions defined in omp.h with code like:
# if (HAS_OPENMP == 1) { openMP code here }
# If OpenMP is found, define HAS_OPENMP to be 1. Otherwise define it to be 0.
-find_package(OpenMP 3.0.0)
+find_package(OpenMP)
if (OPENMP_FOUND)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
diff --git a/src/mlpack/methods/lsh/lsh_search_impl.hpp b/src/mlpack/methods/lsh/lsh_search_impl.hpp
index c37aed9..066d5c0 100644
--- a/src/mlpack/methods/lsh/lsh_search_impl.hpp
+++ b/src/mlpack/methods/lsh/lsh_search_impl.hpp
@@ -825,10 +825,17 @@ void LSHSearch<SortPolicy>::Search(const arma::mat& querySet,
#pragma omp parallel for \
shared(avgIndicesReturned, resultingNeighbors, distances) \
schedule(dynamic)
- // Go through every query point.
- for (size_t i = 0; i < querySet.n_cols; i++)
+#ifdef _WIN32
+ // Tiny workaround: Visual Studio only implements OpenMP 2.0, which doesn't
+ // support unsigned loop variables. If we're building for Visual Studio, use
+ // the intmax_t type instead.
+ intmax_t querySetSize = (intmax_t) querySet.n_cols;
+ for (intmax_t i = 0; i < querySetSize; ++i)
+#else
+ for (size_t i = 0; i < querySet.n_cols; ++i)
+#endif
{
-
+ // Go through every query point.
// Hash every query into every hash table and eventually into the
// 'secondHashTable' to obtain the neighbor candidates.
arma::uvec refIndices;
@@ -893,6 +900,15 @@ Search(const size_t k,
#pragma omp parallel for \
shared(avgIndicesReturned, resultingNeighbors, distances) \
schedule(dynamic)
+#ifdef _WIN32
+ // Tiny workaround: Visual Studio only implements OpenMP 2.0, which doesn't
+ // support unsigned loop variables. If we're building for Visual Studio, use
+ // the intmax_t type instead.
+ intmax_t referenceSetSize = (intmax_t) referenceSet->n_cols;
+ for (intmax_t i = 0; i < referenceSetSize; ++i)
+#else
+ for (size_t i = 0; i < referenceSet->n_cols; ++i)
+#endif
// Go through every query point. Use long int because some compilers complain
// for openMP unsigned index variables.
for (size_t i = 0; i < referenceSet->n_cols; i++)
More information about the mlpack-git
mailing list