10 #ifndef ZOLTAN2_DIRECTORY_H_
11 #define ZOLTAN2_DIRECTORY_H_
13 #include <Teuchos_DefaultComm.hpp>
14 #include <Teuchos_CommHelpers.hpp>
25 #include <Kokkos_UnorderedMap.hpp>
35 template <
typename g
id_t,
typename l
id_t,
typename user_t>
54 template <
typename g
id_t,
typename l
id_t>
65 template <
typename g
id_t,
typename l
id_t>
74 template <
typename g
id_t,
typename l
id_t>
87 template <
typename g
id_t,
typename l
id_t,
typename user_t>
107 Teuchos::RCP<
const Teuchos::Comm<int> > comm_,
126 const int * partition,
137 bool throw_if_missing =
true);
161 for(
size_t n = 0; n <
node_map.capacity(); ++n) {
162 if(
node_map.value_at(n).free == 0) {
163 local_gids[cnt++] =
node_map.key_at(n);
168 throw std::logic_error(
"Unexpected counts. Internal error with the"
169 " node_map behavior.");
178 typedef long long mpi_t;
179 mpi_t nDDEntries =
static_cast<mpi_t
>(
node_map.size());
181 Teuchos::scan(*
comm, Teuchos::REDUCE_SUM,
182 1, &nDDEntries, &firstIdx);
183 firstIdx -= nDDEntries;
185 for(
size_t n = 0; n <
node_map.capacity(); ++n) {
186 if(
node_map.value_at(n).free == 0) {
203 int partition,
int owner);
207 int *partition,
int *owner,
bool throw_if_missing =
true)
const;
218 typedef Kokkos::UnorderedMap<gid_t,
233 unsigned int hash_proc(
const gid_t & gid)
const;
236 Teuchos::RCP<const Teuchos::Comm<int> >
comm;
259 bool throw_if_missing =
true)
const {
return 0; };
264 void rehash_node_map(
size_t new_hash_size) {
269 template <
typename g
id_t,
typename l
id_t,
typename user_t>
296 this->
comm = src.comm;
318 throw std::logic_error(
"Aggregate doesn't mean anything for single "
319 "types. Must use Zoltan2_Directory_Vector class.");
321 throw std::logic_error(
"AggregateAdd doesn't mean anything for single "
322 "types. Must use Zoltan2_Directory_Vector class.");
351 bool throw_if_missing =
true)
const {
362 template <
typename g
id_t,
typename l
id_t,
typename user_t>
389 this->
comm = src.comm;
404 size_t * pLength = (
size_t*)(pRaw);
405 size_t read_array_length = *pLength;
413 dst.resize(read_array_length);
414 for(
size_t i = 0; i < read_array_length; ++i) {
422 if(dst.size() !=
static_cast<size_t>(read_array_length)) {
423 throw std::logic_error(
"The data lengths are not the same size");
426 for(
size_t i = 0; i < dst.size(); ++i) {
443 for(
size_t i = 0; i < read_array_length; ++i) {
445 if(dst.size() == 0 || (*pRead) > dst[dst.size()-1]) {
446 dst.push_back(*pRead);
450 for(
auto itr = dst.begin(); itr != dst.end(); ++itr) {
451 if((*itr) == (*pRead)) {
453 Update_Mode::AggregateAdd) {
458 else if((*itr) > (*pRead)) {
459 dst.insert(itr, (*pRead));
507 for(
size_t i = 0; i < read_array_length; ++i) {
509 for(
auto itr = dst.begin(); itr != dst.end(); ++itr) {
510 if((*itr) == (*pRead)) {
517 dst.push_back(*pRead);
530 size_t *pLength = (
size_t*)(pRaw);
531 *pLength = src.size();
534 for(
size_t n = 0; n < src.size(); ++n) {
543 size_t* pLength = (
size_t*) pRaw;
544 dst.resize(static_cast<size_t>(*pLength));
547 for(
size_t n = 0; n < dst.size(); ++n) {
556 return sizeof(
typename user_t::value_type);
572 size_t * pLength = (
size_t*) (pRaw);
580 bool throw_if_missing =
true)
const {
586 else if(throw_if_missing) {
587 throw std::logic_error(
"Could not find gid in map." );
601 if(msg->
proc == -1) {
609 size_t * pVectorLength =
virtual size_t get_local_find_msg_size(gid_t *gid, bool throw_if_missing=true) const
int find(size_t length, const gid_t *gid, lid_t *lid, user_t *user, int *partition, int *owner, bool throw_if_missing=true)
Can be Replace, Add, or Aggregate.
virtual size_t get_local_find_msg_size(gid_t *gid, bool throw_if_missing=true) const
int update(size_t length, const gid_t *gid, const lid_t *lid, const user_t *user, const int *partition, Update_Mode update_mode)
update is called by user to submit new data.
virtual bool is_Zoltan2_Directory_Vector() const
For std::vector user data, aggregates all data so for example [1,2,5] and [3,5] becomes [1...
Zoltan2_Directory(Teuchos::RCP< const Teuchos::Comm< int > > comm_, bool use_lid_, int debug_level_)
Construct Zoltan2_Directory (abstract class).
virtual void update_local_user(const user_t *pRaw, user_t &dst)
All values from different procs are summed.
virtual bool is_Zoltan2_Directory_Vector() const
void stats() const
stats. New Kokkos mode needs further development.
int remove_local(gid_t *gid)
virtual void raw_to_user(const user_t *pRaw, user_t &dst) const
int print() const
gids to remove.
virtual size_t size_of_value_type() const
void get_locally_managed_gids(std::vector< gid_t > &local_gids) const
virtual size_t get_update_msg_size(const user_t *pRaw) const
int copy(const Zoltan2_Directory< gid_t, lid_t, user_t > &dd)
virtual void user_to_raw(const user_t &src, user_t *pRaw) const
virtual size_t size_of_value_type() const
size_t node_map_size() const
The new value replaces the original value.
int update_local(gid_t *gid, lid_t *lid, user_t *user, int partition, int owner)
Update_Mode
Update_Mode determines how update executes.
virtual size_t get_update_msg_size(const user_t *pRaw) const
virtual size_t get_incoming_find_msg_size(Zoltan2_DD_Find_Msg< gid_t, lid_t > *msg) const
Teuchos::RCP< const Teuchos::Comm< int > > comm
virtual void update_local_user(const user_t *pRaw, user_t &dst)
virtual size_t get_local_find_msg_size(gid_t *gid, bool throw_if_missing=true) const
virtual ~Zoltan2_Directory()
Destructor currently does nothing.
virtual void raw_to_user(const user_t *pRaw, user_t &dst) const
virtual size_t get_update_msg_size(const user_t &data) const
unsigned int hash_proc(const gid_t &gid) const
virtual size_t get_incoming_find_msg_size(Zoltan2_DD_Find_Msg< gid_t, lid_t > *msg) const
Zoltan2_Directory_Vector(const Zoltan2_Directory_Vector< gid_t, lid_t, user_t > &src)
Copy constructor.
virtual size_t get_update_msg_size(const user_t &data) const
virtual void user_to_raw(const user_t &src, user_t *pRaw) const
virtual size_t get_update_msg_size(const user_t &data) const
int find_local(gid_t *gid, lid_t *lid, user_t *user, int *partition, int *owner, bool throw_if_missing=true) const
Kokkos::UnorderedMap< gid_t, Zoltan2_Directory_Node< gid_t, lid_t, user_t >, Kokkos::HostSpace > node_map_t
bool is_use_lid() const
returns true if the directory is handling local ids.
virtual bool is_Zoltan2_Directory_Vector() const
user_t::value_type user_val_t
virtual size_t get_incoming_find_msg_size(Zoltan2_DD_Find_Msg< gid_t, lid_t > *msg) const
void remap_user_data_as_unique_gids()
virtual size_t size_of_value_type() const
virtual void update_local_user(const user_t *pRaw, user_t &dst)
Zoltan2_Directory_Simple(const Zoltan2_Directory_Simple< gid_t, lid_t, user_t > &src)
Copy constructor.
virtual size_t get_update_msg_size(const user_t *pRaw) const
virtual void user_to_raw(const user_t &src, user_t *pRaw) const
Zoltan2_Directory is an abstract base class.
In progress and needs discussion. Currently this mode will use operator== to determine if two items m...
Zoltan2_Directory_Vector(Teuchos::RCP< const Teuchos::Comm< int > > comm_, bool use_lid_, int debug_level_)
Constructo directory which handles std::vector user data types.
virtual void raw_to_user(const user_t *pRaw, user_t &dst) const
Zoltan2_Directory_Simple(Teuchos::RCP< const Teuchos::Comm< int > > comm_, bool use_lid_, int debug_level_)
Constructo directory which handles simple user data types.
Zoltan2::BasicUserTypes< zscalar_t, zlno_t, zgno_t > user_t