/** * Used only by Rank 0 to distribute the rows to the other processes */ void p2p_cycl_distribute_rows(struct GEmpi *param) { int N = param->N; int size = param->size; int rank = param->rank; double **R = param->R; int blocking_factor = param->blocking_factor; int row, cur_rank; int r = 0; //printf("\nPrinting input matrix:\n"); double *buffer = allocate_row(N); double t1; // Cyclic distribution of blocks for (row = 0; row < N; row++) { cur_rank = row % size; if (cur_rank == 0) { R[r] = initialize_row(R[r], N); //print_row(R[r], N); r++; } else { buffer = initialize_row(buffer, N); //printf(" RANK = %i ",cur_rank); //print_row(buffer, N); t1 = timer(); MPI_Send(buffer, N, MPI_DOUBLE, cur_rank, 1, MPI_COMM_WORLD); param->t_comm += timer() - t1; } cur_rank++; } free(buffer); }
/** * Used only by Rank 0 to distribute the rows to the other processes */ void bcast_cons_distribute_rows(struct GEmpi *param) { int N = param->N; int size = param->size; int rank = param->rank; double **R = param->R; int blocking_factor = param->blocking_factor; int r, cur_rank; //printf("\nPrinting input matrix:\n"); // Allocate Rank 0 rows for (r = 0; r < blocking_factor; r++) { R[r] = initialize_row(R[r], N); //print_row(R[r], N); } // Send to procs with blocking_factor rows double *buffer = allocate_row(N); double t1; for (cur_rank = 1; cur_rank < size; cur_rank++) { for (r = 0; r < blocking_factor; r++) { buffer = initialize_row(buffer, N); //print_row(buffer, N); //printf("Root about to send row to (rank = %i)\n", cur_rank); t1 = timer(); MPI_Send(buffer, N, MPI_DOUBLE, cur_rank, 1, MPI_COMM_WORLD); param->t_comm += timer() - t1; } } free(buffer); }
CompoundSymMatrixSpace::CompoundSymMatrixSpace(Index ncomp_spaces, Index total_dim) : SymMatrixSpace(total_dim), ncomp_spaces_(ncomp_spaces), block_dim_(ncomp_spaces, -1), dimensions_set_(false) { for (Index irow=0; irow<ncomp_spaces_; irow++) { std::vector<SmartPtr<const MatrixSpace> > row(irow+1); std::vector< bool > allocate_row(irow+1, false); comp_spaces_.push_back(row); allocate_block_.push_back(allocate_row); } }
CompoundMatrixSpace::CompoundMatrixSpace(Index ncomps_rows, Index ncomps_cols, Index total_nRows, Index total_nCols) : MatrixSpace(total_nRows, total_nCols), ncomps_rows_(ncomps_rows), ncomps_cols_(ncomps_cols), dimensions_set_(false), block_rows_(ncomps_rows, -1), block_cols_(ncomps_cols, -1), diagonal_(false) { DBG_START_METH("CompoundMatrixSpace::CompoundMatrixSpace", 0); std::vector<SmartPtr<const MatrixSpace> > row(ncomps_cols_); std::vector< bool > allocate_row(ncomps_cols_, false); for (Index i=0; i<ncomps_rows_; i++) { DBG_PRINT((1, "block_rows_[%d] = %d\n", i, block_rows_[i])); comp_spaces_.push_back(row); allocate_block_.push_back(allocate_row); } }