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

Scalar views don't work with Kokkos::Atomic memory trait #69

Closed
crtrott opened this issue Aug 13, 2015 · 1 comment
Closed

Scalar views don't work with Kokkos::Atomic memory trait #69

crtrott opened this issue Aug 13, 2015 · 1 comment
Assignees
Labels
Bug Broken / incorrect code; it could be Kokkos' responsibility, or others’ (e.g., Trilinos)

Comments

@crtrott
Copy link
Member

crtrott commented Aug 13, 2015

The following code doesn't work:

#include <cstdio>

#include <Kokkos_Core.hpp>

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

  Kokkos::initialize();

  typedef Kokkos::View<unsigned int, Kokkos::OpenMP,
                       Kokkos::MemoryTraits<Kokkos::Atomic> > AtomicScalar;

  AtomicScalar atomicScalar("atomicScalar");

  const unsigned int numberOfTasks = 1000;
  Kokkos::parallel_for(Kokkos::RangePolicy<Kokkos::OpenMP>(0, numberOfTasks),
                       KOKKOS_LAMBDA (const unsigned int i) {
                         ++atomicScalar();
                       });

  const unsigned int value = atomicScalar();

  printf("scalar is %u, should be %u\n", value, numberOfTasks);

  Kokkos::finalize();
  return 0;
}

It does work when replacing atomicScalar with a 1D view of length 1.

@crtrott crtrott added the Bug Broken / incorrect code; it could be Kokkos' responsibility, or others’ (e.g., Trilinos) label Aug 13, 2015
crtrott added a commit that referenced this issue Sep 5, 2015
This addresses issue #69
@crtrott
Copy link
Member Author

crtrott commented Sep 16, 2015

Pushed to master.

@crtrott crtrott closed this as completed Sep 16, 2015
@crtrott crtrott self-assigned this Sep 20, 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

1 participant