47 #ifndef ZOLTAN2_DIRECTORY_H_
48 #define ZOLTAN2_DIRECTORY_H_
50 #include <Teuchos_DefaultComm.hpp>
51 #include <Teuchos_CommHelpers.hpp>
62 #include <Kokkos_UnorderedMap.hpp>
72 template <
typename g
id_t,
typename l
id_t,
typename user_t>
91 template <
typename g
id_t,
typename l
id_t>
102 template <
typename g
id_t,
typename l
id_t>
111 template <
typename g
id_t,
typename l
id_t>
124 template <
typename g
id_t,
typename l
id_t,
typename user_t>
144 Teuchos::RCP<
const Teuchos::Comm<int> > comm_,
163 const int * partition,
174 bool throw_if_missing =
true);
198 for(
size_t n = 0; n <
node_map.capacity(); ++n) {
199 if(
node_map.value_at(n).free == 0) {
200 local_gids[cnt++] =
node_map.key_at(n);
205 throw std::logic_error(
"Unexpected counts. Internal error with the"
206 " node_map behavior.");
215 typedef long long mpi_t;
216 mpi_t nDDEntries =
static_cast<mpi_t
>(
node_map.size());
218 Teuchos::scan(*
comm, Teuchos::REDUCE_SUM,
219 1, &nDDEntries, &firstIdx);
220 firstIdx -= nDDEntries;
222 for(
size_t n = 0; n <
node_map.capacity(); ++n) {
223 if(
node_map.value_at(n).free == 0) {
240 int partition,
int owner);
244 int *partition,
int *owner,
bool throw_if_missing =
true)
const;
255 typedef Kokkos::UnorderedMap<gid_t,
270 unsigned int hash_proc(
const gid_t & gid)
const;
273 Teuchos::RCP<const Teuchos::Comm<int> >
comm;
296 bool throw_if_missing =
true)
const {
return 0; };
301 void rehash_node_map(
size_t new_hash_size) {
306 template <
typename g
id_t,
typename l
id_t,
typename user_t>
333 this->
comm = src.comm;
355 throw std::logic_error(
"Aggregate doesn't mean anything for single "
356 "types. Must use Zoltan2_Directory_Vector class.");
358 throw std::logic_error(
"AggregateAdd doesn't mean anything for single "
359 "types. Must use Zoltan2_Directory_Vector class.");
388 bool throw_if_missing =
true)
const {
399 template <
typename g
id_t,
typename l
id_t,
typename user_t>
426 this->
comm = src.comm;
441 size_t * pLength = (
size_t*)(pRaw);
442 size_t read_array_length = *pLength;
450 dst.resize(read_array_length);
451 for(
size_t i = 0; i < read_array_length; ++i) {
459 if(dst.size() !=
static_cast<size_t>(read_array_length)) {
460 throw std::logic_error(
"The data lengths are not the same size");
463 for(
size_t i = 0; i < dst.size(); ++i) {
480 for(
size_t i = 0; i < read_array_length; ++i) {
482 if(dst.size() == 0 || (*pRead) > dst[dst.size()-1]) {
483 dst.push_back(*pRead);
487 for(
auto itr = dst.begin(); itr != dst.end(); ++itr) {
488 if((*itr) == (*pRead)) {
490 Update_Mode::AggregateAdd) {
495 else if((*itr) > (*pRead)) {
496 dst.insert(itr, (*pRead));
544 for(
size_t i = 0; i < read_array_length; ++i) {
546 for(
auto itr = dst.begin(); itr != dst.end(); ++itr) {
547 if((*itr) == (*pRead)) {
554 dst.push_back(*pRead);
567 size_t *pLength = (
size_t*)(pRaw);
568 *pLength = src.size();
571 for(
size_t n = 0; n < src.size(); ++n) {
580 size_t* pLength = (
size_t*) pRaw;
581 dst.resize(static_cast<size_t>(*pLength));
584 for(
size_t n = 0; n < dst.size(); ++n) {
593 return sizeof(
typename user_t::value_type);
609 size_t * pLength = (
size_t*) (pRaw);
617 bool throw_if_missing =
true)
const {
623 else if(throw_if_missing) {
624 throw std::logic_error(
"Could not find gid in map." );
638 if(msg->
proc == -1) {
646 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