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

Fix bug in CMakeLists.txt (get_filename_component was using non-existent path as BASE_DIR), use ip@5: if available instead of sp #1090

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

climbfuji
Copy link
Collaborator

@climbfuji climbfuji commented Oct 7, 2024

Description

This PR does two things:

  1. Fix a bug in CMakeLists.txt: The first call to get_filename_component seems to be using an uninitialized (empty) variable LOCAL_CURRENT_SOURCE_DIR as BASE_DIR argument. It would be good if somebody could verify that.
  2. The sp library is deprecated and replaced by ip@5 and newer (drop-in replacement). While [email protected] is still in spack-stack-1.8.0, ip-5.0.0 is also available. We expect sp to be removed in spack-stack-1.9.0.

Because of (2), similar changes need to be made in the host model (SCM: PR to come in a minute, UFS: someone else needs to do).

Note that I cannot compile the SCM on my laptop with GCC, because the SCHEMES_OPENMP_OFF logic seems to be not working as expected (with and without the change made in 1 I believe), therefore I would like to ask someone else to test these two changes, please.

…ent path as BASE_DIR), use ip@5: if available instead of sp
Copy link
Collaborator

@dustinswales dustinswales left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@climbfuji Thanks for making these changes.
@grantfirl Is there and open ccpp-physics:ufs/dev PR that I(you) could add this on the UFS side?

@climbfuji
Copy link
Collaborator Author

ping

@grantfirl grantfirl requested a review from rhaesung as a code owner January 17, 2025 00:27
Copy link
Collaborator

@grantfirl grantfirl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree that LOCAL_CURRENT_SOURCE_DIR is empty.

Copy link
Collaborator

@grantfirl grantfirl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something about switching to ip/5.0.0 is causing compilation of RRTMGP to fail. @dustinswales

@dustinswales
Copy link
Collaborator

dustinswales commented Jan 27, 2025

@grantfirl I needed to add the following to the CMakeLists.txt for things to work with GP:
if(SCHEMES_OPENMP_OFF)
SET_PROPERTY(SOURCE ${SCHEMES_OPENMP_OFF}
APPEND_STRING PROPERTY COMPILE_FLAGS " ${CMAKE_Fortran_FLAGS_PHYSICS} -qno-openmp ")
list(REMOVE_ITEM SCHEMES ${SCHEMES_OPENMP_OFF})

I'm not sure if this is the ideal solution though?
Also, I can't understand why we NOW need this flag. Is it that the flags come down from above and they aren't getting set correctly for the new spack-stack version?
@climbfuji

@climbfuji
Copy link
Collaborator Author

@grantfirl I needed to add the following to the CMakeLists.txt for things to work with GP: if(SCHEMES_OPENMP_OFF) SET_PROPERTY(SOURCE ${SCHEMES_OPENMP_OFF} APPEND_STRING PROPERTY COMPILE_FLAGS " ${CMAKE_Fortran_FLAGS_PHYSICS} -qno-openmp ") list(REMOVE_ITEM SCHEMES ${SCHEMES_OPENMP_OFF})

I'm not sure if this is the ideal solution though? Also, I can't understand why we NOW need this flag. Is it that the flags come down from above and they aren't getting set correctly for the new spack-stack version? @climbfuji

Pretty sure that one of the dependencies (maybe ip) defines itself as a cmake target with the openmp flags incorrectly assigned as public.

Note that your -qno-openmp` is Intel-specific, will need to define the no-openmp flag for each compiler.

@dustinswales
Copy link
Collaborator

Pretty sure that one of the dependencies (maybe ip) defines itself as a cmake target with the openmp flags incorrectly assigned as public.
This seems plausible to me. How to we confirm this is the case? Or do we even care for this PR switching from SP to IP? Is this more of a spack-stack problem?

Note that your -qno-openmp` is Intel-specific, will need to define the no-openmp flag for each compiler.
Yeah, that's why I didn't this was the solution and the flags are being corrupted further up.

@climbfuji
Copy link
Collaborator Author

Pretty sure that one of the dependencies (maybe ip) defines itself as a cmake target with the openmp flags incorrectly assigned as public.
This seems plausible to me. How to we confirm this is the case? Or do we even care for this PR switching from SP to IP? Is this more of a spack-stack problem?

It's going to be your problem, because spack-stack-1.10 definitely won't have sp anymore, maybe even spack-stack-1.9.0.

Confirming is easy, just look in the cmake target definitions of the ip library. Example:

> cat ../../neptune/spack-stack/spack-stack-neptune-1.5/envs/ne-oneapi-2024.2.1/install/oneapi/2024.2.1/ip-5.1.0-6uutwti/lib64/cmake/ip/ip-targets.cmake

# Create imported target ip::ip_4
add_library(ip::ip_4 STATIC IMPORTED)

set_target_properties(ip::ip_4 PROPERTIES
  INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include_4"
  INTERFACE_LINK_LIBRARIES "OpenMP::OpenMP_Fortran;LAPACK::LAPACK"
)

# Create imported target ip::ip_d
add_library(ip::ip_d STATIC IMPORTED)

set_target_properties(ip::ip_d PROPERTIES
  INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include_d"
  INTERFACE_LINK_LIBRARIES "OpenMP::OpenMP_Fortran;LAPACK::LAPACK"
)

# Create imported target ip::ip_8
add_library(ip::ip_8 STATIC IMPORTED)

set_target_properties(ip::ip_8 PROPERTIES
  INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include_8"
  INTERFACE_LINK_LIBRARIES "OpenMP::OpenMP_Fortran;LAPACK::LAPACK"
)

Note that your -qno-openmp` is Intel-specific, will need to define the no-openmp flag for each compiler.
Yeah, that's why I didn't this was the solution and the flags are being corrupted further up.

@climbfuji
Copy link
Collaborator Author

See also NOAA-EMC/NCEPLIBS-ip#234

@dustinswales
Copy link
Collaborator

Pretty sure that one of the dependencies (maybe ip) defines itself as a cmake target with the openmp flags incorrectly assigned as public.
This seems plausible to me. How to we confirm this is the case? Or do we even care for this PR switching from SP to IP? Is this more of a spack-stack problem?

It's going to be your problem, because spack-stack-1.10 definitely won't have sp anymore, maybe even spack-stack-1.9.0.

Confirming is easy, just look in the cmake target definitions of the ip library. Example:

> cat ../../neptune/spack-stack/spack-stack-neptune-1.5/envs/ne-oneapi-2024.2.1/install/oneapi/2024.2.1/ip-5.1.0-6uutwti/lib64/cmake/ip/ip-targets.cmake

# Create imported target ip::ip_4
add_library(ip::ip_4 STATIC IMPORTED)

set_target_properties(ip::ip_4 PROPERTIES
  INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include_4"
  INTERFACE_LINK_LIBRARIES "OpenMP::OpenMP_Fortran;LAPACK::LAPACK"
)

# Create imported target ip::ip_d
add_library(ip::ip_d STATIC IMPORTED)

set_target_properties(ip::ip_d PROPERTIES
  INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include_d"
  INTERFACE_LINK_LIBRARIES "OpenMP::OpenMP_Fortran;LAPACK::LAPACK"
)

# Create imported target ip::ip_8
add_library(ip::ip_8 STATIC IMPORTED)

set_target_properties(ip::ip_8 PROPERTIES
  INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include_8"
  INTERFACE_LINK_LIBRARIES "OpenMP::OpenMP_Fortran;LAPACK::LAPACK"
)

Note that your -qno-openmp` is Intel-specific, will need to define the no-openmp flag for each compiler.
Yeah, that's why I didn't this was the solution and the flags are being corrupted further up.

@climbfuji Is it not the case that whoever builds spack-stack-1.9, and onwards, for the UWM will have to build the IP target correctly? Which will then be available for the SCM?

@climbfuji
Copy link
Collaborator Author

If your testing with the PRIVATE directive works well, we can ask the NCEPLIBS-ip developers to fix their package and then switching shouldn't be a problem once sp is gone.

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 this pull request may close these issues.

4 participants