[mlpack-git] master: Fixes CMakeFiles and code to make openMP actually transparent (2ca48c6)
gitdub at mlpack.org
gitdub at mlpack.org
Mon Jun 27 08:15:37 EDT 2016
Repository : https://github.com/mlpack/mlpack
On branch : master
Link : https://github.com/mlpack/mlpack/compare/34cf8d94f79c9a72ff4199676033b060cd039fcd...425324bf7fb7c86c85d10a909d8a59d4f69b7164
>---------------------------------------------------------------
commit 2ca48c63f7aba8def3f08e96d155cd9be2b8f7d5
Author: Yannis Mentekidis <mentekid at gmail.com>
Date: Mon Jun 27 13:15:37 2016 +0100
Fixes CMakeFiles and code to make openMP actually transparent
>---------------------------------------------------------------
2ca48c63f7aba8def3f08e96d155cd9be2b8f7d5
CMakeLists.txt | 18 ++++++++----------
src/mlpack/methods/lsh/lsh_search_impl.hpp | 10 +++++-----
2 files changed, 13 insertions(+), 15 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 855212e..2dba9e5 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -27,7 +27,7 @@ option(BUILD_TESTS "Build tests." ON)
option(BUILD_CLI_EXECUTABLES "Build command-line executables" ON)
option(BUILD_SHARED_LIBS
"Compile shared libraries (if OFF, static libraries are compiled)." ON)
-option(HAS_OPENMP "Use OpenMP for parallel execution." OFF)
+option(HAS_OPENMP "Use OpenMP for parallel execution, if available" ON)
enable_testing()
@@ -118,11 +118,6 @@ if(ARMA_EXTRA_DEBUG)
add_definitions(-DARMA_EXTRA_DEBUG)
endif()
-# If the user has an OpenMP-enabled compiler, turn OpenMP on
-if (HAS_OPENMP)
- add_definitions(-DHAS_OPENMP)
-endif()
-
# Now, find the libraries we need to compile against. Several variables can be
# set to manually specify the directory in which each of these libraries
# resides.
@@ -239,10 +234,13 @@ add_definitions(-DBOOST_TEST_DYN_LINK)
# Detect OpenMP support in a compiler. If the compiler supports OpenMP, the
# flags to compile with OpenMP are returned and added.
-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}")
+if (HAS_OPENMP)
+ find_package(OpenMP)
+ if (OPENMP_FOUND)
+ add_definitions(-DOPENMP_FOUND)
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
+ endif ()
endif ()
# Create a 'distclean' target in case the user is using an in-source build for
diff --git a/src/mlpack/methods/lsh/lsh_search_impl.hpp b/src/mlpack/methods/lsh/lsh_search_impl.hpp
index 0a20bb3..17886dc 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,
distanceEvaluations(0)
{
- #ifdef _OPENMP
+ #ifdef OPENMP_FOUND
maxThreads = omp_get_max_threads();
#else
maxThreads = 1;
@@ -59,7 +59,7 @@ LSHSearch(const arma::mat& referenceSet,
bucketSize(bucketSize),
distanceEvaluations(0)
{
- #ifdef _OPENMP
+ #ifdef OPENMP_FOUND
maxThreads = omp_get_max_threads();
#else
maxThreads = 1;
@@ -82,7 +82,7 @@ LSHSearch<SortPolicy>::LSHSearch() :
distanceEvaluations(0)
{
// Only define maxThreads. Nothing else to do.
- #ifdef _OPENMP
+ #ifdef OPENMP_FOUND
maxThreads = omp_get_max_threads();
#else
maxThreads = 1;
@@ -446,7 +446,7 @@ void LSHSearch<SortPolicy>::ReturnIndicesFromTable(
// Only keep reference points found in at least one bucket. If OpenMP is
// found, do it in parallel
- #ifdef _OPENMP
+ #ifdef OPENMP_FOUND
// TODO: change this to our own function?
referenceIndices = arma::find(refPointsConsidered > 0);
return;
@@ -497,7 +497,7 @@ void LSHSearch<SortPolicy>::ReturnIndicesFromTable(
}
// Only keep unique candidates. If OpenMP is found, do it in parallel.
- #ifdef _OPENMP
+ #ifdef OPENMP_FOUND
// TODO: change this to our own function?
referenceIndices = arma::unique(refPointsConsideredSmall);
return;
More information about the mlpack-git
mailing list