111 spm_complex64_t *bglob,
113 spm_complex64_t *bloc,
118 assert( ldbl == ldbg );
119 memcpy( bloc, bglob, spm->
gNexp * nrhs *
sizeof( spm_complex64_t ) );
121#if defined(SPM_WITH_MPI)
124 MPI_Allreduce( MPI_IN_PLACE, bglob, ldbg * nrhs, SPM_MPI_COMPLEX64, MPI_SUM, spm->
comm );
167 const spm_complex64_t *b,
174 assert( (spm->
nexp == 0) || (ldb == spm->
nexp) );
177 assert( (spm->
gNexp == 0) || (ldbg == spm->
gNexp) );
180 if ( ( root == -1 ) || ( root == spm->
clustnum ) ) {
181 memcpy( bg, b, spm->
gNexp * nrhs *
sizeof( spm_complex64_t ) );
188#if defined(SPM_WITH_MPI)
191 int nexp, nexpmax = 0;
192 spm_complex64_t *tmp_out, *current_out, *outptr;
201 MPI_Allreduce( &n, &nmax, 1, MPI_INT, MPI_MAX, spm->
comm );
202 MPI_Allreduce( &nexp, &nexpmax, 1, MPI_INT, MPI_MAX, spm->
comm );
205 MPI_Reduce( &n, &nmax, 1, MPI_INT, MPI_MAX, root, spm->
comm );
206 MPI_Reduce( &nexp, &nexpmax, 1, MPI_INT, MPI_MAX, root, spm->
comm );
209 if ( ( root == -1 ) || ( root == spm->
clustnum ) ) {
210 tmp_out = malloc( nexpmax * nrhs *
sizeof( spm_complex64_t ) );
211 tmp_l2g = malloc( nmax *
sizeof(
spm_int_t ) );
218 current_nexp = spm->
nexp;
220 current_out = (spm_complex64_t *)b;
225 current_l2g = tmp_l2g;
226 current_out = tmp_out;
232 if ( current_n > 0 ) {
234 MPI_Bcast( current_out, current_nexp * nrhs, SPM_MPI_COMPLEX64, c, spm->
comm );
237 else if ( root != c ) {
241 if ( current_n > 0 ) {
242 MPI_Recv( current_l2g, current_n,
SPM_MPI_INT, c, 2, spm->
comm, &status );
243 MPI_Recv( current_out, current_nexp * nrhs, SPM_MPI_COMPLEX64, c, 3, spm->
comm, &status );
248 for ( i=0; i<current_n; i++, current_l2g++ ) {
249 ig = *current_l2g - baseval;
250 dofi = ( spm->
dof > 0 ) ? spm->
dof : spm->
dofs[ig+1] - spm->
dofs[ig];
251 row = ( spm->
dof > 0 ) ? spm->
dof * ig : spm->
dofs[ig] - baseval;
252 for ( j=0; j<nrhs; j++ ) {
253 for ( k=0; k<dofi; k++ ) {
254 outptr[ row + j * spm->
gNexp + k ] = current_out[ j * current_nexp + k ];
266 current_nexp = spm->
nexp;
268 current_out = (spm_complex64_t*)b;
272 if ( current_n > 0 ) {
274 MPI_Send( current_out, current_nexp * nrhs, SPM_MPI_COMPLEX64, root, 3, spm->
comm );
void z_spmReduceRHS(int nrhs, const spmatrix_t *spm, spm_complex64_t *bglob, spm_int_t ldbg, spm_complex64_t *bloc, spm_int_t ldbl)
Reduce all the global coefficients of a rhs and store the local ones.
void z_spmGatherRHS(int nrhs, const spmatrix_t *spm, const spm_complex64_t *b, spm_int_t ldb, int root, spm_complex64_t *bg, spm_int_t ldbg)
Gather all the global C coefficients and store the good ones in local.
void z_spmExtractLocalRHS(int nrhs, const spmatrix_t *spm, const spm_complex64_t *bglob, spm_int_t ldbg, spm_complex64_t *bloc, spm_int_t ldbl)
Stores the local values of a global RHS in the local one.