20 #ifdef MOOSE_KOKKOS_SCOPE 25 KOKKOS_FUNCTION uint32_t
28 auto bytes =
reinterpret_cast<const uint8_t *
>(&key);
30 for (
size_t i = 0; i <
sizeof(T); ++i)
40 KOKKOS_FUNCTION uint32_t
46 template <
typename T1,
typename T2>
49 template <
typename T1,
typename T2>
50 KOKKOS_FUNCTION uint32_t
57 template <
typename T1,
typename T2,
template <
typename...>
class MapType>
60 template <
typename T1,
typename T2,
template <
typename...>
class MapType>
62 template <
typename T1,
typename T2,
template <
typename...>
class MapType>
70 template <
typename T1,
typename T2,
template <
typename...>
class MapType>
83 auto begin()
const {
return get().cbegin(); }
93 auto end()
const {
return get().cend(); }
101 _map_host = std::make_shared<MapType<T1, T2>>();
109 const auto &
get()
const 112 _map_host = std::make_shared<MapType<T1, T2>>();
127 #ifdef MOOSE_KOKKOS_SCOPE 148 KOKKOS_IF_ON_HOST(
return get().
size();)
194 KOKKOS_IF_ON_HOST(
return get().at(
key);)
213 #ifdef MOOSE_KOKKOS_SCOPE 242 template <
typename T1,
typename T2,
template <
typename...>
class MapType>
253 #ifdef MOOSE_KOKKOS_SCOPE 254 template <
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;
286 template <
typename T1,
typename T2,
template <
typename...>
class MapType>
292 _keys.copyToDevice();
293 _values.copyToDevice();
296 template <
typename T1,
typename T2,
template <
typename...>
class MapType>
302 _keys.copyToDeviceNested();
303 _values.copyToDeviceNested();
306 template <
typename T1,
typename T2,
template <
typename...>
class MapType>
311 _keys.swap(map.
_keys);
316 template <
typename T1,
typename T2,
template <
typename...>
class MapType>
324 auto begin = _offset[bucket];
325 auto end = _offset[bucket + 1];
334 template <
typename T1,
typename T2,
template <
typename...>
class MapType>
346 template <
typename T1,
typename T2,
template <
typename...>
class MapType>
359 template <
typename T1,
typename T2>
362 template <
typename T1,
typename T2>
auto end()
Get the end writeable iterator of the host map.
constexpr uint32_t FNV_PRIME
void copyToDevice()
Copy host map to device.
void dataStore(std::ostream &stream, MapBase< T1, T2, MapType > &map, void *context)
void dataLoad(std::istream &stream, MapBase< T1, T2, MapType > &map, void *context)
void clear()
Clear the underlying data.
KOKKOS_FUNCTION const T2 & value(dof_id_type idx) const
Get the value of an index.
auto & get()
Get the underlying writeable host map.
void dataLoad(std::istream &stream, Array< T, dimension, index_type, layout > &array, void *context)
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.
auto begin() const
Get the beginning const iterator of the host map.
KOKKOS_FUNCTION uint32_t fnv1aHash(const T &key, uint32_t hash)
constexpr uint32_t FNV_OFFSET_BASIS
Real value(unsigned n, unsigned alpha, unsigned beta, Real x)
static constexpr dof_id_type invalid_id
Array< dof_id_type > _offset
Beginning offset into device arrays of each bucket.
KOKKOS_FUNCTION const T1 & key(dof_id_type idx) const
Get the key of an index.
void copyToDeviceNested()
Copy host map to device, perform nested copy for Kokkos arrays.
KOKKOS_FUNCTION index_type size() const
Get the total array size.
void dataStore(std::ostream &stream, Array< T, dimension, index_type, layout > &array, void *context)
Array< T2 > _values
Values on device.
static const dof_id_type invalid_id
The Kokkos wrapper class for standard map.
auto begin()
Get the beginning writeable iterator of the host map.
T2 & operator[](const T1 &key)
Call host map's operator[].
std::shared_ptr< MapType< T1, T2 > > _map_host
Standard map on host Stored as a shared pointer to avoid deep copy.
KOKKOS_FUNCTION dof_id_type size() const
Get the size of map.
KOKKOS_FUNCTION bool exists(const T1 &key) const
Get whether a key exists.
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.
Array< T1 > _keys
Keys on device.
KOKKOS_FUNCTION const T2 & operator()(const T1 &key) const
auto end() const
Get the end const iterator of the host map.