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

CMake Standalone Support #674

Closed
crtrott opened this issue Mar 8, 2017 · 14 comments
Closed

CMake Standalone Support #674

crtrott opened this issue Mar 8, 2017 · 14 comments
Labels
Feature Request Create new capability; will potentially require voting
Milestone

Comments

@crtrott
Copy link
Member

crtrott commented Mar 8, 2017

There are 2 use cases for building Kokkos:

  1. Build against an already installed library.
  2. Build Kokkos as part of the application build.

The first is addressed by @pkestene in #633.

The second is being addressed by @gmackey and has the following dependent tickets:
#243
#629
#654
#667
#668
#688

@crtrott crtrott added this to the 2017-April-end milestone Mar 8, 2017
@crtrott crtrott added the Feature Request Create new capability; will potentially require voting label Mar 8, 2017
@gmackey
Copy link
Contributor

gmackey commented Mar 17, 2017

The first use case is already in develop.

@gmackey
Copy link
Contributor

gmackey commented Mar 29, 2017

The cmake branch in my fork also includes improvements to the Makefile build and to the snapshot script The tickets related to those are
#697
#673
#701
#702
#703
#704
#705
#706
#717

@dholladay00
Copy link

If I want to use a branch with this feature, is build-cleanup or task-dag the better choice?

@crtrott crtrott modified the milestones: 2017-April-end, 2017-June-end Apr 26, 2017
@bjoo
Copy link
Contributor

bjoo commented May 5, 2017

Question: Does the standalone CMake support a 'make install' target? E.g. at the Kokkos Training, I dropped kokkos/ into a subdirectory of my mini-app, which is a library + unit tests. When I type make, Kokkos is built and is linked with my library. However, when I type 'make install' only my library components are installed but Kokkos is not.

Would there be an issue if someone wanted to link against my library?

@crtrott
Copy link
Member Author

crtrott commented May 5, 2017

Looks like that install thing is missing. And yes for a library you would want to install kokkos along side your library.

@dholladay00
Copy link

In my case, I believe applications that link against my library must also link against kokkos.

I'm guessing there's a way for cmake to include kokkos in the make install step though.

@crtrott
Copy link
Member Author

crtrott commented May 5, 2017

Actually you might just need to add the kokkos library to your list of things that need installing (in your libraries install command).

@bjoo
Copy link
Contributor

bjoo commented May 9, 2017

I tried this and tried adding

install(TARGETS kokkos DESTINATION kokkos)

in various places ( My toplevel CMakeLists.txt, or the one in my lib/ Directory)
I also tried adding it into the kokkos.cmake file in the kokkos/cmake/ dir.
None of these worked, tho I am a relative newcomer to CMake, so it may be my fault.

One thing I could probably do is install the whole kokkos subdirectory. But then clients of my
library would need to rebuild it, so that seems the wrong approach.

I can try to look at the CMakeLists.txt files in Kokkos, but I don't want to mess anything up for TriBits builds.

@dholladay00
Copy link

From what I can tell, Kokkos is meant to be built with the rest of the application. If you look at how their examples and tutorial Makefiles are structured, that is what they do. The main reason I can think of is combinatorics, but they could have other motivations. The Kokkos developers could answer that better than I.

It can be prebuilt and linked against, but I don't think it is recommended. Also, going that route, you can use their makefile generator script and build kokkos without needing to use their cmake at all. You could also look into the recently added Kokkos Spack module.

Another potential option is, if machines already have Trilinos, to link against the Trilinos-Kokkos libraries (that process is slightly different from standalone Kokkos though). Also, in that case, you're stuck with whatever configuration the Trilinos-Kokkos was built with.

As someone who has used the above methods (Trilinos didn't work for me b/c that version did not have the features I needed), my experiences tell me to recommend building with the application.

@bjoo
Copy link
Contributor

bjoo commented May 9, 2017 via email

@dholladay00
Copy link

I see … There is probably a cmake-y way to add Kokkos as one of the install targets, but I'm not familiar with that.

@pfultz2
Copy link
Contributor

pfultz2 commented May 9, 2017

Actually, you can export the targets, so they can be used downstream. This article here explains a simple way of doing that(however a slightly different approach is needed if kokkos uses imported targets):

  add_library(
    kokkoscore
    ${KOKKOS_CORE_SRCS}
  )

  # Adjust the include directories so the installed target doesn't include
  # files from the build and source directories
  target_include_directories(
    kokkoscore
    PUBLIC $<BUILD_INTERFACE:${Kokkos_SOURCE_DIR}/core/src>
    PUBLIC $<BUILD_INTERFACE:${KOKKOS_INCLUDE_DIRS}>
    PUBLIC $<BUILD_INTERFACE:${Kokkos_BINARY_DIR}>     # To include generated KokkosCore_config.h.
    SYSTEM PUBLIC $<INSTALL_INTERFACE:$<INSTALL_PREFIX>/include>
  )

  # ... the rest of the targets

  # Install the kokkos library targets
  install(TARGETS kokkoscore kokkos kokkoscontainers kokkosalgorithms EXPORT kokkos-config
    ARCHIVE  DESTINATION ${CMAKE_INSTALL_LIBDIR}
    LIBRARY  DESTINATION ${CMAKE_INSTALL_LIBDIR}
    RUNTIME  DESTINATION ${CMAKE_INSTALL_BINDIR})

  # Install the kokkos exported targets
  install(EXPORT kokkos-config DESTINATION share/kokkos/cmake)

  # Export the targets
  export(TARGETS kokkoscore kokkos kokkoscontainers kokkosalgorithms FILE kokkos-config.cmake)

Then the user can do:

find_package(kokkos)
add_library(foo foo.cpp)
target_link_libraries(foo kokkoscore)

@ibaned
Copy link
Contributor

ibaned commented May 9, 2017

I wrote a set of CMake helper functions to automate some of the trickier parts of this:

https://github.com/ibaned/cmake_bob

@bjoo
Copy link
Contributor

bjoo commented May 9, 2017

Thanks Paul, Dan I will work through these.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature Request Create new capability; will potentially require voting
Projects
None yet
Development

No branches or pull requests

6 participants