root/src/parallelization/hiparsimulator/test/parallel_mpi_1/innersetmarkertest.h @ 127:3e368f5be1d3

Revision 127:3e368f5be1d3, 2.3 KB (checked in by Andreas Schaefer <gentryx@…>, 15 months ago)
Line 
1#include <cxxtest/TestSuite.h>
2#include <libgeodecomp/misc/superset.h>
3#include <libgeodecomp/parallelization/hiparsimulator/partitions/stripingpartition.h>
4#include <libgeodecomp/parallelization/hiparsimulator/innersetmarker.h>
5#include <libgeodecomp/parallelization/hiparsimulator/vanillaregionaccumulator.h>
6
7using namespace LibGeoDecomp;
8using namespace HiParSimulator;
9
10namespace LibGeoDecomp {
11namespace HiParSimulator {
12
13class InnerSetMarkerTest : public CxxTest::TestSuite
14{
15public:
16    void setUp()
17    {
18        intersector = PartitionManager<2>();
19        dimensions = Coord<2>(20, 400);
20        partition = StripingPartition<2>(Coord<2>(0, 0), dimensions);
21
22        // assume this is a dual cluster setup and on the current
23        // level we're in the second cluster which is responsible for
24        // the (dimensions.y() - offset / dimensions.x()) last lines of
25        // the StripingPartition.
26        startLine = 130;
27        offset = startLine * dimensions.x();
28        ghostZoneWidth = 6;
29        rank = 0;
30        weights = SuperVector<long> (9, 30 * dimensions.x());
31        weights[3] = 40 * dimensions.x();
32        weights[5] = 20 * dimensions.x();
33        // sanity check
34        TS_ASSERT_EQUALS(weights.sum() + offset, dimensions.x() * dimensions.y());
35
36        intersector.resetRegions(
37            CoordBox<2>(Coord<2>(), dimensions),
38            new VanillaRegionAccumulator<StripingPartition<2> >(
39                partition,
40                offset,
41                weights),
42            rank,
43            ghostZoneWidth);
44    }
45
46    void testBasic()
47    {
48        InnerSetMarker<2> marker(intersector);
49        SuperSet<Coord<2> > expected, actual;
50
51        for (unsigned i = 0; i <= ghostZoneWidth; ++i) {
52            for (int y = startLine + i; 
53                 y < startLine + weights[0] / dimensions.x() - i;
54                 ++y)
55                for (int x = 0; x < dimensions.x(); ++x)
56                    expected.insert(Coord<2>(x, y));
57            for (Region<2>::Iterator c = marker.begin(i); c != marker.end(i); ++c)
58                actual.insert(*c);
59            TS_ASSERT_EQUALS(expected, actual);
60        }
61    }
62
63private:
64    PartitionManager<2> intersector;
65    StripingPartition<2> partition;
66    Coord<2> dimensions;
67    SuperVector<long> weights;
68    unsigned startLine;
69    unsigned offset;
70    unsigned ghostZoneWidth;
71    unsigned rank;
72
73};
74
75}
76}
Note: See TracBrowser for help on using the browser.