LAMA
|
00001 00033 #ifndef LAMA_CYCLIC_DISTRIBUTION_HPP_ 00034 #define LAMA_CYCLIC_DISTRIBUTION_HPP_ 00035 00036 // for dll_import 00037 #include <lama/config.hpp> 00038 00039 // base classes 00040 #include <lama/distribution/Distribution.hpp> 00041 00042 namespace lama 00043 { 00044 00049 class LAMA_DLL_IMPORTEXPORT CyclicDistribution: public Distribution 00050 { 00051 public: 00052 00059 CyclicDistribution(const IndexType globalSize, const IndexType chunkSize, 00060 const CommunicatorPtr communicator); 00061 00062 virtual ~CyclicDistribution(); 00063 00064 virtual bool isLocal(const IndexType index) const; 00065 00072 virtual PartitionId getOwner( const IndexType globalIndex ) const; 00073 00074 virtual IndexType getLocalSize() const; 00075 00076 inline IndexType chunkSize() const; 00077 00084 IndexType getNumLocalChunks() const; 00085 00092 IndexType getNumChunks( const PartitionId partition) const; 00093 00100 IndexType getNumTotalChunks() const; 00101 00107 IndexType getPartitionSize( const PartitionId partition) const; 00108 00109 virtual IndexType local2global(const IndexType localIndex) const; 00110 00111 virtual IndexType global2local(const IndexType globalIndex) const; 00112 00113 virtual bool isEqual(const Distribution& other) const; 00114 00115 virtual void writeAt(std::ostream& stream) const; 00116 00120 virtual void computeOwners( 00121 const std::vector<IndexType>& requiredIndexes, 00122 std::vector<PartitionId>& owners) const; 00123 00124 void printDistributionVector( std::string problem ) const; 00125 00126 private: 00127 00128 CyclicDistribution(); // disable default constructor as it has no global size 00129 00130 IndexType allGlobal2local(const IndexType globalIndex) const; 00131 00134 void getChunkInfo( IndexType& localChunks, IndexType& extra, const PartitionId rank) const; 00135 00136 IndexType mChunkSize; // chunk size of each partition 00137 00138 LAMA_LOG_DECL_STATIC_LOGGER( logger ); 00139 }; 00140 00141 IndexType CyclicDistribution::chunkSize() const 00142 { 00143 return mChunkSize; 00144 } 00145 00146 } 00147 00148 #endif // LAMA_CYCLIC_DISTRIBUTION_HPP_