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

Serialize kokkos views #1

Closed
lifflander opened this issue Oct 26, 2018 · 1 comment
Closed

Serialize kokkos views #1

lifflander opened this issue Oct 26, 2018 · 1 comment
Assignees

Comments

@lifflander
Copy link
Contributor

This is being implemented by @mperrinel with help from @nmm0

Please track progress on this in this issue.

lifflander added a commit that referenced this issue Nov 1, 2018
lifflander added a commit that referenced this issue Nov 1, 2018
lifflander added a commit that referenced this issue Nov 1, 2018
@lifflander
Copy link
Contributor Author

Test are now passing for Kokkos::View<T,Args...> and Kokkos::Experimental::DynamicView<T,Args...> for a wide range of T. See checkpoint/tests/unit/kokkos-serialize.cc for the full set of tests.

The unit tests pass with three layouts: LayoutLeft, LayoutRight, and LayoutStride.

For each of these three layouts, these View types (T) are tested in 1-D, 2-D, and 3-D:

using Test1DTypes = std::tuple<
  int      *, int      [1], int      [4],
  double   *, double   [1], double   [4],
  float    *, float    [1], float    [4],
  int32_t  *, int32_t  [1], int32_t  [4],
  int64_t  *, int64_t  [1], int64_t  [4],
  unsigned *, unsigned [1], unsigned [4],
  long     *, long     [1], long     [4],
  long long*, long long[1], long long[4]
>;

using Test2DTypes = std::tuple<
  int      **, int      *[1], int      *[4],
  double   **, double   *[1], double   *[4],
  float    **, float    *[1], float    *[4],
  int32_t  **, int32_t  *[1], int32_t  *[4],
  int64_t  **, int64_t  *[1], int64_t  *[4],
  unsigned **, unsigned *[1], unsigned *[4],
  long     **, long     *[1], long     *[4],
  long long**, long long*[1], long long*[4]
>;

using Test3DTypes = std::tuple<
  int      ***, int      **[1], int      **[9],
  double   ***, double   **[1], double   **[9],
  float    ***, float    **[1], float    **[9],
  int32_t  ***, int32_t  **[1], int32_t  **[9],
  int64_t  ***, int64_t  **[1], int64_t  **[9],
  unsigned ***, unsigned **[1], unsigned **[9],
  long     ***, long     **[1], long     **[9],
  long long***, long long**[1], long long**[9]
>;

The unit tests check deep equality between the views by accessing the data and comparing values before and after serialization.

The final integration test utilizes a class with multiple views, std::vector, and other data and checks for correctness by populating the data and asserting the data values are identical after serialization and deserialization.

struct BaseData { int a = 10; };
struct Data : BaseData {
  using Kokkos_ViewType1 = ::Kokkos::View<int*,     Kokkos::LayoutLeft>;
  using Kokkos_ViewType2 = ::Kokkos::View<double**, Kokkos::LayoutRight>;
  using Kokkos_ViewType3 = ::Kokkos::View<float***>;
  using Kokkos_ViewType4 = ::Kokkos::View<int*[2]>;
 
 //...

private:
  std::vector<int> vec = {};
  int val1 = 1, val2 = 2;
  Kokkos_ViewType1 v1;
  Kokkos_ViewType2 v2;
  Kokkos_ViewType3 v3;
  Kokkos_ViewType4 v4;
};

lifflander added a commit that referenced this issue Nov 3, 2018
This currently doesn't work with Kokkos::LayoutStride. If you try, the
Kokkos::View constructor will encounter a false static_assert on
Kokkos_View::2215.

static_assert(
  traits::array_layout::is_extent_constructible,
  "Layout is not extent constructible. A layout object should be passed too.\n"
 );
lifflander added a commit that referenced this issue Nov 3, 2018
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

No branches or pull requests

3 participants