kokkos / kokkos

Kokkos C++ Performance Portability Programming Ecosystem: The Programming Model - Parallel Execution and Memory Abstraction
https://kokkos.org
Other
2.01k stars 436 forks source link

Investigate not allowing atomic views of const element types #7115

Open nmm0 opened 4 months ago

nmm0 commented 4 months ago
  // TODO:  Kokkos allows atomic views of const element types right now,
  //        but for the future we might to deprecated it and do this:
#if 0
  KOKKOS_FUNCTION
  AtomicAccessorRelaxed(const default_accessor<element_type>&) {}

  static_assert(
      std::is_same_v<std::remove_cv_t<element_type>, element_type>,
      "AtomicAccessorRelaxed can only be used for non-const element types");
#endif

https://github.com/kokkos/kokkos/blob/3c35733dd9f227606765ae485b1ad78c09bfd73b/core/src/View/MDSpan/Kokkos_MDSpan_Accessor.hpp#L186-L195

crtrott commented 4 months ago

Some more context: its semantically incorrect for Kokkos users to access a const element type view and expect to see updates from currently running threads on an aliasing non-const element type view. Thus atomic reads on const elements can't be necessary, unless Kokkos semantics are violated.

dalg24 commented 3 months ago

Isn't it a valid use to only want atomic loads?