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

Try using FindOpenMP instead of figuring out flags manually #4105

Merged
merged 7 commits into from
Aug 17, 2022

Conversation

masterleinad
Copy link
Contributor

@masterleinad masterleinad commented Jun 18, 2021

Trying to address #3256 by relying on CMake's FindOpenMP.

@masterleinad
Copy link
Contributor Author

Retest this please.

1 similar comment
@masterleinad
Copy link
Contributor Author

Retest this please.

@masterleinad
Copy link
Contributor Author

This pull currently doesn't add any linker flags but passes our regular CI. It would be good to check this on a somewhat wider ranger of configurations.

@masterleinad masterleinad added this to In progress in Developer: Daniel Arndt Jul 7, 2021
@masterleinad masterleinad moved this from In progress to Awaiting Feedback in Developer: Daniel Arndt Jul 8, 2021
@crtrott crtrott added this to In progress in Kokkos Release 3.5 Jul 14, 2021
@ajpowelsnl ajpowelsnl removed the [WIP] label Jul 15, 2021
@ndellingwood
Copy link
Contributor

I configured and built this PR with intel/17.0.4 and intel/19.0.3 each with cmake/3.16.0 and cmake/3.19.3, there were no issues in any of these cases

@masterleinad
Copy link
Contributor Author

I think the interesting cases to test with are CLANG_CRAY and CLANG_MSVC.

@ndellingwood
Copy link
Contributor

ndellingwood commented Jul 16, 2021

I'm not able to test clang_msvc, here is from my attempt to test with clang_cray that failed to configure (I don't have much experience with that env, so I could be doing something wrong):

Load cray computing env and cmake/3.16.2

module load cce/11.0.2 cmake/3.16.2

clang++ --version
Cray clang version 11.0.2  (7cc96bf2bf88b71c173230d893018a3f38fbbb09)
Target: x86_64-unknown-linux-gnu
Thread model: posix

Configure
Kokkos SHA 4a29d0a

cmake -DCMAKE_CXX_COMPILER=clang++ -DKokkos_ARCH_HSW=ON -DKokkos_ENABLE_OPENMP=ON -DKokkos_ENABLE_TESTS=ON $KOKKOS_PATH

Configure output:

ndellin@voltrino:~/kokkos/testing/Voltrino-HSW-CCE> cmake -DCMAKE_CXX_COMPILER=clang++ -DKokkos_ARCH_HSW=ON -DKokkos_ENABLE_OPENMP=ON -DKokkos_ENABLE_TESTS=ON $KOKKOS_PATH 2>&1 | tee config.out
-- Setting default Kokkos CXX standard to 14
-- The CXX compiler identification is Clang 11.0.0
-- Check for working CXX compiler: /opt/cray/pe/cce/11.0.2/cce-clang/x86_64/bin/clang++
-- Check for working CXX compiler: /opt/cray/pe/cce/11.0.2/cce-clang/x86_64/bin/clang++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Setting build type to 'RelWithDebInfo' as none was specified.
-- Setting policy CMP0074 to use <Package>_ROOT variables
-- The project name is: Kokkos
CMake Warning at cmake/kokkos_check_env.cmake:10 (MESSAGE):
  CRAYPE_LINK_TYPE is not set.  Linking is likely to fail unless this is set
  to 'dynamic'
Call Stack (most recent call first):
  CMakeLists.txt:162 (INCLUDE)


CMake Error at /projects/Voltrino/hpcsoft/cle7.0/common/cmake/3.16.2/share/cmake-3.16/Modules/FindPackageHandleStandardArgs.cmake:146 (message):
  Could NOT find OpenMP_CXX (missing: OpenMP_CXX_FLAGS OpenMP_CXX_LIB_NAMES)
Call Stack (most recent call first):
  /projects/Voltrino/hpcsoft/cle7.0/common/cmake/3.16.2/share/cmake-3.16/Modules/FindPackageHandleStandardArgs.cmake:393 (_FPHSA_FAILURE_MESSAGE)
  /projects/Voltrino/hpcsoft/cle7.0/common/cmake/3.16.2/share/cmake-3.16/Modules/FindOpenMP.cmake:511 (find_package_handle_standard_args)
  cmake/kokkos_enable_devices.cmake:47 (FIND_PACKAGE)
  cmake/kokkos_tribits.cmake:229 (INCLUDE)
  CMakeLists.txt:170 (KOKKOS_SETUP_BUILD_ENVIRONMENT)

Is there anything obvious that I may be doing wrong on my end?

@masterleinad
Copy link
Contributor Author

I almost forgot that I can check myself for clang_cray. On spock, I get

-- Setting default Kokkos CXX standard to 14
-- The CXX compiler identification is Clang 11.0.0
-- Check for working CXX compiler: /opt/cray/pe/craype/2.7.6/bin/CC
-- Check for working CXX compiler: /opt/cray/pe/craype/2.7.6/bin/CC - works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Setting build type to 'RelWithDebInfo' as none was specified.
-- Setting policy CMP0074 to use <Package>_ROOT variables
-- The project name is: Kokkos
CMake Warning at cmake/kokkos_check_env.cmake:10 (MESSAGE):
  CRAYPE_LINK_TYPE is not set.  Linking is likely to fail unless this is set
  to 'dynamic'
Call Stack (most recent call first):
  CMakeLists.txt:162 (INCLUDE)


-- Found OpenMP_CXX: -fopenmp (found version "5.0") 
-- Found OpenMP: TRUE (found version "5.0")  
-- Using -std=gnu++14 for C++14 extensions as feature
-- Built-in Execution Spaces:
--     Device Parallel: NoTypeDefined
--     Host Parallel: Kokkos::OpenMP
--       Host Serial: NONE
-- 
-- Architectures:
-- Found TPLLIBDL: /usr/lib64/libdl.so  
-- Kokkos Devices: OPENMP, Kokkos Backends: OPENMP
-- Configuring done
-- Generating done
-- Build files have been written to: /ccs/home/darndt/kokkos/build_cray

so that seems to work.
@ndellingwood Can you use OpenMP successfully on your system with develop instead of this pull request?

@ndellingwood
Copy link
Contributor

@masterleinad I'm able to get the develop branch to configure,

ndellin@voltrino:~/kokkos/testing/Voltrino-HSW-CCE> cmake -DCMAKE_CXX_COMPILER=clang++ -DKokkos_ARCH_HSW=ON -DKokkos_ENABLE_OPENMP=ON -DKokkos_ENABLE_TESTS=ON $KOKKOS_PATH
-- Setting default Kokkos CXX standard to 14
-- The CXX compiler identification is Clang 11.0.0
-- Check for working CXX compiler: /opt/cray/pe/cce/11.0.2/cce-clang/x86_64/bin/clang++
-- Check for working CXX compiler: /opt/cray/pe/cce/11.0.2/cce-clang/x86_64/bin/clang++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Setting build type to 'RelWithDebInfo' as none was specified.
-- Setting policy CMP0074 to use <Package>_ROOT variables
-- The project name is: Kokkos
CMake Warning at cmake/kokkos_check_env.cmake:10 (MESSAGE):
  CRAYPE_LINK_TYPE is not set.  Linking is likely to fail unless this is set
  to 'dynamic'
Call Stack (most recent call first):
  CMakeLists.txt:162 (INCLUDE)


-- Using -std=gnu++14 for C++14 extensions as feature
-- Built-in Execution Spaces:
--     Device Parallel: NoTypeDefined
--     Host Parallel: Kokkos::OpenMP
--       Host Serial: NONE
-- 
-- Architectures:
--  HSW
-- Found TPLLIBDL: /usr/lib64/libdl.so  
-- Sources TestOpenMP.cpp
-- Kokkos Devices: OPENMP, Kokkos Backends: OPENMP
-- Configuring done
-- Generating done
-- Build files have been written to: /home/ndellin/kokkos/testing/Voltrino-HSW-CCE

However I am running into build errors in this case:

ld.lld: error: unable to find library -lcraymp
clang-11: error: linker command failed with exit code 1 (use -v to see invocation)

@masterleinad masterleinad moved this from In progress to Awaiting Feedback in Kokkos Release 3.5 Jul 20, 2021
@ajpowelsnl ajpowelsnl added the InDevelop Enhancement, fix, etc. has been merged into the develop branch; label Jul 20, 2021
@crtrott crtrott removed the InDevelop Enhancement, fix, etc. has been merged into the develop branch; label Aug 3, 2021
@crtrott
Copy link
Member

crtrott commented Aug 3, 2021

DId you test CUDA + OpenMP?

@crtrott
Copy link
Member

crtrott commented Aug 4, 2021

I did some testing with ICPX for simple OpenMP run, OpenMPTarget, and CUDA+OpenMP even with nvc++ and it all works. So this appears to be good on that front. Still we need to resolve the cray stuff.

@crtrott
Copy link
Member

crtrott commented Dec 16, 2021

@masterleinad is that still WIP? Or does this work now?

@crtrott crtrott moved this from Awaiting Feedback to In progress in Kokkos Release 3.5 Dec 16, 2021
@crtrott crtrott removed this from In progress in Kokkos Release 3.5 Dec 16, 2021
@crtrott crtrott added this to In progress in Kokkos Release 3.6 via automation Dec 16, 2021
@masterleinad
Copy link
Contributor Author

@masterleinad is that still WIP? Or does this work now?

I didn't change anything but I would think that the error in #4105 (comment) is more an issue with the machine being misconfigured. I would be interesting to hear if the problem persists.

@masterleinad
Copy link
Contributor Author

I updated this pull request to just use

IF (Kokkos_ENABLE_OPENMP)
  find_package(OpenMP REQUIRED)
  KOKKOS_EXPORT_CMAKE_TPL(OpenMP REQUIRED)
  target_link_libraries(kokkoscore PUBLIC OpenMP::OpenMP_CXX)
ENDIF()

which is the same approach we use for desul. This would also force Trilinos to use the same path instead of

KOKKOS_LINK_TPL(kokkoscore PUBLIC IMPORTED_NAME OpenMP::OpenMP_CXX OPENMP)

which doesn't do anything for Trilinos.

@junghans
Copy link
Contributor

junghans commented Aug 8, 2022

I guess that would also help in #5184

@masterleinad
Copy link
Contributor Author

One disadvantage of this approach would be that using different compilers for Kokkos and downstream applications causes issues when using OpenMP since the compiler flags for the found target might be different. On the other hand, I wouldn't expect that to be very stable anyway.

@PhilMiller
Copy link
Contributor

One disadvantage of this approach would be that using different compilers for Kokkos and downstream applications causes issues when using OpenMP since the compiler flags for the found target might be different. On the other hand, I wouldn't expect that to be very stable anyway.

Was that ever something we really supported? Is it something we want to explicitly disclaim from 4.0 onward?

Copy link
Contributor

@nmm0 nmm0 left a comment

Choose a reason for hiding this comment

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

Looks good to me

@aminiussi
Copy link

Hi, correct me if I'm wrong, but this fix is not in 3.7.1 right ?
Thanks

@masterleinad
Copy link
Contributor Author

Hi, correct me if I'm wrong, but this fix is not in 3.7.1 right ?

Yes, this feature is only merged to the 4.0.00 release branch.

@aminiussi
Copy link

Thanks. Is there a roadmap page somewhere ?

@masterleinad
Copy link
Contributor Author

Thanks. Is there a roadmap page somewhere ?

We normally only do release notes (#5439, https://github.com/kokkos/kokkos/blob/master/CHANGELOG.md).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Developer: Daniel Arndt
Awaiting Feedback
Development

Successfully merging this pull request may close these issues.

None yet

9 participants