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

Reducers for Tagged operators give wrong answer #1250

Closed
crtrott opened this issue Dec 4, 2017 · 3 comments
Closed

Reducers for Tagged operators give wrong answer #1250

crtrott opened this issue Dec 4, 2017 · 3 comments
Assignees
Labels
Bug Broken / incorrect code; it could be Kokkos' responsibility, or others’ (e.g., Trilinos)
Milestone

Comments

@crtrott
Copy link
Member

crtrott commented Dec 4, 2017

Reproducer:

#include<Kokkos_Core.hpp>

struct TagMin {};
struct functor {
  Kokkos::View<double*> a;

  functor(Kokkos::View<double*> a_):a(a_) {}

  KOKKOS_INLINE_FUNCTION
  void operator() (const TagMin, const int& i, double& val) const {
    if(a(i) < val) val = a(i);
  }
};

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

  Kokkos::View<double*> a("A", 100);
  Kokkos::deep_copy(a,5.0);
  a(5) = 3.0;
  a(7) = 6.0;

  double result = 100;
  Kokkos::parallel_reduce(Kokkos::RangePolicy<TagMin>(0,100), functor(a), Kokkos::Experimental::Min<double>(result));

  printf("Result: %lf\n",result);

  Kokkos::finalize();
}

Prints 0 for building with openmp on SNB with GCC 5.3

@crtrott crtrott added Blocks Promotion Overview issue for release-blocking bugs Bug Broken / incorrect code; it could be Kokkos' responsibility, or others’ (e.g., Trilinos) labels Dec 4, 2017
@crtrott crtrott self-assigned this Dec 4, 2017
@crtrott
Copy link
Member Author

crtrott commented Dec 4, 2017

Works without the tag.

@crtrott
Copy link
Member Author

crtrott commented Dec 5, 2017

Ok got a handle on this: the ValueInit specialisation layer needs to take void instead of the tag if a reducer is provided instead of the functor.

@crtrott
Copy link
Member Author

crtrott commented Dec 5, 2017

I have added a unit test which catches this issues.

crtrott added a commit that referenced this issue Dec 5, 2017
crtrott added a commit that referenced this issue Dec 5, 2017
@crtrott crtrott added this to the 2017 December milestone Dec 5, 2017
@crtrott crtrott removed the Blocks Promotion Overview issue for release-blocking bugs label Dec 5, 2017
@crtrott crtrott closed this as completed Dec 15, 2017
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

1 participant