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

Only search for kokkos if it is not already found #2435

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

JBludau
Copy link

@JBludau JBludau commented Nov 21, 2024

This proposes a partial fix for #2424 Nevertheless, I am not yet sure if we are actually want to go that way

What is the problem:
Kokkos misuses the component feature of CMake to specify if the compiler Kokkos defines as CXX_COMPILER will be launched globally. The default is a global set on everything in the directory. But Kokkos allows to specify separable_compilation as a required component which disables this behavior. Nevertheless, because of the logic that CMake uses to aggregate find_package/dependency commands (see here), we overwrite the user choice if separable_compilation was specified.

If we guard for an already found Kokkos we allow the user to use the separable compilation feature like:

find_package(Kokkos COMPONENTS separable_compilation)
find_package(KokkosKernels)

add_executable(example_with_kokkos example_with_kokkos.cpp)
kokkos_compilation(TARGET example_with_kokkos) #this sets the compiler for the target to the appropriate one
target_link_libraries(example_with_kokkos PRIVATE Kokkos::kokkos Kokkos::kokkoskernels)

add_executable(example_without_kokkos foobar.cpp)
...

Alternative solution:
Kokkos sets the compiler only for the current scope ... so putting your kokkos files in a subdirectory with its own targets and link Kokkos in PRIVATE mode will allow to compile all other directories how the user prefers. Nevertheless this will not work if Kokkos is exposed in the other directories.

What do we need to discuss:

  • does this work with kokkos/kokkos-kernels as part of trilinos
  • This is a misuse of components in CMake ... Kokkos core should think about if this should stay this way.

@rbberger
Copy link
Contributor

Can this workaround at least be merged for a future release while you figure out a long term solution?

@JBludau
Copy link
Author

JBludau commented Dec 20, 2024

@lucbv @cwpearson what do you think? Would you consider this workaround for now? I found a way to get rid of the problems with the components and am currently pushing it into core but it will take some time to convince some people ...

@JBludau JBludau marked this pull request as ready for review December 20, 2024 21:25
@JBludau JBludau mentioned this pull request Dec 21, 2024
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.

2 participants