Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OpenMP detection is still broken with Clang since ginkgo 1.6.0 #1482

Closed
barracuda156 opened this issue Dec 2, 2023 · 6 comments · Fixed by #1619
Closed

OpenMP detection is still broken with Clang since ginkgo 1.6.0 #1482

barracuda156 opened this issue Dec 2, 2023 · 6 comments · Fixed by #1619

Comments

@barracuda156
Copy link

--->  Configuring ginkgo
Executing:  cd "/opt/local/var/macports/build/_opt_svacchanda_SonomaPorts_math_ginkgo/ginkgo/work/build" && /opt/local/bin/cmake -G "CodeBlocks - Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="/opt/local" -DCMAKE_INSTALL_NAME_DIR="/opt/local/lib" -DCMAKE_SYSTEM_PREFIX_PATH="/opt/local;/usr" -DCMAKE_C_COMPILER="$CC" -DCMAKE_CXX_COMPILER="$CXX" -DCMAKE_OBJC_COMPILER="$CC" -DCMAKE_OBJCXX_COMPILER="$CXX" -DCMAKE_POLICY_DEFAULT_CMP0025=NEW -DCMAKE_POLICY_DEFAULT_CMP0060=NEW -DCMAKE_VERBOSE_MAKEFILE=ON -DCMAKE_COLOR_MAKEFILE=ON -DCMAKE_FIND_FRAMEWORK=LAST -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_MAKE_PROGRAM=/usr/bin/make -DCMAKE_MODULE_PATH="/opt/local/share/cmake/Modules" -DCMAKE_PREFIX_PATH="/opt/local/share/cmake/Modules" -DCMAKE_BUILD_WITH_INSTALL_RPATH:BOOL=OFF -DCMAKE_INSTALL_RPATH="/opt/local/lib" -Wno-dev -DBUILD_SHARED_LIBS=ON -DGINKGO_MIXED_PRECISION=ON -DGINKGO_BUILD_MPI=ON -DGINKGO_BUILD_REFERENCE=ON -DGINKGO_BUILD_TESTS=ON -DGINKGO_BUILD_BENCHMARKS=OFF -DGINKGO_BUILD_CUDA=OFF -DGINKGO_BUILD_DPCPP=OFF -DGINKGO_BUILD_HIP=OFF -DGINKGO_BUILD_DOC=OFF -DGINKGO_BUILD_EXAMPLES=OFF -DGINKGO_BUILD_HWLOC=OFF -DGINKGO_BUILD_OMP=ON -DGINKGO_DEVEL_TOOLS=OFF -DGINKGO_DOC_GENERATE_EXAMPLES=OFF -DGINKGO_DOC_GENERATE_PDF=OFF -DGINKGO_JACOBI_FULL_OPTIMIZATIONS=OFF -DGINKGO_WITH_CCACHE=OFF -DMPIEXEC_EXECUTABLE=/opt/local/bin/mpiexec -DGTEST_SRC_DIR=/opt/local/src/googletest/ -DCMAKE_OSX_ARCHITECTURES="arm64" -DCMAKE_OSX_DEPLOYMENT_TARGET="14.0" -DCMAKE_OSX_SYSROOT="/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.sdk" /opt/local/var/macports/build/_opt_svacchanda_SonomaPorts_math_ginkgo/ginkgo/work/ginkgo-1.7.0 
-- The C compiler identification is AppleClang 15.0.0.15000040
-- The CXX compiler identification is AppleClang 15.0.0.15000040
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - failed
-- Check for working C compiler: /opt/local/bin/mpicc-mpich-mp
-- Check for working C compiler: /opt/local/bin/mpicc-mpich-mp - works
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - failed
-- Check for working CXX compiler: /opt/local/bin/mpicxx-mpich-mp
-- Check for working CXX compiler: /opt/local/bin/mpicxx-mpich-mp - works
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Could NOT find PAPI (missing: PAPI_LIBRARY PAPI_INCLUDE_DIR sde) (Required is at least version "7.0.1.0")
CMake Warning at cmake/rename.cmake:15 (message):
  GINKGO_BUILD_DPCPP was deprecated, please use GINKGO_BUILD_SYCL instead.
  We copy OFF to GINKGO_BUILD_SYCL
Call Stack (most recent call first):
  CMakeLists.txt:27 (gko_rename_cache)


CMake Error at /opt/local/share/cmake-3.28/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
  Could NOT find OpenMP_C (missing: OpenMP_C_FLAGS OpenMP_C_LIB_NAMES)
  (Required is at least version "3.0")
Call Stack (most recent call first):
  /opt/local/share/cmake-3.28/Modules/FindPackageHandleStandardArgs.cmake:600 (_FPHSA_FAILURE_MESSAGE)
  /opt/local/share/cmake-3.28/Modules/FindOpenMP.cmake:580 (find_package_handle_standard_args)
  CMakeLists.txt:110 (find_package)


-- Configuring incomplete, errors occurred!
Command failed:  cd "/opt/local/var/macports/build/_opt_svacchanda_SonomaPorts_math_ginkgo/ginkgo/work/build" && /opt/local/bin/cmake -G "CodeBlocks - Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="/opt/local" -DCMAKE_INSTALL_NAME_DIR="/opt/local/lib" -DCMAKE_SYSTEM_PREFIX_PATH="/opt/local;/usr" -DCMAKE_C_COMPILER="$CC" -DCMAKE_CXX_COMPILER="$CXX" -DCMAKE_OBJC_COMPILER="$CC" -DCMAKE_OBJCXX_COMPILER="$CXX" -DCMAKE_POLICY_DEFAULT_CMP0025=NEW -DCMAKE_POLICY_DEFAULT_CMP0060=NEW -DCMAKE_VERBOSE_MAKEFILE=ON -DCMAKE_COLOR_MAKEFILE=ON -DCMAKE_FIND_FRAMEWORK=LAST -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_MAKE_PROGRAM=/usr/bin/make -DCMAKE_MODULE_PATH="/opt/local/share/cmake/Modules" -DCMAKE_PREFIX_PATH="/opt/local/share/cmake/Modules" -DCMAKE_BUILD_WITH_INSTALL_RPATH:BOOL=OFF -DCMAKE_INSTALL_RPATH="/opt/local/lib" -Wno-dev -DBUILD_SHARED_LIBS=ON -DGINKGO_MIXED_PRECISION=ON -DGINKGO_BUILD_MPI=ON -DGINKGO_BUILD_REFERENCE=ON -DGINKGO_BUILD_TESTS=ON -DGINKGO_BUILD_BENCHMARKS=OFF -DGINKGO_BUILD_CUDA=OFF -DGINKGO_BUILD_DPCPP=OFF -DGINKGO_BUILD_HIP=OFF -DGINKGO_BUILD_DOC=OFF -DGINKGO_BUILD_EXAMPLES=OFF -DGINKGO_BUILD_HWLOC=OFF -DGINKGO_BUILD_OMP=ON -DGINKGO_DEVEL_TOOLS=OFF -DGINKGO_DOC_GENERATE_EXAMPLES=OFF -DGINKGO_DOC_GENERATE_PDF=OFF -DGINKGO_JACOBI_FULL_OPTIMIZATIONS=OFF -DGINKGO_WITH_CCACHE=OFF -DMPIEXEC_EXECUTABLE=/opt/local/bin/mpiexec -DGTEST_SRC_DIR=/opt/local/src/googletest/ -DCMAKE_OSX_ARCHITECTURES="arm64" -DCMAKE_OSX_DEPLOYMENT_TARGET="14.0" -DCMAKE_OSX_SYSROOT="/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.sdk" /opt/local/var/macports/build/_opt_svacchanda_SonomaPorts_math_ginkgo/ginkgo/work/ginkgo-1.7.0 
Exit code: 1

Without OpenMP 1.7.0 builds fine and mostly passes the test suite.

@barracuda156
Copy link
Author

Configure log:
ginkgo_1.7.0_CMakeConfigureLog.txt

@upsj
Copy link
Member

upsj commented Dec 2, 2023

That is a CMake issue, we are relying on the FindOpenMP module. Can you compile a small OpenMP test program successfully? As a workaround, you can specify the OpenMP_C(XX)_FLAGS, OpenMP_C(XX)_LIB_NAMES and OpenMP_<libname>_LIBRARY path explicitly, we do the same for Intel's new C++ compilers

@barracuda156
Copy link
Author

@upsj OpenMP as such works with our CMake and Clang, AFAICT (including detection). I can try fixing CMakeLists here, I did the same for another port a couple of days ago.

@upsj
Copy link
Member

upsj commented Dec 2, 2023

We don't do anything unusual for OpenMP detection, this is the standard CMake way of enabling it. Does a simple

project(Test LANGUAGES C CXX)
find_package(OpenMP 3.0 REQUIRED)

work properly in your environment? I see a missing include in your configure report.

/opt/local/var/macports/build/_opt_svacchanda_SonomaPorts_math_ginkgo/ginkgo/work/build/CMakeFiles/CMakeScratch/TryCompile-2JDIZ9/OpenMPTryFlag.cpp:2:10: fatal error: 'omp.h' file not found
        #include <omp.h>

@barracuda156
Copy link
Author

@upsj Sorry for a delay with this, somewhat short on time. I will return to this issue this week.

@tcojean
Copy link
Member

tcojean commented May 29, 2024

I realize that our CI was also not actually running with OpenMP, despite the
name stating so.

For MacOS when using homebrew's libomp, you need to add to the CMake
command: -DCMAKE_PREFIX_PATH=/opt/homebrew/opt/libomp/. Then
the OpenMP library is properly found. According to #1619, with minor changes
the OpenMP build (and tests) seem to succeed.

AFAIU, there's nothing we can do about this, brew states the following when
installing libomp:

libomp is keg-only, which means it was not symlinked into /opt/homebrew,
because it can override GCC headers and result in broken builds.
For compilers to find libomp you may need to set:
export LDFLAGS="-L/opt/homebrew/opt/libomp/lib"
export CPPFLAGS="-I/opt/homebrew/opt/libomp/include"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants