Flow123d
release_3.0.0-968-gc87a28e79
|
Go to the documentation of this file.
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];
71 :communicator(PETSC_COMM_WORLD),
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");
128 : communicator(distr.communicator)
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 np() const
get num of processors
unsigned int lsize() const
unsigned int myp() const
get my processor
int my_proc
my proc number
Support classes for parallel programing.
unsigned int size() const
get global size
Distribution(const unsigned int size, MPI_Comm comm)
unsigned int * starts
starts[i] index of the first index on the proc i; starts[n_procs]=size of whole array
unsigned int get_proc(unsigned int idx) const
get processor of the given index
int num_of_procs
number of procs
const unsigned int * get_lsizes_array()
get local sizes array
unsigned int * lsizes
local sizes
const unsigned int * get_starts_array() const
get local starts array
Global macros to enhance readability and debugging, general constants.
const MPI_Comm communicator
communicator
unsigned int begin() const
#define MPI_Allgather(sendbuf, sendcount, sendtype, recvbuf, recvcount, recvtype, comm)
bool is_on_proc(unsigned int idx, unsigned int proc) const
void view(std::ostream &stream) const
distribution view