TriBITSPub / TriBITS

TriBITS: Tribal Build, Integrate, and Test System,
http://tribits.org
Other
36 stars 46 forks source link

OpenMP Detection for Fortran when using GCC 7.2.0 Fails #244

Closed nmhamster closed 6 years ago

nmhamster commented 6 years ago

Had this on initial GCC 7.2.0 bring up for Sky Lake (using Sandia/ASC Blake Test Bed)

-- Trilinos_ENABLE_CXX11=ON
-- Found OpenMP_C: -fopenmp (found version "4.5")
-- Found OpenMP_CXX: -fopenmp (found version "4.5")
-- Could NOT find OpenMP_Fortran (missing: OpenMP_Fortran_FLAGS OpenMP_Fortran_LIB_NAMES) (found version "1.0")
CMake Error at cmake/tribits/core/package_arch/TribitsGlobalMacros.cmake:1951 (MESSAGE):
  Could not find OpenMP, try setting OpenMP_C_FLAGS and OpenMP_CXX_FLAGS
  directly
Call Stack (most recent call first):
  cmake/tribits/core/package_arch/TribitsProjectImpl.cmake:188 (TRIBITS_SETUP_ENV)
  cmake/tribits/core/package_arch/TribitsProject.cmake:93 (TRIBITS_PROJECT_IMPL)
  CMakeLists.txt:93 (TRIBITS_PROJECT)

In CMakeCache.txt I get the following text:

//Fortran compiler flags for OpenMP parallelization
OpenMP_Fortran_FLAGS:STRING=NOTFOUND
nmhamster commented 6 years ago

Seem to be able to work around with (below) for now.

-D OpenMP_Fortran_FLAGS:STRING="-fopenmp" \
-D OpenMP_Fortran_LIB_NAMES:STRING="gomp" \
bartlettroscoe commented 6 years ago

@nmhamster,

What version of CMake is this?

The TriBITS support for OpenMP is to just call FIND_PACKAGE(OpenMP) and add the compile flags to CMAKE_<LANG>_FLAGS (for C, CXX, Fortran). It does not do anything with libraries. As of CMake 2.8.11 (the minimum version of CMake that TriBITS needs to support), the FindOpenMP.cmake module did not supply any OpenMP libs as shown at:

I can see that at some point FindOpenMP.cmake added those libs at:

but not sure when.

Looking at the current TriBITS implementation integrating OpenMP at:

you can see that TriBITS never uses the lib variables. But I guess for the use case you describe it seems that OpenMP_Fortran_LIB_NAMES is actually being used by FindOpenMP.cmake to find the OpenMP library?

In any case, the good news is that the OpenMP problem for Trilinos should go away once merge the branch being worked on in trilinos/Trilinos#1400 and people start setting KOKKOS_ARCH. But for other projects I am not sure the best way to proceed with OpenMP support in TriBITS. I guess I would like to see someone explain how to use the set of variables being returned in modern versions of FindOpenMP.cmake like shown at https://cmake.org/cmake/help/v3.10/module/FindOpenMP.html. There is really not much explanation there. (CMake documentation can be pretty terse).

bartlettroscoe commented 6 years ago

@nmhamster,

Now that Trilinos can use KOKKOS_ARCH, can you try that to set compiler options for this machine?

We need to move away from FindOpenMP.cmake I think.

bartlettroscoe commented 6 years ago

Now that Trilinos is using KOKKOS_ARCH, I am going to close this as "wontfix".

bartlettroscoe commented 6 years ago

@nmhamster, I just hit this while working on an Intel OpenMP build of Trilinos for SPARC as part of https://software-sandbox.sandia.gov/jira/browse/TRIL-212. It seems this is a known problem for CMake:

Unfortunately, the workaround you give above does not result in a successful configure. I gives the configure failure:

-- Could NOT find OpenMP_Fortran (missing: OpenMP_gomp_LIBRARY) (found version "4.5")
-- Could NOT find OpenMP (missing: OpenMP_Fortran_FOUND) (found version "4.5")
CMake Error at cmake/tribits/core/package_arch/TribitsGlobalMacros.cmake:1990 (MESSAGE):
  Could not find OpenMP, try setting OpenMP_C_FLAGS and OpenMP_CXX_FLAGS
  directly
Call Stack (most recent call first):
  cmake/tribits/core/package_arch/TribitsProjectImpl.cmake:188 (TRIBITS_SETUP_ENV)
  cmake/tribits/core/package_arch/TribitsProject.cmake:93 (TRIBITS_PROJECT_IMPL)
  CMakeLists.txt:90 (TRIBITS_PROJECT)

I posted the SNK Kitware issue:

In the meantime, we need to find a workaround.

bartlettroscoe commented 6 years ago

I found a workaround that worked for the ATDM Trilinos Intel build in https://software-sandbox.sandia.gov/jira/browse/TRIL-212 which was:

  -DOpenMP_Fortran_FLAGS=-fopenmp \
  -DOpenMP_Fortran_LIB_NAMES=gomp \
  -DOpenMP_gomp_LIBRARY=-lgomp \

No rush to fix this, at least for the ATDM Trilinos builds.