root/src/parallelization/hiparsimulator/vanillaregionaccumulator.h @ 108:605da18c9c0a

Revision 108:605da18c9c0a, 1.3 KB (checked in by Andreas Schaefer <gentryx@…>, 16 months ago)
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
9namespace LibGeoDecomp {
10namespace HiParSimulator {
11
12template<typename PARTITION>
13class VanillaRegionAccumulator : public RegionAccumulator<PARTITION::DIM>
14{
15public:
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
37private:
38    PARTITION partition;
39    SuperVector<unsigned> startOffsets;
40};
41
42};
43};
44
45#endif
46#endif
Note: See TracBrowser for help on using the browser.