omega_h
Reliable mesh adaptation
Omega_h_array_kokkos.hpp
1 //
2 // Created by Matthew McCall on 6/8/23.
3 //
4 
5 #ifndef OMEGA_H_ARRAY_KOKKOS_HPP
6 #define OMEGA_H_ARRAY_KOKKOS_HPP
7 
8 namespace Omega_h {
9 
10 template <typename T>
11 OMEGA_H_INLINE Write<T>::Write() : view_() {}
12 
13 template <typename T>
14 OMEGA_H_INLINE LO Write<T>::size() const OMEGA_H_NOEXCEPT {
15 #ifdef OMEGA_H_CHECK_BOUNDS
16  OMEGA_H_CHECK(exists());
17 #endif
18  return static_cast<LO>(view_.size());
19 }
20 
21 template <typename T>
22 OMEGA_H_DEVICE T& Write<T>::operator[](LO i) const OMEGA_H_NOEXCEPT {
23 #ifdef OMEGA_H_CHECK_BOUNDS
24  OMEGA_H_CHECK_OP(0, <=, i);
25  OMEGA_H_CHECK_OP(i, <, size());
26 #endif
27  return view_(i);
28 }
29 
30 template <typename T>
31 OMEGA_H_INLINE T* Write<T>::data() const noexcept {
32  return view_.data();
33 }
34 
35 template <typename T>
36 long Write<T>::use_count() const {
37  return manager_ ? manager_.use_count() : view_.use_count();
38 }
39 
40 template <typename T>
41 OMEGA_H_INLINE bool Write<T>::exists() const noexcept {
42  return view().data() != nullptr
43 #if defined(KOKKOS_ENABLE_DEPRECATED_CODE) && (!defined(__CUDA_ARCH__))
44  /* deprecated Kokkos behavior: zero-span views have data()==nullptr
45  */
46  || view().use_count() != 0
47 #endif
48  ;
49 }
50 
51 template <typename T>
52 inline T const& HostRead<T>::operator[](LO i) const OMEGA_H_NOEXCEPT {
53 #ifdef OMEGA_H_CHECK_BOUNDS
54  OMEGA_H_CHECK_OP(0, <=, i);
55  OMEGA_H_CHECK_OP(i, <, size());
56 #endif
57  return mirror_(i);
58 }
59 
60 template <typename T>
61 inline T& HostWrite<T>::operator[](LO i) const OMEGA_H_NOEXCEPT {
62 #ifdef OMEGA_H_CHECK_BOUNDS
63  OMEGA_H_CHECK_OP(0, <=, i);
64  OMEGA_H_CHECK_OP(i, <, size());
65 #endif
66  return mirror_(i);
67 }
68 
69 } // namespace Omega_h
70 
71 #endif // OMEGA_H_ARRAY_KOKKOS_HPP
Definition: amr_mpi_test.cpp:6