| Line | |
|---|
| 1 | #include <libgeodecomp/config.h> |
|---|
| 2 | #ifdef LIBGEODECOMP_FEATURE_MPI |
|---|
| 3 | #ifndef _libgeodecomp_parallelization_hiparsimulator_vanillaregionaccumulator_h_ |
|---|
| 4 | #define _libgeodecomp_parallelization_hiparsimulator_vanillaregionaccumulator_h_ |
|---|
| 5 | |
|---|
| 6 | #include <boost/shared_ptr.hpp> |
|---|
| 7 | #include <libgeodecomp/parallelization/hiparsimulator/regionaccumulator.h> |
|---|
| 8 | |
|---|
| 9 | namespace LibGeoDecomp { |
|---|
| 10 | namespace HiParSimulator { |
|---|
| 11 | |
|---|
| 12 | template<typename PARTITION> |
|---|
| 13 | class VanillaRegionAccumulator : public RegionAccumulator<PARTITION::DIM> |
|---|
| 14 | { |
|---|
| 15 | public: |
|---|
| 16 | const static int DIM = PARTITION::DIM; |
|---|
| 17 | |
|---|
| 18 | inline VanillaRegionAccumulator( |
|---|
| 19 | const PARTITION& _partition=PARTITION(), |
|---|
| 20 | const unsigned& offset=0, |
|---|
| 21 | const SuperVector<unsigned>& weights=SuperVector<unsigned>(2)) : |
|---|
| 22 | partition(_partition) |
|---|
| 23 | { |
|---|
| 24 | startOffsets.resize(weights.size() + 1); |
|---|
| 25 | startOffsets[0] = offset; |
|---|
| 26 | for (unsigned i = 0; i < weights.size(); ++i) |
|---|
| 27 | startOffsets[i + 1] = startOffsets[i] + weights[i]; |
|---|
| 28 | } |
|---|
| 29 | |
|---|
| 30 | inline virtual Region<DIM> getRegion(const unsigned& node) |
|---|
| 31 | { |
|---|
| 32 | return Region<DIM>( |
|---|
| 33 | partition[startOffsets[node]], |
|---|
| 34 | partition[startOffsets[node + 1]]); |
|---|
| 35 | } |
|---|
| 36 | |
|---|
| 37 | private: |
|---|
| 38 | PARTITION partition; |
|---|
| 39 | SuperVector<unsigned> startOffsets; |
|---|
| 40 | }; |
|---|
| 41 | |
|---|
| 42 | }; |
|---|
| 43 | }; |
|---|
| 44 | |
|---|
| 45 | #endif |
|---|
| 46 | #endif |
|---|