ginkgo icon indicating copy to clipboard operation
ginkgo copied to clipboard

OpenMP detection is still broken with Clang since `ginkgo` 1.6.0

Open barracuda156 opened this issue 1 year ago • 5 comments

--->  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 avatar Dec 02 '23 08:12 barracuda156

Configure log: ginkgo_1.7.0_CMakeConfigureLog.txt

barracuda156 avatar Dec 02 '23 08:12 barracuda156

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

upsj avatar Dec 02 '23 08:12 upsj

@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.

barracuda156 avatar Dec 02 '23 09:12 barracuda156

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>

upsj avatar Dec 02 '23 11:12 upsj

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

barracuda156 avatar Dec 03 '23 14:12 barracuda156

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"

tcojean avatar May 29 '24 15:05 tcojean