57 for(
unsigned int i=0 ; i<
np(); i++)
starts[i+1]=
starts[i]+sizes[i];
65 :communicator(PETSC_COMM_WORLD),
71 const PetscInt *petsc_starts;
72 chkerr(VecGetOwnershipRanges(petsc_vector,&petsc_starts));
75 for(
unsigned int i=0 ; i<=
np(); i++)
starts[i]=petsc_starts[i];
91 unsigned int reminder, per_proc;
93 reminder=global_size %
np(); per_proc=global_size /
np();
97 for(
unsigned int i=0; i<
np(); i++)
104 for(
unsigned int i=1; i<=
np(); i++)
starts[i]=global_size;
115 : communicator(distr.communicator)
133 ASSERT_LT(idx,
size()).error(
"Index is greater than distribution size.\n");
135 for(
unsigned int i=0; i<
np(); i++) {
162 stream <<
"[" <<
myp() <<
"]" <<
"Distribution size: " <<
size() <<
" lsize: " <<
lsize() <<
" offset: " <<
begin() <<
" mpi_size: " <<
np() << endl;
163 for(
unsigned int i=0; i<
np();++i)
164 stream <<
"[" <<
myp() <<
"]" <<
"proc: " << i <<
" offset: " <<
begin(i) <<
" lsize: " <<
lsize(i) << endl;
#define ASSERT_PERMANENT(expr)
Allow use shorter versions of macro names if these names is not used with external library.
#define ASSERT_LT(a, b)
Definition of comparative assert macro (Less Than) only for debug mode.
#define ASSERT_PERMANENT_GT(a, b)
Definition of comparative assert macro (Greater Than)
#define ASSERT_PTR(ptr)
Definition of assert macro checking non-null pointer (PTR) only for debug mode.
const unsigned int * get_lsizes_array()
get local sizes array
unsigned int * starts
starts[i] index of the first index on the proc i; starts[n_procs]=size of whole array
const unsigned int * get_starts_array() const
get local starts array
unsigned int myp() const
get my processor
bool is_on_proc(unsigned int idx, unsigned int proc) const
int num_of_procs
number of procs
Distribution(const unsigned int size, MPI_Comm comm)
unsigned int * lsizes
local sizes
void view(std::ostream &stream) const
distribution view
unsigned int get_proc(unsigned int idx) const
get processor of the given index
unsigned int lsize() const
unsigned int size() const
get global size
unsigned int np() const
get num of processors
int my_proc
my proc number
const MPI_Comm communicator
communicator
unsigned int begin() const
Support classes for parallel programing.
Global macros to enhance readability and debugging, general constants.
#define MPI_Allgather(sendbuf, sendcount, sendtype, recvbuf, recvcount, recvtype, comm)
void chkerr(unsigned int ierr)
Replacement of new/delete operator in the spirit of xmalloc.