20#ifdef MOOSE_KOKKOS_SCOPE
25KOKKOS_FUNCTION uint32_t
28 auto bytes =
reinterpret_cast<const uint8_t *
>(&key);
30 for (
size_t i = 0; i <
sizeof(T); ++i)
40KOKKOS_FUNCTION uint32_t
46template <
typename T1,
typename T2>
49template <
typename T1,
typename T2>
50KOKKOS_FUNCTION uint32_t
57template <
typename T1,
typename T2,
template <
typename...>
class MapType>
60template <
typename T1,
typename T2,
template <
typename...>
class MapType>
61void dataStore(std::ostream & stream, MapBase<T1, T2, MapType> & map,
void * context);
62template <
typename T1,
typename T2,
template <
typename...>
class MapType>
63void dataLoad(std::istream & stream, MapBase<T1, T2, MapType> & map,
void * context);
70template <
typename T1,
typename T2,
template <
typename...>
class MapType>
93 auto end()
const {
return get().cend(); }
101 _map_host = std::make_shared<MapType<T1, T2>>();
112 _map_host = std::make_shared<MapType<T1, T2>>();
127#ifdef MOOSE_KOKKOS_SCOPE
146 KOKKOS_FUNCTION dof_id_type
size()
const
148 KOKKOS_IF_ON_HOST(
return get().
size();)
157 KOKKOS_FUNCTION dof_id_type
find(
const T1 &
key)
const;
169 KOKKOS_FUNCTION
const T1 &
key(dof_id_type idx)
const
180 KOKKOS_FUNCTION
const T2 &
value(dof_id_type idx)
const
194 KOKKOS_IF_ON_HOST(
return get().at(
key);)
213#ifdef MOOSE_KOKKOS_SCOPE
242template <
typename T1,
typename T2,
template <
typename...>
class MapType>
253#ifdef MOOSE_KOKKOS_SCOPE
254template <
typename T1,
typename T2,
template <
typename...>
class MapType>
258 _keys.create(size());
259 _values.create(size());
260 _offset.create(size() + 1);
263 for (
const auto & [key, value] : get())
270 std::exclusive_scan(_offset.begin(), _offset.end(), _offset.begin(), 0);
272 _offset.copyToDevice();
274 std::vector<dof_id_type> idx(size(), 0);
276 for (
const auto & [key, value] : get())
280 _keys[_offset[bucket] + idx[bucket]] = key;
281 _values[_offset[bucket] + idx[bucket]] = value;
286template <
typename T1,
typename T2,
template <
typename...>
class MapType>
292 _keys.copyToDevice();
293 _values.copyToDevice();
296template <
typename T1,
typename T2,
template <
typename...>
class MapType>
302 _keys.copyToDeviceNested();
303 _values.copyToDeviceNested();
306template <
typename T1,
typename T2,
template <
typename...>
class MapType>
310 get().swap(map.
get());
311 _keys.swap(map.
_keys);
316template <
typename T1,
typename T2,
template <
typename...>
class MapType>
317KOKKOS_FUNCTION dof_id_type
324 auto begin = _offset[bucket];
325 auto end = _offset[bucket + 1];
327 for (dof_id_type i = begin; i < end; ++i)
334template <
typename T1,
typename T2,
template <
typename...>
class MapType>
346template <
typename T1,
typename T2,
template <
typename...>
class MapType>
359template <
typename T1,
typename T2>
362template <
typename T1,
typename T2>
KOKKOS_FUNCTION index_type size() const
Get the total array size.
The Kokkos wrapper class for standard map.
void copyToDeviceNested()
Copy host map to device, perform nested copy for Kokkos arrays.
KOKKOS_FUNCTION const T1 & key(dof_id_type idx) const
Get the key of an index.
auto end()
Get the end writeable iterator of the host map.
void clear()
Clear the underlying data.
Array< T2 > _values
Values on device.
Array< dof_id_type > _offset
Beginning offset into device arrays of each bucket.
auto begin()
Get the beginning writeable iterator of the host map.
auto & get()
Get the underlying writeable host map.
KOKKOS_FUNCTION bool exists(const T1 &key) const
Get whether a key exists.
KOKKOS_FUNCTION const T2 & operator()(const T1 &key) const
Array< T1 > _keys
Keys on device.
KOKKOS_FUNCTION dof_id_type size() const
Get the size of map.
static const dof_id_type invalid_id
std::shared_ptr< MapType< T1, T2 > > _map_host
Standard map on host Stored as a shared pointer to avoid deep copy.
KOKKOS_FUNCTION const T2 & operator[](const T1 &key) const
Get the value corresponding to a key.
auto begin() const
Get the beginning const iterator of the host map.
const auto & get() const
Get the underlying const host map.
KOKKOS_FUNCTION const T2 & value(dof_id_type idx) const
Get the value of an index.
T2 & operator[](const T1 &key)
Call host map's operator[].
void copyToDevice()
Copy host map to device.
void swap(MapBase< T1, T2, MapType > &map)
Swap with another Kokkos map.
void copy()
Internal method to copy host map to device.
KOKKOS_FUNCTION dof_id_type find(const T1 &key) const
Find the index of a key.
auto end() const
Get the end const iterator of the host map.
static constexpr dof_id_type invalid_id
void dataLoad(std::istream &stream, Array< T, dimension, index_type, layout > &array, void *context)
constexpr uint32_t FNV_OFFSET_BASIS
constexpr uint32_t FNV_PRIME
KOKKOS_FUNCTION uint32_t fnv1aHash(const T &key, uint32_t hash)
void dataStore(std::ostream &stream, Array< T, dimension, index_type, layout > &array, void *context)