| 1 |
/* |
| 2 |
* (C) Copyright 2013 ECMWF. |
| 3 |
* |
| 4 |
* This software is licensed under the terms of the Apache Licence Version 2.0 |
| 5 |
* which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. |
| 6 |
* In applying this licence, ECMWF does not waive the privileges and immunities |
| 7 |
* granted to it by virtue of its status as an intergovernmental organisation |
| 8 |
* nor does it submit to any jurisdiction. |
| 9 |
*/ |
| 10 |
|
| 11 |
#pragma once |
| 12 |
|
| 13 |
#include "atlas/grid/Distribution.h" |
| 14 |
#include "atlas/grid/Grid.h" |
| 15 |
#include "atlas/grid/detail/distribution/SerialDistribution.h" |
| 16 |
#include "atlas/grid/detail/partitioner/Partitioner.h" |
| 17 |
|
| 18 |
namespace atlas { |
| 19 |
namespace grid { |
| 20 |
namespace detail { |
| 21 |
namespace partitioner { |
| 22 |
|
| 23 |
class SerialPartitioner : public Partitioner { |
| 24 |
public: |
| 25 |
SerialPartitioner(): |
| 26 |
Partitioner(1, util::NoConfig()) { |
| 27 |
} |
| 28 |
SerialPartitioner(int /*N*/): |
| 29 |
SerialPartitioner() { |
| 30 |
} |
| 31 |
SerialPartitioner(int /*N*/, const eckit::Parametrisation& config): |
| 32 |
SerialPartitioner(config) { |
| 33 |
} |
| 34 |
SerialPartitioner(const eckit::Parametrisation& config); |
| 35 |
|
| 36 |
std::string type() const override { return static_type(); } |
| 37 |
static std::string static_type() { return "serial"; } |
| 38 |
|
| 39 |
Distribution partition(const Grid& grid) const override { |
| 40 |
return Distribution{new distribution::SerialDistribution{grid, part_}}; |
| 41 |
} |
| 42 |
|
| 43 |
void partition(const Grid& grid, int part[]) const override { |
| 44 |
gidx_t gridsize = grid.size(); |
| 45 |
for (gidx_t n = 0; n < gridsize; ++n) { |
| 46 |
part[n] = part_; |
| 47 |
} |
| 48 |
} |
| 49 |
private: |
| 50 |
int part_{0}; |
| 51 |
}; |
| 52 |
|
| 53 |
|
| 54 |
} // namespace partitioner |
| 55 |
} // namespace detail |
| 56 |
} // namespace grid |
| 57 |
} // namespace atlas |