LAMA
|
00001 00033 #ifndef LAMA_COMMUNICATION_PLAN_HPP_ 00034 #define LAMA_COMMUNICATION_PLAN_HPP_ 00035 00036 // for dll_import 00037 #include <lama/config.hpp> 00038 00039 // base classes 00040 #include <lama/Printable.hpp> 00041 00042 // others 00043 #include <lama/LAMATypes.hpp> 00044 #include <lama/LAMAArray.hpp> 00045 00046 // logging 00047 #include <logging/logging.hpp> 00048 00049 #include <vector> 00050 00051 namespace lama 00052 { 00053 00054 class Communicator; // forward declaration 00055 00069 class LAMA_DLL_IMPORTEXPORT CommunicationPlan : public Printable 00070 { 00071 public: 00072 00076 struct Entry 00077 { 00078 PartitionId partitionId; 00079 IndexType quantity; 00080 IndexType offset; 00081 }; 00082 00083 CommunicationPlan(); 00084 00087 void clear(); 00088 00103 CommunicationPlan(const LAMAArray<IndexType>& quantities, bool compressFlag = true ); 00104 00109 CommunicationPlan(const PartitionId noPartitions, 00110 const std::vector<PartitionId>& owners, 00111 bool compressFlag = true ); 00112 00115 CommunicationPlan( const CommunicationPlan& other, const IndexType quantities[] ); 00116 00126 CommunicationPlan( const CommunicationPlan& other, const IndexType n ); 00127 00130 virtual ~CommunicationPlan(); 00131 00147 void allocate(const LAMAArray<IndexType>& quantities, bool compressFlag = true); 00148 00149 void allocate(const PartitionId noPartitions, 00150 const std::vector<PartitionId>& owners, bool compressFlag = true); 00151 00157 void allocateTranspose( const CommunicationPlan& plan, const Communicator& comm); 00158 00159 bool allocated() const; 00160 00163 void compress(); 00164 00167 bool compressed() const; 00168 00177 inline PartitionId size() const; 00178 00181 inline IndexType totalQuantity() const; 00182 00190 IndexType maxQuantity() const; 00191 00199 inline const Entry& operator[](const PartitionId index) const; 00200 00203 void writeAt( std::ostream& stream ) const; 00204 00205 private: 00206 00207 bool mAllocated; 00208 00209 bool mCompressed; 00210 00211 std::vector<Entry> mEntries; 00212 00213 IndexType mQuantity; 00214 00215 LAMA_LOG_DECL_STATIC_LOGGER(logger); 00216 }; 00217 00218 /* ----------------------------------------------------------------------*/ 00219 00220 PartitionId CommunicationPlan::size() const 00221 { 00222 return static_cast<PartitionId>( mEntries.size() ); 00223 } 00224 00225 const CommunicationPlan::Entry& CommunicationPlan::operator[] 00226 (const PartitionId id) const 00227 { 00228 return mEntries.at(id); 00229 } 00230 00231 IndexType CommunicationPlan::totalQuantity() const 00232 { 00233 return mQuantity; 00234 } 00235 00236 } 00237 00238 #endif // LAMA_COMMUNICATION_PLAN_HPP_