LAMA
/home/brandes/workspace/LAMA/src/lama/distribution/GenBlockDistribution.hpp
Go to the documentation of this file.
00001 
00033 #ifndef LAMA_GENBLOCKDISTRIBUTION_HPP_
00034 #define LAMA_GENBLOCKDISTRIBUTION_HPP_
00035 
00036 // for dll_import
00037 #include <lama/config.hpp>
00038 
00039 // base classes
00040 #include <lama/distribution/Distribution.hpp>
00041 
00042 // boost
00043 #include <boost/scoped_array.hpp>
00044 
00045 namespace lama
00046 {
00047 
00058 class LAMA_DLL_IMPORTEXPORT GenBlockDistribution: public lama::Distribution
00059 {
00060 public:
00061 
00071     GenBlockDistribution(const IndexType globalSize,
00072                          const std::vector<IndexType>& localSizes,
00073                          const CommunicatorPtr communicator);
00074 
00084      GenBlockDistribution(const IndexType globalSize,
00085                           const IndexType firstGlobalIdx,
00086                           const IndexType lastGlobalIdx,
00087                           const CommunicatorPtr communicator);
00088 
00097     GenBlockDistribution(const IndexType globalSize,
00098                          const IndexType localSize,
00099                          const CommunicatorPtr communicator);
00100 
00112     GenBlockDistribution(const IndexType globalSize,
00113                          const float weight,
00114                          const CommunicatorPtr communicator);
00115 
00116     virtual ~GenBlockDistribution();
00117 
00120     void getLocalRange( IndexType& lb, IndexType& ub ) const;
00121 
00122     // Implementation of abstract methods, override default virtual methods
00123 
00124     virtual bool isLocal(const IndexType index) const;
00125 
00132     virtual PartitionId getOwner( const IndexType globalIndex ) const;
00133 
00134     virtual IndexType getLocalSize() const;
00135 
00136     virtual IndexType local2global(const IndexType localIndex) const;
00137 
00138     virtual IndexType global2local(const IndexType globalIndex) const;
00139 
00140     virtual bool isEqual(const Distribution& other) const;
00141 
00142     virtual void writeAt(std::ostream& stream) const;
00143 
00150     virtual void computeOwners(
00151         const std::vector<IndexType>& requiredIndexes,
00152         std::vector<PartitionId>& owners) const;
00153 
00154     void printDistributionVector( std::string name ) const;
00155 
00156 protected:
00157 
00158     LAMA_LOG_DECL_STATIC_LOGGER(logger);
00159 
00160 private:
00161 
00162     void setOffsets( const IndexType rank, const IndexType numPartitions, const IndexType localSizes[] );
00163 
00164     void setOffsets( const IndexType rank, const IndexType numPartitions, const IndexType mySize );
00165 
00166     GenBlockDistribution();  // disable default destructor
00167 
00168     boost::scoped_array<IndexType> mOffsets; 
00169 
00170     IndexType mLB, mUB;     
00171 };
00172 
00173 }
00174 
00175 #endif // LAMA_GENBLOCKDISTRIBUTION_HPP_