33 OLD_ASSERT( ! ierr ,
"Can not get MPI rank.\n" );
35 OLD_ASSERT( ! ierr ,
"Can not get MPI size.\n" );
57 OLD_ASSERT( ! ierr ,
"Can not get MPI rank.\n" );
59 OLD_ASSERT( ! ierr ,
"Can not get MPI size.\n" );
63 for(
unsigned int i=0 ; i<
np(); i++)
starts[i+1]=
starts[i]+sizes[i];
76 OLD_ASSERT( ! ierr ,
"Can not get MPI rank.\n" );
78 OLD_ASSERT( ! ierr ,
"Can not get MPI size.\n" );
80 const PetscInt *petsc_starts;
81 VecGetOwnershipRanges(petsc_vector,&petsc_starts);
82 OLD_ASSERT( ! ierr ,
"Can not get vector ownership range.\n" );
85 for(
unsigned int i=0 ; i<=
np(); i++)
starts[i]=petsc_starts[i];
98 OLD_ASSERT( ! ierr ,
"Can not get MPI rank.\n" );
100 OLD_ASSERT( ! ierr ,
"Can not get MPI size.\n" );
104 unsigned int reminder, per_proc;
106 reminder=global_size %
np(); per_proc=global_size /
np();
110 for(
unsigned int i=0; i<
np(); i++)
117 for(
unsigned int i=1; i<=
np(); i++)
starts[i]=global_size;
120 OLD_ASSERT( 0 ,
"Cyclic distribution is not yet implemented.\n");
146 OLD_ASSERT(idx <
size(),
"Index %d greater then distribution size %d.\n", idx,
size());
148 for(
unsigned int i=0; i<
np(); i++) {
151 OLD_ASSERT( 0 ,
"Can not find owner of index %d. \n", idx);
175 stream <<
"[" <<
myp() <<
"]" <<
"Distribution size: " <<
size() <<
" lsize: " <<
lsize() <<
" offset: " <<
begin() <<
" mpi_size: " <<
np() << endl;
176 for(
unsigned int i=0; i<
np();++i)
177 stream <<
"[" <<
myp() <<
"]" <<
"proc: " << i <<
" offset: " <<
begin(i) <<
" lsize: " <<
lsize(i) << endl;
unsigned int size() const
get global size
unsigned int get_proc(unsigned int idx) const
get processor of the given index
int my_proc
my proc number
unsigned int * starts
starts[i] index of the first index on the proc i; starts[n_procs]=size of whole array ...
unsigned int begin() const
Distribution(const unsigned int size, MPI_Comm comm)
int num_of_procs
number of procs
unsigned int lsize() const
const unsigned int * get_lsizes_array()
get local sizes array
void view(std::ostream &stream) const
distribution view
Global macros to enhance readability and debugging, general constants.
const MPI_Comm communicator
communicator
const unsigned int * get_starts_array() const
get local starts array
#define MPI_Allgather(sendbuf, sendcount, sendtype, recvbuf, recvcount, recvtype, comm)
unsigned int np() const
get num of processors
unsigned int myp() const
get my processor
unsigned int * lsizes
local sizes
Support classes for parallel programing.
bool is_on_proc(unsigned int idx, unsigned int proc) const