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 Assumes GNU-Style Preprocessor Directive for Fortran (Incompatible with IBM XLF) #485

Closed
nmhamster opened this issue Jul 6, 2016 · 6 comments
Assignees
Labels
CLOSED_DUE_TO_INACTIVITY Issue or PR has been closed by the GitHub Actions bot due to inactivity. Framework tasks Framework tasks (used internally by Framework team) impacting: configure or build The issue is primarily related to configuring or building MARKED_FOR_CLOSURE Issue or PR is marked for auto-closure by the GitHub Actions bot. system: linux system: manycore type: bug The primary issue is a bug in Trilinos code or tests

Comments

@nmhamster
Copy link
Contributor

Trilinos OpenMP detection of flags for Fortran compiler does not work correctly with IBM XLF compiler on POWER8 platform. The detection assumes that the -D flag works for passing preprocessor defines through to the compiler. This is not the case for the IBM xlfand xlf90 compilers where -WF,-D needs to be used if we expect the C preprocessor to be called. The correct check should be for -qsmp=omp to be found although its not clear this is correctly tested for (possible I have missed it in the error output).

/home/projects/pwr8-rhel72/ibm/xl/xlf/15.1.3/bin/xlf   -O3 -g -qsmp=omp -qsimd=auto -L/home/projects/pwr8-rhel72/ibm/xl/xlf/15.1.3/lib -L/home/projects/pwr8-rhel72/ibm/xl/xlC/13.1.3/lib -lopen-pal -lxl -lxlopt -lxlf90 -lxlfmath -lm -libmc++ -lstdc++ -L/home/projects/pwr8-rhel72/openmpi/1.10.2/xl/13.1.3/cuda/7.5.7/lib -lmpi  -O3 -g -qsmp=omp -qsimd=auto -L/home/projects/pwr8-rhel72/ibm/xl/xlf/15.1.3/lib -L/home/projects/pwr8-rhel72/ibm/xl/xlC/13.1.3/lib -lxlf90 -DOpenMP_FLAG_DETECTED -mp CMakeFiles/cmTC_48a9b.dir/src.F.o  -o cmTC_48a9b -Wl,-export-dynamic

Yields (incorrect behavior) error of:

ld: warning: cannot find entry symbol nMP_FLAG_DETECTED; defaulting to 0000000010000860
@nmhamster nmhamster added type: bug The primary issue is a bug in Trilinos code or tests impacting: configure or build The issue is primarily related to configuring or building system: linux system: manycore labels Jul 6, 2016
@bartlettroscoe bartlettroscoe added the Framework tasks Framework tasks (used internally by Framework team) label Jul 6, 2016
@bartlettroscoe
Copy link
Member

CC: @trilinos/framework

Looking at the implementation for this in TriBITS (not sure who wrote this) I see:

  IF(${PROJECT_NAME}_ENABLE_OpenMP)
    FIND_PACKAGE(OpenMP)
    IF(OPENMP_FOUND)
      SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
      SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
      # FindOpenMP.cmake doesn't find Fortran flags.  Mike H said this is safe.
      SET(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} ${OpenMP_C_FLAGS}")
    ELSE()
      MESSAGE(FATAL_ERROR "Could not find OpenMP, try setting OpenMP_C_FLAGS and OpenMP_CXX_FLAGS directly")
    ENDIF(OPENMP_FOUND)
  ENDIF(${PROJECT_NAME}_ENABLE_OpenMP)

It seems that updated versions of FindOpenMP.cmake do in fact define an OpenMP_Fortran_FLAGS variable (I looked at CMake 3.5.1).

Si,

Can you please try replacing:

      SET(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} ${OpenMP_C_FLAGS}")

with:

      SET(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} ${OpenMP_Fortran_FLAGS}")

in your copy of Trilinos in the file:

Trilinos/cmake/tribits/core/package_arch/TribitsGlobalMacros.cmake

and see if that works? If it does not work out of the box, then it looks like updated versions of FindOpenMP.cmake allow you to override these as CMake cache vars with -DOpenMP_Fortran_FLAGS="<whatever-you-want>". Just make sure you blow away your CMakeCache and CMakeFiles/ directory to start.

If this works, then we can update TriBITS for this change and snapshot back into Trilinos.

@nmhamster
Copy link
Contributor Author

@bartlettroscoe I had set the various OpenMP_* flags last night but got caught up by this bug you outlined in my overnight builds. Have made the change and am building now. Recall that the build, link and test on this machine can be greater than 3 days in the current cycle due to very long optimization times. Appreciate your help.

@bartlettroscoe
Copy link
Member

Recall that the build, link and test on this machine can be greater than 3 days in the current cycle due to very long optimization times.

Si, since it looks like this error occurs right in the compiler setup phase in the initial CMake configure, you should get feedback pretty fast (before you start building any Trilinos code). Otherwise, after the cmake configure completes (successfully, perhaps after some iteration), then I would build a single Fortran source/object file. For details on how to do that, see:

@bartlettroscoe
Copy link
Member

As described in #1427, setup for OpenMP is controlled by FindOpenMP.cmake which is in the set of standard CMake modules. The solution is to try upgrading CMake and otherwise report the problems to Kitware (and we can make suggested changes).

CC: @trilinos/framework

@github-actions
Copy link

This issue has had no activity for 365 days and is marked for closure. It will be closed after an additional 30 days of inactivity.
If you would like to keep this issue open please add a comment and remove the MARKED_FOR_CLOSURE label.
If this issue should be kept open even with no activity beyond the time limits you can add the label DO_NOT_AUTOCLOSE.

@github-actions github-actions bot added the MARKED_FOR_CLOSURE Issue or PR is marked for auto-closure by the GitHub Actions bot. label Jan 17, 2021
@github-actions
Copy link

This issue was closed due to inactivity for 395 days.

@github-actions github-actions bot added the CLOSED_DUE_TO_INACTIVITY Issue or PR has been closed by the GitHub Actions bot due to inactivity. label Feb 17, 2021
bartlettroscoe added a commit that referenced this issue Jun 10, 2022
Origin repo remote tracking branch: 'github/master'
Origin repo remote repo URL: 'github = git@github.com:TriBITSPub/TriBITS.git'
Git describe: Vera4.0-RC1-start-1173-g332f7a44

At commit:

commit e82c4544fbd50769b85bab45cb98ef009ca4643c
Author:  Roscoe A. Bartlett <rabartl@sandia.gov>
Date:    Fri Jun 10 11:08:38 2022 -0600
Summary: Remove internal quotes for git log --pretty=format:<fmnt> strings (#485)
bartlettroscoe added a commit to bartlettroscoe/Trilinos that referenced this issue Jun 29, 2022
…Pub/TriBITS#299)

Somehow, the Trilinos 'develop' branch got a different version of the modules
tribits/common_tools/FindTPLBLAS.cmake and FindTPLLAPACK.cmake that what is in
the TriBITS 'master' branch.  That problem with that is that if you are
building Trilinos with external TriBITS with:

  -DTrilinos_TRIBITS_DIR:STRING=TriBITS/tribits

you get different behavior for finding BLAS and LAPACK than if you are using
the versions in Trilinos.  That is not good and it has cost people real lost
time (e.g. the testing of Trilinos PR trilinos#10614 with an offline email
discussion as part of working TriBITSPub/TriBITS#299).

The fix implemented here was to:

* Copy these modules from Trilinos/cmake/tribits/common_tools/ to
  Trilinos/cmake/TPLs/.

* Point BLAS and LAPACK in Trilinos/TPLsList.cmake to FindTPL*.cmake files
  under cmake/TPLs/ instead of cmake/tribits/common_tools/.

* Make the versions of the FindTPL*.cmake under cmake/tribits/common_tpls/ on
  the Trilinos develop branch to be identical to what is in the currently
  snapshotted version of TriBITS in the merged-in 'tribits_github_snapshot'
  branch.

The current version of TriBITS 'master' snapshotted in is given in the most
current snapshotted commit:

    commit fb578c9 (github/tribits_github_snapshot, tribits_github_snapshot)
    Author: Roscoe A. Bartlett <rabartl@sandia.gov>
    Date:   Fri Jun 10 13:40:24 2022 -0600

        Automatic snapshot commit from tribits at e82c4544

        Origin repo remote tracking branch: 'github/master'
        Origin repo remote repo URL: 'github = git@github.com:TriBITSPub/TriBITS.git'

        At commit:

        commit e82c4544fbd50769b85bab45cb98ef009ca4643c
        Author:  Roscoe A. Bartlett <rabartl@sandia.gov>
        Date:    Fri Jun 10 11:08:38 2022 -0600
        Summary: Remove internal quotes for git log --pretty=format:<fmnt> strings (trilinos#485)

Later, we could sync up the FindTPLBLAS.cmake and FindTPLLAPACK.cmake modules
but that will break someone's backward compatibility.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLOSED_DUE_TO_INACTIVITY Issue or PR has been closed by the GitHub Actions bot due to inactivity. Framework tasks Framework tasks (used internally by Framework team) impacting: configure or build The issue is primarily related to configuring or building MARKED_FOR_CLOSURE Issue or PR is marked for auto-closure by the GitHub Actions bot. system: linux system: manycore type: bug The primary issue is a bug in Trilinos code or tests
Projects
None yet
Development

No branches or pull requests

2 participants