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

Error in subview #2448

Closed
ramanan opened this issue Oct 10, 2019 · 7 comments
Closed

Error in subview #2448

ramanan opened this issue Oct 10, 2019 · 7 comments
Assignees
Labels
Bug Broken / incorrect code; it could be Kokkos' responsibility, or others’ (e.g., Trilinos)

Comments

@ramanan
Copy link

ramanan commented Oct 10, 2019

I have a code that uses subview and it fails to build when using a Cuda build of Kokkos/2.9.00. This was working fine with 2.8.00. See simple reproducer below.

#include <Kokkos_Core.hpp>

int main (int argc, char* argv[]) {
  Kokkos::initialize (argc, argv);

  Kokkos::View<double [120][140][96]> f1;
  Kokkos::View<double ***, Kokkos::LayoutStride> f2;

  f2=Kokkos::subview(f1, Kokkos::ALL(), Kokkos::ALL(), Kokkos::ALL());

  Kokkos::finalize ();
}

The build error is: /opt/sw/Kokkos/BuildCuda10.1_2.9.00/include/impl/Kokkos_ViewMapping.hpp(1065): error: static assertion failed with "ViewOffset subview construction requires compatible rank"

Can you tell me if something is wrong or has changed recently?

@dalg24
Copy link
Member

dalg24 commented Oct 10, 2019

Try this

Kokkos::View<double [120][140][96]> f1("label");
auto f2 = Kokkos::subview(f1, Kokkos::ALL, Kokkos::ALL, Kokkos::ALL);

edit actually it won't compile either with 2.9.00. I was able to reproduce the issue you describe. Need further investigation :/

update broken by d2b10ae

@dhollman
Copy link

Yes, preserving static extents in subview was a feature request that I addressed with that commit you mentioned. I'm surprised, though, that static extents aren't compatible with dynamic extents by default.

Also, what breaks in the auto version? That makes even less sense.

@dhollman dhollman added the Bug Broken / incorrect code; it could be Kokkos' responsibility, or others’ (e.g., Trilinos) label Oct 10, 2019
@dhollman dhollman added this to To do (soon) in Developer: DSHOLLM via automation Oct 10, 2019
@crtrott
Copy link
Member

crtrott commented Oct 11, 2019

Interesting that this breaks while there seems to be a test very very similar:

Kokkos::View<int*[10][5][2], Layout, Space> a;

   KOKKOS_INLINE_FUNCTION
   int operator()() const noexcept
   {
     /* Doesn't actually do anything; just static assertions */

     auto sub_a = Kokkos::subview(a, 0, Kokkos::ALL, Kokkos::ALL, Kokkos::ALL);

@crtrott
Copy link
Member

crtrott commented Oct 11, 2019

Yeah as I thought:
This compiles:

#include <Kokkos_Core.hpp>

int main (int argc, char* argv[]) {
  Kokkos::initialize (argc, argv);

  Kokkos::View<double *[120][140][96]> f1;
  Kokkos::View<double ***, Kokkos::LayoutStride> f2;

  f2=Kokkos::subview(f1, 0,Kokkos::ALL(), Kokkos::ALL(), Kokkos::ALL());

  Kokkos::finalize ();
}

@crtrott
Copy link
Member

crtrott commented Oct 11, 2019

The problem appears to be the take a subview of a view with only static extents, and use ALL() on each dimension. It already appears at minimum rank. In the following example only the last one doesn't compile (creation of f8):

#include <Kokkos_Core.hpp>

int main (int argc, char* argv[]) {
  Kokkos::initialize (argc, argv);

  int n = argc>1?atoi(argv[1]):5;
  Kokkos::View<double *[96]> f1;
  Kokkos::View<double *, Kokkos::LayoutStride> f2;

  f2=Kokkos::subview(f1,0, Kokkos::ALL());

  Kokkos::View<double *[96]> f3;
  Kokkos::View<double **, Kokkos::LayoutStride> f4;

  f4=Kokkos::subview(f3,Kokkos::ALL(), Kokkos::ALL());

  Kokkos::View<double [96]> f5;
  Kokkos::View<double *, Kokkos::LayoutStride> f6;

  f6=Kokkos::subview(f5,Kokkos::pair<int,int>(5,5+n));

  Kokkos::View<double [96]> f7;
  Kokkos::View<double *, Kokkos::LayoutStride> f8;

  f8=Kokkos::subview(f7,Kokkos::ALL());

  Kokkos::finalize ();
}

@dalg24
Copy link
Member

dalg24 commented Oct 16, 2019

@ramanan this will be fixed in release 3.0.
Thanks for reporting this.

@dalg24
Copy link
Member

dalg24 commented Oct 16, 2019

(We just merged the fix into the develop branch.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Broken / incorrect code; it could be Kokkos' responsibility, or others’ (e.g., Trilinos)
Projects
No open projects
Developer: DSHOLLM
  
To do (soon)
Development

No branches or pull requests

5 participants