kokkos / pykokkos-base

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

breaking behavior with kokkos 3.7 #52

Closed kaschau closed 2 years ago

kaschau commented 2 years ago

I have had a stable code using pykokkos base + kokkos 3.6 that is broken with kokkos 3.7 release and pykokkos-base starting with commit a8f4ca6f64897f208a2d6c5f40c2bf11e03ac4b8.

I use structs to hold kokkos arrays, and pybind11 to allow these structs to serve as inheritable classes on a python side. Then use the kokkos module (python side) to set the kokkos array attributes of my c++ structs.

It seems the signature of the kokkos arrays have changed and pybind11 does not recognize the kokkos module's arrays as c++ kokkos arrays anymore. It is failing with

(): incompatible function arguments. The following argument types are supported:
    1. (self: example.thtrdat_, arg0: Kokkos::View<double*, Kokkos::LayoutRight, Kokkos::HostSpace>) -> None

Invoked with: <__main__.thtrdat object at 0x7fe4c2f40c70>, (<kokkos.libpykokkos.KokkosView_float64_HostSpace_LayoutRight_1 object at 0x7fe4bcee74b0>,)
Traceback (most recent call last):
  File "/home/kschau6/test/test.py", line 29, in <module>
    simulate()
  File "/home/kschau6/test/test.py", line 14, in simulate
    test.MW = (
TypeError: (): incompatible function arguments. The following argument types are supported:
    1. (self: example.thtrdat_, arg0: Kokkos::View<double*, Kokkos::LayoutRight, Kokkos::HostSpace>) -> None

Invoked with: <__main__.thtrdat object at 0x7fe4c2f40c70>, (<kokkos.libpykokkos.KokkosView_float64_HostSpace_LayoutRight_1 object at 0x7fe4bcee74b0>,)

A small reproducer is available at https://github.com/kaschau/kokkos37Issue

Using stable branch of pybind11, python 3.9

Does not work with: kokkos3.7, any pykokkos-base branch a8f4ca6f64897f208a2d6c5f40c2bf11e03ac4b8 and after.

Works with: kokkos3.6, and pykokkos-base before a8f4ca6f64897f208a2d6c5f40c2bf11e03ac4b8

NaderAlAwar commented 2 years ago

Commit https://github.com/kokkos/kokkos/commit/5ea4c83e5c0ad69caf389df788707dbe6230d605 added a new template parameter to the View class. In PyKokkos we just set it to Kokkos::Experimental::DefaultViewHooks. Could you try adding that?

kaschau commented 2 years ago

yes adding the Kokkos::Experimental::DefaultViewHooks to the array types on the cpp side seems to have done the trick. Thanks!