kokkos / pykokkos-base

Python bindings for data interoperability with Kokkos (View, DynRankView)
Other
26 stars 9 forks source link

Support pykokkos-base as subproject with existing kokkos #35

Closed jrmadsen closed 2 years ago

jrmadsen commented 2 years ago

Example:

cmake_minimum_required(VERSION 3.16.0 FATAL_ERROR)

project(test LANGUAGES CXX)

add_subdirectory(kokkos)
add_subdirectory(pybind11)
add_subdirectory(pykokkos-base)
aminiussi commented 2 years ago

Hi,

I tried to checkout that branch and my cmake shows the following trace:

-- pybind11 v2.9.1 
-- pykokkos-base version 0.0.7
-- Found Git: /opt/software/occigen/tools/git/2.10.2/intel/17.0/nompi/bin/git (found version "2.10.2") 
Submodule 'pybind11' (https://github.com/pybind/pybind11.git) registered for path 'external/pybind11'
Cloning into '/work/CT4/oca7233/aminiussi/fargo/pybind11/external/pykokkos-base/external/pybind11'...
Submodule path 'external/pybind11': checked out 'e25b1505dbca042289c4076141092cff49b0b96b'
[...]

That is, pykokkos-base seems to clone its own pybind11 although it's already there as a submodule.

Is that expected ?

Thanks

[...]
    add_subdirectory(external/kokkos)
[...]
  add_subdirectory(external/pybind11)
  add_subdirectory(external/pykokkos-base)
jrmadsen commented 2 years ago

https://github.com/kokkos/pykokkos-base/blob/fad4a429c3f17e27394a0f108d1b4a75f843bee2/cmake/Modules/KokkosPythonOptions.cmake#L38

jrmadsen commented 2 years ago

Set it to off

jrmadsen commented 2 years ago

Added checks for pybind11::pybind11

aminiussi commented 2 years ago

So eventually, this should work ?

  add_subdirectory(external/kokkos)
  set(ENABLE_INTERNAL_PYBIND11 OFF)
  set(ENABLE_INTERNAL_KOKKOS   OFF)
  add_subdirectory(external/pybind11)
  add_subdirectory(external/pykokkos-base)

It fails with:

-- pybind11 v2.9.1 
-- pykokkos-base version 0.0.7
CMake Error at external/pykokkos-base/cmake/Modules/KokkosPythonKokkos.cmake:27 (FIND_PACKAGE):
  By not providing "FindKokkos.cmake" in CMAKE_MODULE_PATH this project has
  asked CMake to find a package configuration file provided by "Kokkos", but
  CMake did not find one.

  Could not find a package configuration file provided by "Kokkos" with any
  of the following names:

    KokkosConfig.cmake
    kokkos-config.cmake

  Add the installation prefix of "Kokkos" to CMAKE_PREFIX_PATH or set
  "Kokkos_DIR" to a directory containing one of the above files.  If "Kokkos"
  provides a separate development package or SDK, be sure it has been
  installed.
Call Stack (most recent call first):
  external/pykokkos-base/CMakeLists.txt:23 (INCLUDE)

-- Configuring incomplete, errors occurred!

If I change that to:

  add_subdirectory(external/kokkos)
  set(ENABLE_INTERNAL_PYBIND11 OFF)
  set(ENABLE_INTERNAL_KOKKOS   OFF)
#that's where Kokkos will be installed
  set(CMAKE_PREFIX_PATH ${CMAKE_BINARY_DIR}/external/kokkos ${CMAKE_PREFIX_PATH}) 
  add_subdirectory(external/pybind11)
  add_subdirectory(external/pykokkos-base)

I get:

CMake Error at rel/external/kokkos/KokkosConfig.cmake:48 (INCLUDE):
  INCLUDE could not find load file:

    /work/aminiussi/fargo/pybind11/rel/external/kokkos/KokkosTargets.cmake

And then:

CMake Error at rel/external/kokkos/KokkosConfigCommon.cmake:210 (MESSAGE):
  Kokkos could not find 'kokkos_launch_compiler'.  Please set
  '-DKokkos_COMPILE_LAUNCHER=/path/to/launcher'

What are the CMake command I need to enter ?

Thanks

kaschau commented 2 years ago

If you are using an external kokkos installation, I set the environment variable $Kokkos_DIR and it will find the cmake config files it needs

aminiussi commented 2 years ago

I am not really using an external installation. I am importing kokkos as a submodule:

  add_subdirectory(external/kokkos)

So it will be built in ${CMAKE_BINARY_DIR}/external/kokkos but not before I run the build. When cmake sees:

  add_subdirectory(external/pykokkos-base)

where is no $Kokkos_DIR with kokkos compiled. ${CMAKE_BINARY_DIR}/external/kokkos only contains the files cmake produced from processing ${CMAKE_SOURCE_DIR}/external/kokkos.

Thanks

aminiussi commented 2 years ago

And at that point, the CMakeCache does contains:

Kokkos_DIR:PATH=/work/aminiussi/fargo/pybind11/rel/external/kokkos
jrmadsen commented 2 years ago

If you look at this test, it literally does exactly what is described in the PR:

https://github.com/kokkos/pykokkos-base/blob/944b1d0e86d51a86c1edc0e422155d6caf93ecdc/.github/workflows/linux-ci.yml#L228

and it works fine. Try deleting your build folder and starting from scratch.