Skip to content

Instantly share code, notes, and snippets.

@mdouze
Created April 14, 2017 09:15
Show Gist options
  • Save mdouze/46daf5fb494be70c7dd8ab19698021d0 to your computer and use it in GitHub Desktop.
Save mdouze/46daf5fb494be70c7dd8ab19698021d0 to your computer and use it in GitHub Desktop.
[matthijs@matthijs-mbp ~/Desktop/test_cmake/faiss/build]cmake -DCMAKE_CXX_COMPILER=/opt/local/bin/g++-mp-6 ..
-- The C compiler identification is AppleClang 8.0.0.8000042
-- The CXX compiler identification is GNU 6.3.0
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Checking whether CXX compiler has -isysroot
-- Checking whether CXX compiler has -isysroot - yes
-- Checking whether CXX compiler supports OSX deployment target flag
-- Checking whether CXX compiler supports OSX deployment target flag - yes
-- Check for working CXX compiler: /opt/local/bin/g++-mp-6
-- Check for working CXX compiler: /opt/local/bin/g++-mp-6 -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Try OpenMP C flag = [-fopenmp=libomp]
-- Performing Test OpenMP_FLAG_DETECTED
-- Performing Test OpenMP_FLAG_DETECTED - Failed
-- Try OpenMP C flag = [ ]
-- Performing Test OpenMP_FLAG_DETECTED
-- Performing Test OpenMP_FLAG_DETECTED - Failed
-- Try OpenMP C flag = [-fopenmp]
-- Performing Test OpenMP_FLAG_DETECTED
-- Performing Test OpenMP_FLAG_DETECTED - Failed
-- Try OpenMP C flag = [/openmp]
-- Performing Test OpenMP_FLAG_DETECTED
-- Performing Test OpenMP_FLAG_DETECTED - Failed
-- Try OpenMP C flag = [-Qopenmp]
-- Performing Test OpenMP_FLAG_DETECTED
-- Performing Test OpenMP_FLAG_DETECTED - Failed
-- Try OpenMP C flag = [-openmp]
-- Performing Test OpenMP_FLAG_DETECTED
-- Performing Test OpenMP_FLAG_DETECTED - Failed
-- Try OpenMP C flag = [-xopenmp]
-- Performing Test OpenMP_FLAG_DETECTED
-- Performing Test OpenMP_FLAG_DETECTED - Failed
-- Try OpenMP C flag = [+Oopenmp]
-- Performing Test OpenMP_FLAG_DETECTED
-- Performing Test OpenMP_FLAG_DETECTED - Failed
-- Try OpenMP C flag = [-qsmp]
-- Performing Test OpenMP_FLAG_DETECTED
-- Performing Test OpenMP_FLAG_DETECTED - Failed
-- Try OpenMP C flag = [-mp]
-- Performing Test OpenMP_FLAG_DETECTED
-- Performing Test OpenMP_FLAG_DETECTED - Failed
-- Try OpenMP CXX flag = [-fopenmp]
-- Performing Test OpenMP_FLAG_DETECTED
-- Performing Test OpenMP_FLAG_DETECTED - Success
CMake Error at /opt/local/share/cmake-3.7/Modules/FindPackageHandleStandardArgs.cmake:138 (message):
Could NOT find OpenMP (missing: OpenMP_C_FLAGS)
Call Stack (most recent call first):
/opt/local/share/cmake-3.7/Modules/FindPackageHandleStandardArgs.cmake:378 (_FPHSA_FAILURE_MESSAGE)
/opt/local/share/cmake-3.7/Modules/FindOpenMP.cmake:316 (find_package_handle_standard_args)
CMakeLists.txt:13 (find_package)
-- Configuring incomplete, errors occurred!
See also "/Users/matthijs/Desktop/test_cmake/faiss/build/CMakeFiles/CMakeOutput.log".
See also "/Users/matthijs/Desktop/test_cmake/faiss/build/CMakeFiles/CMakeError.log".
@hlzz
Copy link

hlzz commented Apr 14, 2017

I checked the makefile.inc.Mac.brew. It installed a different version of clang using homebrew. So to build faiss on mac, we need to install this new clang too and specified it in the cmake script.

@hlzz
Copy link

hlzz commented Apr 14, 2017

It seems to me that changing the compiler is not done in the cmake script. We should set the CC/CXX variable, pointing it to the new compiler, before running cmake commands.

@mdouze
Copy link
Author

mdouze commented Apr 16, 2017

The compiler /opt/local/bin/g++-mp-6 supports OpenMP, so I don't understand why cmake is complaining. The -DCMAKE_CXX_COMPILER=/opt/local/bin/g++-mp-6 option sets the compiler, right?

@hlzz
Copy link

hlzz commented Apr 17, 2017

What about also setting CMAKE_C_COMPILER to /opt/local/bin/g++-mp-6?

@mdouze
Copy link
Author

mdouze commented Apr 18, 2017

Thanks for the suggestion, this advanced a bit, by setting

OpenBLAS_HOME=/opt/local cmake -DCMAKE_CXX_COMPILER=/opt/local/bin/g++-mp-6 -DCMAKE_C_COMPILER=/opt/local/bin/gcc-mp-6  ..

It now passes the openmp test fine. However, the openblas test fails. with error

-- Could not find OpenBLAS include. Turning OpenBLAS_FOUND off
CMake Error at cmake/Modules/FindOpenBLAS.cmake:55 (MESSAGE):
  Could not find OpenBLAS
Call Stack (most recent call first):
  CMakeLists.txt:16 (find_package)


-- Configuring incomplete, errors occurred!
See also "/Users/matthijs/Desktop/github_faiss/test_cmake/faiss/build/CMakeFiles/CMakeOutput.log".

I set OpenBLAS_HOME to /opt/local because this is where macports installed openblas, see

[matthijs@matthijs-mbp ~/Desktop/github_faiss/faiss]port contents openblas
Warning: port definitions are more than two weeks old, consider updating them by running 'port selfupdate'.
Port OpenBLAS contains:
  /opt/local/include/cblas_openblas.h
  /opt/local/include/f77blas.h
  /opt/local/include/lapacke.h
  /opt/local/include/lapacke_config.h
  /opt/local/include/lapacke_mangling.h
  /opt/local/include/lapacke_utils.h
  /opt/local/include/openblas_config.h
  /opt/local/lib/libopenblas-r1.a
  /opt/local/lib/libopenblas-r1.dylib
  /opt/local/lib/libopenblas.a
  /opt/local/lib/libopenblas.dylib

Any idea why it does not pick up the include path?

@hlzz
Copy link

hlzz commented Apr 19, 2017

Thanks for the report of macports. I use homebrew personally so I didn't encounter this issue. I've update the pull request and INSTALL. This issue is solved by adding the macport search path (/opt/local/include and /opt/local/lib) to FindOpenBlas.cmake.

@mdouze
Copy link
Author

mdouze commented Apr 19, 2017

The fix does not work. It seems to be because cmake requires cblas.h (that Faiss does not use).
Istalling the dev package of openblas to see if it works better...

@mdouze
Copy link
Author

mdouze commented Apr 19, 2017

Could you remove the requirement for CBLAS includes? Faiss does not use them, and the macports openblas does not provide cblas.h, only the devel packags has a /opt/local/include/cblas_openblas.h.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment