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

Kokkos::sort fails for view with all the same values #422

Closed
mndevec opened this issue Sep 7, 2016 · 4 comments
Closed

Kokkos::sort fails for view with all the same values #422

mndevec opened this issue Sep 7, 2016 · 4 comments
Assignees
Labels
Bug Broken / incorrect code; it could be Kokkos' responsibility, or others’ (e.g., Trilinos)
Milestone

Comments

@mndevec
Copy link

mndevec commented Sep 7, 2016

Kokkos sort seems to be failing with messages
':0: : block: [0,0,0], thread: [0,93,0] Assertion View bounds error failed.'
when it is run with a view which has its all values exactly same. A simple example is below.

#include <Kokkos_Core.hpp>
#include<Kokkos_Sort.hpp>
#include<Kokkos_Random.hpp>
typedef typename Kokkos::Cuda MyExecSpace;
//typedef typename Kokkos::OpenMP MyExecSpace;

int  main (int  argc, char ** argv){
  Kokkos::initialize( );
  int n = 256;
  typedef Kokkos::View<int*,MyExecSpace> KeyViewType;
  KeyViewType keys("Keys",n);
  Kokkos::fence();
  Kokkos::sort(keys,true);
  Kokkos::fence();
  Kokkos::finalize();

  return 0;
}

Also, the array in the below example somehow triggering a similar error in sort function. Errors occur with openmp as well, if the second argument of sort is provided as true.

#include <Kokkos_Core.hpp>
#include<Kokkos_Sort.hpp>
#include<Kokkos_Random.hpp>
typedef typename Kokkos::Cuda MyExecSpace;
//typedef typename Kokkos::OpenMP MyExecSpace;
int myarray[] = {18364,19072,18320,19734,19955,23360,21902,22788,21859,23628,22744,24204,26327,24912,26460,28053,25575,27168,27213,27922,28805,31638,31593,32522,29469,34470,36509,33009,34426,37880,37171,40641,40649,37788,40525,39105,40634,38401,40758,39329,40678,38952,37896,38600,38604,40570,38633,38540,39295,39405,41302,42305,41977,42765,44898,44998,45015,42213,41722,42107,41596,44089,43511,43113,46179,46459,45099,45119,45431,46487,45395,45334,48295,46730,48315,48279,45706,46111,47437,48214,47839,47607,46769,46775,47247,47484,45693,49230,52616,49275,49784,50613,49647,50458,50492,50446,50580,51908,51154,53472,53464,53545,53561,53605,56288,53589,53513,54164,60713,66319,69563,67439};

int  main (int  argc, char ** argv){

  Kokkos::initialize( );
  typedef int KeyType;
  typedef Kokkos::View<KeyType*,MyExecSpace> KeyViewType;

  int n = 112;
  KeyViewType keys("Keys",n);

  auto h_keys = Kokkos::create_mirror_view (keys);
  for (int i = 0; i < n; ++i){
   h_keys(i) = myarray[i];
  }
  Kokkos::deep_copy(keys,h_keys);
  Kokkos::fence();
  Kokkos::sort(keys,true);

  Kokkos::finalize();

  return 0;
}
@mndevec mndevec changed the title Kokkos::sort fails with Kokkos::sort fails Sep 7, 2016
@mndevec
Copy link
Author

mndevec commented Sep 7, 2016

For the second issue, it seems that it has nothing to do with the array values. The views that have lengths of 112 and 56 are causing Kokkos::sort to fail.

@crtrott
Copy link
Member

crtrott commented Sep 7, 2016

Ok I saw what happens, the automatic determination of the range of values comes back with the range is null. The inverse of it (which is used in the index calculations) comes back as inf. This particular error can only happen if all values are the same. I mark this as a bug and we'll put it in the next milestone.

@crtrott crtrott added the Bug Broken / incorrect code; it could be Kokkos' responsibility, or others’ (e.g., Trilinos) label Sep 7, 2016
@crtrott crtrott added this to the Fall 2016 milestone Sep 7, 2016
@crtrott crtrott self-assigned this Sep 7, 2016
@crtrott crtrott changed the title Kokkos::sort fails Kokkos::sort fails for view with all the same values Sep 7, 2016
@mndevec
Copy link
Author

mndevec commented Sep 7, 2016

Thank Christian,
Were you able to reproduce the second issue?

@crtrott
Copy link
Member

crtrott commented Sep 19, 2016

I pushed a fix which makes both examples work. I also added a unit test for the "all keys are the same" situation.

@crtrott crtrott closed this as completed Sep 27, 2016
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
None yet
Development

No branches or pull requests

2 participants