16 #ifndef MOAB_PARALLEL_COMM_HPP
17 #define MOAB_PARALLEL_COMM_HPP
36 class SequenceManager;
38 template <
typename KeyType,
typename ValType, ValType NullVal >
45 #define MAX_SHARING_PROCS 64
100 const int start_id = 1,
101 const bool largest_dim_only =
true,
102 const bool parallel =
true,
103 const bool owned_only =
false );
111 const bool owned_only );
119 const int start_id = 1,
120 const bool largest_dim_only =
true,
121 const bool parallel =
true,
122 const bool owned_only =
false );
147 const bool store_remote_handles,
153 std::vector< MPI_Request >& recv_remoteh_reqs,
154 bool wait_all =
true );
157 std::vector< Range* >& send_ents,
160 const bool store_remote_handles );
174 const bool store_remote_handles,
179 std::vector< std::vector< EntityHandle > >& L1hloc,
180 std::vector< std::vector< EntityHandle > >& L1hrem,
181 std::vector< std::vector< int > >& L1p,
182 std::vector< EntityHandle >& L2hloc,
183 std::vector< EntityHandle >& L2hrem,
184 std::vector< unsigned int >& L2p,
185 std::vector< MPI_Request >& recv_remoteh_reqs,
186 bool wait_all =
true );
191 const bool store_remote_handles,
192 const bool migrate =
false );
203 const bool store_remote_handles,
208 std::vector< std::vector< EntityHandle > >& L1hloc,
209 std::vector< std::vector< EntityHandle > >& L1hrem,
210 std::vector< std::vector< int > >& L1p,
211 std::vector< EntityHandle >& L2hloc,
212 std::vector< EntityHandle >& L2hrem,
213 std::vector< unsigned int >& L2p,
214 std::vector< MPI_Request >& recv_remoteh_reqs );
218 std::vector< EntityHandle >& L2hloc,
219 std::vector< EntityHandle >& L2hrem,
220 std::vector< unsigned int >& L2p,
221 std::vector< MPI_Request >& recv_remoteh_reqs );
246 bool store_remote_handles,
247 bool wait_all =
true,
254 unsigned int num_procs,
259 bool store_remote_handles,
267 ErrorCode post_irecv( std::vector< unsigned int >& shared_procs, std::set< unsigned int >& recv_procs );
278 std::vector< Range* >& exchange_ents,
279 std::vector< MPI_Request >& recv_ent_reqs,
280 std::vector< MPI_Request >& recv_remoteh_reqs,
281 bool store_remote_handles,
282 bool wait_all =
true,
283 bool migrate =
false,
291 std::vector< Range* >& exchange_ents,
292 std::vector< MPI_Request >& recv_ent_reqs,
293 std::vector< MPI_Request >& recv_remoteh_reqs,
294 const bool recv_posted,
295 bool store_remote_handles,
297 bool migrate =
false );
309 const std::vector< Tag >& dst_tags,
342 const std::vector< Tag >& dst_tags,
374 const bool adjacencies =
false,
375 const bool tags =
true );
387 const bool adjacencies =
false,
388 const bool tags =
true );
397 std::vector< std::vector< int > >& msgsizes,
398 std::vector< std::vector< EntityHandle > >& senddata,
399 std::vector< std::vector< EntityHandle > >& recvdata );
402 std::vector< int >& procs,
403 std::vector< EntityHandle >& handles );
431 int resolve_dim = -1,
433 Range* skin_ents = NULL,
434 const Tag* id_tag = 0 );
450 const Tag* id_tag = 0 );
453 const unsigned int np,
536 unsigned char& pstat,
537 unsigned int& num_ps );
549 unsigned char& pstat,
562 std::set< int >& procs,
582 const bool iface =
false,
583 const bool owned_filter =
false );
587 ErrorCode get_partition_sets(EntityHandle this_set,
589 const char *tag_name = NULL);
609 unsigned& owner_rank,
713 void print_pstatus(
unsigned char pstat, std::string& ostr );
742 int& num_part_ids_out,
766 const unsigned char pstatus_val,
767 const unsigned char op,
769 Range* returned_ents = NULL );
793 Buffer(
unsigned int sz = 0 );
806 inline void reserve(
unsigned int new_size );
825 const bool adjacencies,
827 const bool store_remote_handles,
831 Range* allsent = NULL );
834 const bool store_remote_handles,
837 std::vector< std::vector< EntityHandle > >& L1hloc,
838 std::vector< std::vector< EntityHandle > >& L1hrem,
839 std::vector< std::vector< int > >& L1p,
840 std::vector< EntityHandle >& L2hloc,
841 std::vector< EntityHandle >& L2hrem,
842 std::vector< unsigned int >& L2p,
843 std::vector< EntityHandle >& new_ents,
844 const bool created_iface =
false );
848 const bool store_remote_handles,
852 Range* allsent = NULL );
856 const bool store_remote_handles,
859 std::vector< std::vector< EntityHandle > >& L1hloc,
860 std::vector< std::vector< EntityHandle > >& L1hrem,
861 std::vector< std::vector< int > >& L1p,
862 std::vector< EntityHandle >& L2hloc,
863 std::vector< EntityHandle >& L2hrem,
864 std::vector< unsigned int >& L2p,
865 std::vector< EntityHandle >& new_ents,
866 const bool created_iface =
false );
889 const char* prefix = NULL );
901 int get_buffers(
int to_proc,
bool* is_new = NULL );
904 const std::vector< unsigned int >&
buff_procs()
const;
910 unsigned char*& buff_ptr,
911 std::vector< EntityHandle >& L2hloc,
912 std::vector< EntityHandle >& L2hrem,
913 std::vector< unsigned int >& L2p );
919 std::vector< EntityHandle >& L1hrem,
920 std::vector< int >& procs,
921 unsigned int to_proc,
935 std::map< std::vector< int >, std::vector< EntityHandle > >& proc_nvecs,
937 unsigned int i_extra = 1 );
976 int root_proc_rank = 0 );
997 Range& shared_edges_owned,
998 std::vector< std::vector< EntityHandle >* >& extraNodesVec,
1018 ErrorCode reduce_void(
int tag_data_type,
const MPI_Op mpi_op,
int num_ents,
void* old_vals,
void* new_vals );
1020 template <
class T >
1021 ErrorCode reduce(
const MPI_Op mpi_op,
int num_ents,
void* old_vals,
void* new_vals );
1035 unsigned char pstatus,
1046 const int bridge_dim,
1047 const int ghost_dim,
1048 const int num_layers,
1049 const int addl_ents,
1065 unsigned char pstatus_val,
1066 bool lower_dim_ents =
false,
1067 bool verts_too =
true,
1082 unsigned char pstatus_val,
1083 bool lower_dim_ents =
false,
1084 bool verts_too =
true,
1097 MPI_Request& send_req,
1098 MPI_Request& ack_recv_req,
1101 int next_mesg_tag = -1,
1102 Buffer* next_recv_buff = NULL,
1103 MPI_Request* next_recv_req = NULL,
1104 int* next_incoming = NULL );
1110 const MPI_Status& mpi_status,
1112 MPI_Request& recv_2nd_req,
1113 MPI_Request& ack_req,
1116 MPI_Request& send_req,
1117 MPI_Request& sent_ack_req,
1119 Buffer* next_buff = NULL,
1121 MPI_Request* next_req = NULL,
1122 int* next_incoming = NULL );
1127 const bool store_remote_handles,
1130 std::vector< EntityHandle >&
entities,
1138 const int from_proc,
1140 std::vector< EntityHandle >& recd_ents );
1145 std::vector< EntityHandle >&
entities,
1146 const bool store_handles,
1147 const int to_proc );
1152 unsigned char*& buff_ptr,
1154 const bool just_count,
1155 const bool store_handles,
1156 const int to_proc );
1160 const bool store_handles,
1161 const int from_proc );
1166 const unsigned char* buff_ptr,
1167 std::vector< EntityHandle >& L2hloc,
1168 std::vector< EntityHandle >& L2hrem,
1169 std::vector< unsigned int >& L2p );
1177 const int num_connect,
1178 const EntityType this_type,
1179 std::vector< EntityHandle >& L2hloc,
1180 std::vector< EntityHandle >& L2hrem,
1181 std::vector< unsigned int >& L2p,
1185 const unsigned char pstatus,
1187 const std::set< unsigned int >& procs,
1188 unsigned int& num_ents,
1207 std::vector< Tag >& all_tags,
1208 std::vector< Range >& tag_ranges );
1255 const std::vector< Tag >& src_tags,
1256 const std::vector< Tag >& dst_tags,
1257 const std::vector< Range >& tag_ranges,
1259 const bool store_handles,
1260 const int to_proc );
1295 Tag destination_tag,
1297 const std::vector< EntityHandle >& whole_range,
1299 const bool store_remote_handles,
1300 const int to_proc );
1303 std::vector< EntityHandle >&
entities,
1304 const bool store_handles,
1306 const MPI_Op*
const mpi_op = NULL );
1310 std::map< std::vector< int >, std::vector< EntityHandle > >& proc_nvecs,
1311 Range& proc_verts );
1316 std::map< std::vector< int >, std::vector< EntityHandle > >& proc_nvecs );
1340 Range& ghosted_ents );
1350 std::vector< std::vector< SharedEntityData > >& result );
1362 const std::vector< EntityHandle >& new_ents );
1367 const Range& from_range,
1370 const std::vector< EntityHandle >& new_ents );
1374 const Range& from_range,
1377 const std::vector< EntityHandle >& new_ents );
1385 Range& local_handles,
1386 const std::vector< EntityHandle >& new_ents );
1392 Range& remote_range,
1394 const unsigned char add_pstat );
1400 const unsigned char add_pstat );
1406 const unsigned char add_pstat );
1494 if( new_size ) this->
reserve( new_size );
1506 #define DEBUG_BUFFER 0
1515 tmp_pos = buff_ptr - mem_ptr;
1517 buff_ptr = (
unsigned char*)malloc( new_size );
1518 assert( 0 <= tmp_pos && tmp_pos <= (
int)alloc_size );
1519 if( tmp_pos ) memcpy( buff_ptr, mem_ptr, tmp_pos );
1520 if( mem_ptr ) free( mem_ptr );
1522 alloc_size = new_size;
1523 buff_ptr = mem_ptr + tmp_pos;
1525 if( mem_ptr && alloc_size < new_size )
1527 size_t tmp_pos = mem_ptr ? buff_ptr - mem_ptr : 0;
1528 mem_ptr = (
unsigned char*)realloc( mem_ptr, new_size );
1529 alloc_size = new_size;
1530 buff_ptr = mem_ptr + tmp_pos;
1534 mem_ptr = (
unsigned char*)malloc( new_size );
1535 alloc_size = new_size;
1543 assert( buff_ptr >= mem_ptr && buff_ptr <= mem_ptr + alloc_size );
1544 unsigned int new_size = buff_ptr - mem_ptr + addl_space;
1545 if( new_size > alloc_size ) reserve( 3 * new_size / 2 );
1550 std::vector< Buffer* >::iterator vit;
1552 ( *vit )->reset_buffer();
1554 ( *vit )->reset_buffer();
1559 std::vector< Buffer* >::iterator vit;
1592 std::vector< Tag > tags( 1 );
1605 std::vector< Tag > tags;
1606 tags.push_back( tagh );
1614 std::vector< Tag > tags( 1 );
1627 std::vector< Tag > tags;
1628 tags.push_back( tagh );
1638 std::copy(
buffProcs.begin(),
buffProcs.end(), std::inserter( procs, procs.begin() ) );
1652 const unsigned char* buff_ptr,
1653 std::vector< EntityHandle >& L2hloc,
1654 std::vector< EntityHandle >& L2hrem,
1655 std::vector< unsigned int >& L2p )
1658 unsigned char* tmp_buff =
const_cast< unsigned char*
>( buff_ptr );
1675 std::set< int >& procs,
1681 std::copy( ents_cast, ents_cast + num_entities,
range_inserter( dum_range ) );
1688 unsigned char& pstat,
1691 unsigned int dum_ps;
1699 sendReqs.resize( n_request, MPI_REQUEST_NULL );
1704 recvReqs.resize( n_request, MPI_REQUEST_NULL );