33 #ifndef __H__LIB_ALGEBRA__PARALLELIZATION__ROW_SENDING_SCHEME_H_
34 #define __H__LIB_ALGEBRA__PARALLELIZATION__ROW_SENDING_SCHEME_H_
45 template<
typename matrix_type>
90 int pid = sendLayout.
proc_id(it);
93 iter2 != interface.end(); ++iter2)
95 issue_send(buf, pid, interface.get_element(iter2));
105 int pid = receiveLayout.
proc_id(it);
122 int pid = receiveLayout.
proc_id(it);
126 UG_DLOG(
LIB_ALG_MATRIX, 4,
"rowsBufferMap: received " << buf.write_pos() <<
" bytes from processor " << pid <<
"\n");
128 process(buf, pid, interface.get_element(it));
138 for(
typename std::map<
size_t, std::vector<connection> >::iterator it =
connections.begin();
141 std::vector<connection> &cons = it->second;
143 mat.set_matrix_row(it->first, &cons[0], cons.size());
150 for(
typename std::map<
size_t, std::vector<connection> >::iterator it =
connections.begin();
153 std::vector<connection> &cons = it->second;
155 mat.add_matrix_row(it->first, &cons[0], cons.size());
163 size_t cols = std::max(
colMax,
mat.num_cols());
164 size_t rows = std::max(
rowMax,
mat.num_rows());
165 if(rows >
mat.num_rows() || cols >
mat.num_cols())
166 mat.resize_and_keep_values(rows, cols);
185 for(
typename matrix_type::const_row_iterator conn =
mat.begin_row(localRowIndex);
186 conn !=
mat.end_row(localRowIndex); ++conn)
188 size_t localColIndex = conn.index();
196 UG_DLOG(
LIB_ALG_MATRIX, 4,
" " << localColIndex <<
" (" << globalColIndex <<
") -> " << conn.value() <<
"\n");
213 std::vector<connection> &cons =
connections[localRowIndex];
214 size_t i = cons.size();
229 UG_DLOG(
LIB_ALG_MATRIX, 4,
" " << (
int)(cons[j].iIndex) <<
" (" << globalColIndex <<
") -> " << cons[j].dValue <<
"\n");
235 if(cons[k].iIndex == cons[j].iIndex)
237 cons[k].dValue += cons[j].dValue;
Performs communication between interfaces on different processes.
Definition: pcl_interface_communicator.h:68
void send_raw(int targetProc, const void *pBuff, int bufferSize, bool bSizeKnownAtTarget=false)
sends raw data to a target-proc.
Definition: pcl_interface_communicator_impl.hpp:61
void receive_raw(int srcProc, ug::BinaryBuffer &bufOut, int bufSize=-1)
registers a binary-stream to receive data from a source-proc.
Definition: pcl_interface_communicator_impl.hpp:166
You may add elements to this interface and iterate over them.
Definition: pcl_communication_structs.h:207
iterator end(size_t level=0)
returns the iterator to the last interface of the layout.
Definition: pcl_communication_structs.h:492
iterator begin(size_t level=0)
returns the iterator to the first interface of the layout.
Definition: pcl_communication_structs.h:486
int proc_id(iterator iter) const
returns the target process of the interface given in iterator
Definition: pcl_communication_structs.h:509
InterfaceMap::const_iterator const_iterator
Definition: pcl_communication_structs.h:477
A Buffer for binary data.
Definition: binary_buffer.h:56
char * buffer()
returns the raw buffer pointer or NULL if the buffer is empty (capacity() == 0)
Definition: binary_buffer_impl.h:94
size_t write_pos() const
returns the current write-pos (in bytes)
Definition: binary_buffer_impl.h:53
Definition: parallel_nodes.h:112
const AlgebraID & local_to_global(size_t i) const
Definition: parallel_nodes.h:278
void issue(pcl::InterfaceCommunicator< IndexLayout > &communicator)
Definition: parallel_nodes.cpp:297
void process()
Definition: parallel_nodes.cpp:320
void create_node(const AlgebraID &globalID, size_t localIndex, int pid)
Definition: parallel_nodes.cpp:232
size_t get_local_index_if_available(const AlgebraID &globalIndex, bool &bHasIndex) const
returns a local index by returning a old local one or a saved created one
Definition: parallel_nodes.cpp:83
size_t distance_to_master_or_inner(size_t i) const
Definition: parallel_nodes.h:368
size_t create_slave_node(const AlgebraID &globalID, int distanceToMasterOrInner)
Definition: parallel_nodes.cpp:219
Definition: row_sending_scheme.h:47
void add_rows_to_matrix(matrix_type &mat)
Definition: row_sending_scheme.h:147
ParallelNodes & PN
Definition: row_sending_scheme.h:55
RowSendingScheme(matrix_type &_mat, ParallelNodes &_PN)
Definition: row_sending_scheme.h:59
size_t rowMax
Definition: row_sending_scheme.h:56
std::map< int, BinaryBuffer > BufferMap
Definition: row_sending_scheme.h:50
void set_create_new_nodes(bool bCreateNewNodes)
Definition: row_sending_scheme.h:65
void process(const IndexLayout &receiveLayout)
Definition: row_sending_scheme.h:114
const matrix_type & mat
Definition: row_sending_scheme.h:52
void resize_mat(matrix_type &mat)
Definition: row_sending_scheme.h:161
BufferMap rowsBufferMap
Definition: row_sending_scheme.h:51
std::map< size_t, std::vector< connection > > connections
Definition: row_sending_scheme.h:54
matrix_type::connection connection
Definition: row_sending_scheme.h:53
bool m_bCreateNewNodes
Definition: row_sending_scheme.h:49
void process(BinaryBuffer &buf, int pid, size_t localRowIndex)
Definition: row_sending_scheme.h:201
void set_rows_in_matrix(matrix_type &mat)
Definition: row_sending_scheme.h:135
void issue_send(pcl::InterfaceCommunicator< IndexLayout > &communicator, const IndexLayout &sendLayout, const IndexLayout &receiveLayout)
Definition: row_sending_scheme.h:83
void issue_send(BinaryBuffer &buf, int pid, int localRowIndex)
Definition: row_sending_scheme.h:177
size_t colMax
Definition: row_sending_scheme.h:56
#define UG_DLOG(__debugID__, level, msg)
Definition: log.h:298
DebugID LIB_ALG_MATRIX
Definition: debug_id.h:130
CPUAlgebra::matrix_type matrix_type
void Deserialize(TIStream &buf, ParallelVector< T > &v)
Deerialize for ParallelVector<T>
Definition: restart_bridge.cpp:112
void Serialize(TOStream &buf, const ParallelVector< T > &v)
Serialize for ParallelVector<T>
Definition: restart_bridge.cpp:103
size_t num_connections(size_t row) const
this type is used to identify distributed objects.
Definition: algebra_id.h:46