22 #ifdef MOOSE_KOKKOS_SCOPE 27 KOKKOS_FUNCTION uint32_t
30 auto bytes =
reinterpret_cast<const uint8_t *
>(&key);
32 for (
size_t i = 0; i <
sizeof(T); ++i)
42 KOKKOS_FUNCTION uint32_t
48 template <
typename T1,
typename T2>
51 template <
typename T1,
typename T2>
52 KOKKOS_FUNCTION uint32_t
59 template <
typename T1,
typename T2>
62 template <
typename T1,
typename T2>
64 template <
typename T1,
typename T2>
72 template <
typename T1,
typename T2>
85 auto begin()
const {
return get().cbegin(); }
95 auto end()
const {
return get().cend(); }
103 _map_host = std::make_shared<std::map<T1, T2>>();
111 const auto &
get()
const 114 _map_host = std::make_shared<std::map<T1, T2>>();
125 #ifdef MOOSE_KOKKOS_SCOPE 146 KOKKOS_IF_ON_HOST(
return get().
size();)
192 KOKKOS_IF_ON_HOST(
return get().at(
key);)
211 #ifdef MOOSE_KOKKOS_SCOPE 236 friend void dataStore<T1, T2>(std::ostream &,
Map<T1, T2> &,
void *);
237 friend void dataLoad<T1, T2>(std::istream &,
Map<T1, T2> &,
void *);
240 #ifdef MOOSE_KOKKOS_SCOPE 241 template <
typename T1,
typename T2>
245 _keys.create(size());
246 _values.create(size());
247 _offset.create(size() + 1);
250 for (
const auto & [key,
value] :
get())
257 std::exclusive_scan(_offset.begin(), _offset.end(), _offset.begin(), 0);
259 _offset.copyToDevice();
261 std::vector<dof_id_type>
idx(size(), 0);
263 for (
const auto & [key,
value] :
get())
267 _keys[_offset[bucket] +
idx[bucket]] = key;
268 _values[_offset[bucket] +
idx[bucket]] =
value;
273 template <
typename T1,
typename T2>
279 _keys.copyToDevice();
280 _values.copyToDevice();
283 template <
typename T1,
typename T2>
289 _keys.copyToDeviceNested();
290 _values.copyToDeviceNested();
293 template <
typename T1,
typename T2>
298 _keys.swap(map.
_keys);
303 template <
typename T1,
typename T2>
311 auto begin = _offset[bucket];
312 auto end = _offset[bucket + 1];
321 template <
typename T1,
typename T2>
333 template <
typename T1,
typename T2>
T2 & operator[](const T1 &key)
Call host map's operator[].
constexpr uint32_t FNV_PRIME
auto & get()
Get the underlying writeable host map.
void copyToDevice()
Copy host map to device.
Array< T1 > _keys
Keys on device.
void swap(std::vector< T > &data, const std::size_t idx0, const std::size_t idx1, const libMesh::Parallel::Communicator &comm)
Swap function for serial or distributed vector of data.
std::shared_ptr< std::map< T1, T2 > > _map_host
Standard map on host Stored as a shared pointer to avoid deep copy.
static const dof_id_type invalid_id
void copyToDeviceNested()
Copy host map to device, perform nested copy for Kokkos arrays.
Array< T2 > _values
Values on device.
auto begin() const
Get the beginning const iterator of the host map.
KOKKOS_FUNCTION const T2 & operator()(const T1 &key) const
The Kokkos wrapper class for standard map.
KOKKOS_FUNCTION uint32_t fnv1aHash(const T &key, uint32_t hash)
constexpr uint32_t FNV_OFFSET_BASIS
auto end() const
Get the end const iterator of the host map.
Array< dof_id_type > _offset
Beginning offset into device arrays of each bucket.
void dataLoad(std::istream &stream, Map< T1, T2 > &map, void *context)
KOKKOS_FUNCTION bool exists(const T1 &key) const
Get whether a key exists.
void copy()
Internal method to copy host map to device.
Real value(unsigned n, unsigned alpha, unsigned beta, Real x)
static const dof_id_type invalid_id
KOKKOS_FUNCTION const T2 & value(dof_id_type idx) const
Get the value of an index.
auto end()
Get the end writeable iterator of the host map.
void dataStore(std::ostream &stream, Array< T, dimension > &array, void *context)
KOKKOS_FUNCTION dof_id_type find(const T1 &key) const
Find the index of a key.
void dataLoad(std::istream &stream, Array< T, dimension > &array, void *context)
KOKKOS_FUNCTION const T1 & key(dof_id_type idx) const
Get the key of an index.
void swap(Map< T1, T2 > &map)
Swap with another Kokkos map.
auto begin()
Get the beginning writeable iterator of the host map.
void dataStore(std::ostream &stream, Map< T1, T2 > &map, void *context)
KOKKOS_FUNCTION dof_id_type size() const
Get the size of map.
MOOSE now contains C++17 code, so give a reasonable error message stating what the user can do to add...