Distribution.h
Go to the documentation of this file.
/*****************************************************************************
*
* Copyright (c) 2003-2017 by The University of Queensland
* http://www.uq.edu.au
*
* Primary Business: Queensland, Australia
* Licensed under the Apache License, version 2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Development until 2012 by Earth Systems Science Computational Center (ESSCC)
* Development 2012-2013 by School of Earth Sciences
* Development from 2014 by Centre for Geoscience Computing (GeoComp)
*
*****************************************************************************/
#ifndef __ESCRIPT_DISTRIBUTION_H__
#define __ESCRIPT_DISTRIBUTION_H__
#include <escript/DataTypes.h>
namespace escript {
struct Distribution;
typedef boost::shared_ptr<Distribution> Distribution_ptr;
typedef boost::shared_ptr<const Distribution> const_Distribution_ptr;
struct Distribution
{
Distribution(JMPI mpiInfo, const DataTypes::IndexVector& firstComponent,
DataTypes::index_t m = 1, DataTypes::index_t b = 0) :
mpi_info(mpiInfo)
{
first_component.resize(mpi_info->size + 1);
for (int i = 0; i < mpi_info->size+1; ++i)
first_component[i] = m * firstComponent[i] + b;
}
inline DataTypes::index_t getFirstComponent() const
{
return first_component[mpi_info->rank];
}
inline DataTypes::index_t getLastComponent() const
{
return first_component[mpi_info->rank+1];
}
inline DataTypes::dim_t getGlobalNumComponents() const
{
return getMaxGlobalComponents()-getMinGlobalComponents();
}
inline DataTypes::dim_t getMyNumComponents() const
{
return getLastComponent()-getFirstComponent();
}
inline DataTypes::dim_t getMinGlobalComponents() const
{
return first_component[0];
}
inline DataTypes::dim_t getMaxGlobalComponents() const
{
return first_component[mpi_info->size];
}
DataTypes::IndexVector first_component;
JMPI mpi_info;
};
} // namespace escript
#endif // __ESCRIPT_DISTRIBUTION_H__
escript::Distribution::getMyNumComponents
DataTypes::dim_t getMyNumComponents() const
Definition: Distribution.h:57
escript
Definition: AbstractContinuousDomain.cpp:22
escript::Distribution_ptr
boost::shared_ptr< Distribution > Distribution_ptr
Definition: Distribution.h:24
escript::DataTypes::IndexVector
std::vector< index_t > IndexVector
Definition: DataTypes.h:62
escript::Distribution::first_component
DataTypes::IndexVector first_component
Definition: Distribution.h:72
escript::JMPI
boost::shared_ptr< JMPI_ > JMPI
Definition: EsysMPI.h:71
escript::Distribution::getMinGlobalComponents
DataTypes::dim_t getMinGlobalComponents() const
Definition: Distribution.h:62
escript::Distribution::getFirstComponent
DataTypes::index_t getFirstComponent() const
Definition: Distribution.h:42
escript::DataTypes::index_t
int index_t
type for array/matrix indices used both globally and on each rank
Definition: DataTypes.h:59
escript::Distribution::mpi_info
JMPI mpi_info
Definition: Distribution.h:73
escript::Distribution::getMaxGlobalComponents
DataTypes::dim_t getMaxGlobalComponents() const
Definition: Distribution.h:67
escript::Distribution::getGlobalNumComponents
DataTypes::dim_t getGlobalNumComponents() const
Definition: Distribution.h:52
escript::const_Distribution_ptr
boost::shared_ptr< const Distribution > const_Distribution_ptr
Definition: Distribution.h:26
escript::Distribution::Distribution
Distribution(JMPI mpiInfo, const DataTypes::IndexVector &firstComponent, DataTypes::index_t m=1, DataTypes::index_t b=0)
Definition: Distribution.h:33
escript::Distribution::getLastComponent
DataTypes::index_t getLastComponent() const
Definition: Distribution.h:47
escript::Distribution
Definition: Distribution.h:31
escript::DataTypes::dim_t
index_t dim_t
Definition: DataTypes.h:64