186 const char *oldval = oldspm->
values;
191 int *recvcounts = NULL;
192 int *recvdispls = NULL;
193 int recv = ( root == -1 ) || ( root == oldspm->
clustnum );
196 assert( ((newspm != NULL) && recv) ||
197 ((newspm == NULL) && !recv) );
205 recvcounts = malloc( oldspm->
clustnbr *
sizeof(
int) );
206 recvdispls = malloc( oldspm->
clustnbr *
sizeof(
int) );
209 recvcounts[0] = allcounts[0];
210 for( c=1; c<oldspm->
clustnbr; c++ ) {
211 recvdispls[c] = recvdispls[c-1] + recvcounts[c-1];
212 recvcounts[c] = allcounts[3 * c];
234 recvcounts[0] = allcounts[1];
235 for( c=1; c<oldspm->
clustnbr; c++ ) {
236 recvcounts[c] = allcounts[3 * c + 1];
246 int nnz = oldspm->
nnz;
250 recvcounts[0] = allcounts[1];
251 for( c=1; c<oldspm->
clustnbr; c++ ) {
252 recvdispls[c] = recvdispls[c-1] + recvcounts[c-1];
253 recvcounts[c] = allcounts[3 * c + 1];
265 root, oldspm->
comm );
273 MPI_Datatype valtype = spm_get_datatype( oldspm );
274 int nnzexp = oldspm->
nnzexp;
278 recvcounts[0] = allcounts[2];
279 for( c=1; c<oldspm->
clustnbr; c++ ) {
280 recvdispls[c] = recvdispls[c-1] + recvcounts[c-1];
281 recvcounts[c] = allcounts[3 * c + 2];
286 MPI_Allgatherv( oldval, nnzexp, valtype,
287 newval, recvcounts, recvdispls, valtype, oldspm->
comm );
290 MPI_Gatherv( oldval, nnzexp, valtype,
291 newval, recvcounts, recvdispls, valtype,
292 root, oldspm->
comm );
328 const int *allcounts )
330 MPI_Datatype valtype = spm_get_datatype( oldspm );
331 int *recvcounts = NULL;
332 int *recvdispls = NULL;
333 int nnz = oldspm->
nnz;
334 int nnzexp = oldspm->
nnzexp;
335 int recv = ( root == -1 ) || ( root == oldspm->
clustnum );
337 assert( ((newspm != NULL) && recv) ||
338 ((newspm == NULL) && !recv) );
342 recvcounts = malloc( oldspm->
clustnbr *
sizeof(
int) );
343 recvdispls = malloc( oldspm->
clustnbr *
sizeof(
int) );
346 recvcounts[0] = allcounts[1];
347 for( c=1; c<oldspm->
clustnbr; c++ ) {
348 recvdispls[c] = recvdispls[c-1] + recvcounts[c-1];
349 recvcounts[c] = allcounts[3 * c + 1];
366 root, oldspm->
comm );
370 root, oldspm->
comm );
377 if ( recv && ( oldspm->
dof != 1 ) ) {
381 recvcounts[0] = allcounts[2];
382 for( c=1; c<oldspm->
clustnbr; c++ ) {
383 recvdispls[c] = recvdispls[c-1] + recvcounts[c-1];
384 recvcounts[c] = allcounts[3 * c + 2];
389 MPI_Allgatherv( oldspm->
values, nnzexp, valtype,
390 newspm->
values, recvcounts, recvdispls, valtype, oldspm->
comm );
393 char *newval = recv ? newspm->
values : NULL;
394 MPI_Gatherv( oldspm->
values, nnzexp, valtype,
395 newval, recvcounts, recvdispls, valtype,
396 root, oldspm->
comm );
445 if ( newspm == NULL ) {
446 spm_print_error(
"spmGather: Incorrect call with newspm == NULL\n");
456 assert( ( root >= -1 ) && ( root < oldspm->clustnbr ) );
485 assert( spmd != NULL );
490 if ( newspm == NULL ) {
491 spm_print_error(
"spmGather: Incorrect call with newspm == NULL\n");
499 newspm->
n = spmd->
gN;
516 newspm->
comm = MPI_COMM_SELF;
520 if ( newspm->
dof < 1 ) {
538 if ( spmd != oldspm ) {
int spmGather(const spmatrix_t *oldspm, int root, spmatrix_t *newspm)
Gather a distributed Sparse Matrix on a single node.
int spmRedistribute(const spmatrix_t *spm, spm_int_t new_n, const spm_int_t *newl2g, spmatrix_t *newspm)
Create a copy of a given SPM with a new distribution corresponding to the given loc2glob array.
static void spm_gather_ijv(const spmatrix_t *oldspm, spmatrix_t *newspm, int root, const int *allcounts)
Gather a distributed Sparse Matrix on the root node(s) in IJV format.
static void spm_gather_csx_update(const spmatrix_t *spm, spm_int_t *colptr, int *recvdispls, int *recvcounts)
Update a gathered compressed array to shift the indices accordingly to the distribution.
static void spm_gather_csx(const spmatrix_t *oldspm, spmatrix_t *newspm, int root, int *allcounts)
Gather a distributed Sparse Matrix on the root node(s) in CSC/CSR format.