47 #ifndef ZOLTAN2_DIRECTORY_H_
48 #define ZOLTAN2_DIRECTORY_H_
50 #include <Teuchos_DefaultComm.hpp>
61 #include <Kokkos_UnorderedMap.hpp>
71 template <
typename g
id_t,
typename l
id_t,
typename user_t>
90 template <
typename g
id_t,
typename l
id_t>
101 template <
typename g
id_t,
typename l
id_t>
110 template <
typename g
id_t,
typename l
id_t>
123 template <
typename g
id_t,
typename l
id_t,
typename user_t>
143 Teuchos::RCP<
const Teuchos::Comm<int> > comm_,
162 const int * partition,
173 bool throw_if_missing =
true);
197 for(
size_t n = 0; n <
node_map.capacity(); ++n) {
198 if(
node_map.value_at(n).free == 0) {
199 local_gids[cnt++] =
node_map.key_at(n);
204 throw std::logic_error(
"Unexpected counts. Internal error with the"
205 " node_map behavior.");
214 typedef long long mpi_t;
215 mpi_t nDDEntries =
static_cast<mpi_t
>(
node_map.size());
217 MPI_Scan(&nDDEntries, &firstIdx, 1, MPI_LONG_LONG, MPI_SUM, getRawComm());
218 firstIdx -= nDDEntries;
220 for(
size_t n = 0; n <
node_map.capacity(); ++n) {
221 if(
node_map.value_at(n).free == 0) {
238 int partition,
int owner);
242 int *partition,
int *owner,
bool throw_if_missing =
true)
const;
253 typedef Kokkos::UnorderedMap<gid_t,
268 unsigned int hash_proc(
const gid_t & gid)
const;
271 Teuchos::RCP<const Teuchos::Comm<int> >
comm;
294 bool throw_if_missing =
true)
const = 0;
299 MPI_Comm getRawComm() {
301 return Teuchos::getRawMpiComm(*
comm);
303 return MPI_COMM_WORLD;
307 void rehash_node_map(
size_t new_hash_size) {
312 template <
typename g
id_t,
typename l
id_t,
typename user_t>
339 this->
comm = src.comm;
361 throw std::logic_error(
"Aggregate doesn't mean anything for single "
362 "types. Must use Zoltan2_Directory_Vector class.");
364 throw std::logic_error(
"AggregateAdd doesn't mean anything for single "
365 "types. Must use Zoltan2_Directory_Vector class.");
394 bool throw_if_missing =
true)
const {
405 template <
typename g
id_t,
typename l
id_t,
typename user_t>
432 this->
comm = src.comm;
447 size_t * pLength = (
size_t*)(pRaw);
448 size_t read_array_length = *pLength;
456 dst.resize(read_array_length);
457 for(
size_t i = 0; i < read_array_length; ++i) {
465 if(dst.size() !=
static_cast<size_t>(read_array_length)) {
466 throw std::logic_error(
"The data lengths are not the same size");
469 for(
size_t i = 0; i < dst.size(); ++i) {
486 for(
size_t i = 0; i < read_array_length; ++i) {
488 if(dst.size() == 0 || (*pRead) > dst[dst.size()-1]) {
489 dst.push_back(*pRead);
493 for(
auto itr = dst.begin(); itr != dst.end(); ++itr) {
494 if((*itr) == (*pRead)) {
496 Update_Mode::AggregateAdd) {
501 else if((*itr) > (*pRead)) {
502 dst.insert(itr, (*pRead));
550 for(
size_t i = 0; i < read_array_length; ++i) {
552 for(
auto itr = dst.begin(); itr != dst.end(); ++itr) {
553 if((*itr) == (*pRead)) {
560 dst.push_back(*pRead);
573 size_t *pLength = (
size_t*)(pRaw);
574 *pLength = src.size();
577 for(
size_t n = 0; n < src.size(); ++n) {
586 size_t* pLength = (
size_t*) pRaw;
587 dst.resize(static_cast<size_t>(*pLength));
590 for(
size_t n = 0; n < dst.size(); ++n) {
599 return sizeof(
typename user_t::value_type);
615 size_t * pLength = (
size_t*) (pRaw);
623 bool throw_if_missing =
true)
const {
629 else if(throw_if_missing) {
630 throw std::logic_error(
"Could not find gid in map." );
644 if(msg->
proc == -1) {
652 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.
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).
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 size_t size_of_value_type() const =0
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
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 bool is_Zoltan2_Directory_Vector() const =0
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
virtual size_t get_local_find_msg_size(gid_t *gid, bool throw_if_missing=true) const =0
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 size_t get_update_msg_size(const user_t &data) const =0
virtual void user_to_raw(const user_t &src, user_t *pRaw) 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.
user_t::value_type user_val_t
virtual void raw_to_user(const user_t *pRaw, user_t &dst) const =0
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 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_incoming_find_msg_size(Zoltan2_DD_Find_Msg< gid_t, lid_t > *msg) const =0
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...
virtual void user_to_raw(const user_t &src, user_t *pRaw) const =0
virtual void update_local_user(const user_t *pRaw, user_t &dst)=0
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