| 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 <string> |
| 14 |
#include <vector> |
| 15 |
|
| 16 |
#include "atlas/library/config.h" |
| 17 |
#include "atlas/util/Config.h" |
| 18 |
#include "atlas/util/Object.h" |
| 19 |
|
| 20 |
|
| 21 |
namespace eckit { |
| 22 |
class Parametrisation; |
| 23 |
} |
| 24 |
|
| 25 |
namespace atlas { |
| 26 |
|
| 27 |
class Grid; |
| 28 |
namespace grid { |
| 29 |
namespace detail { |
| 30 |
|
| 31 |
namespace partitioner { |
| 32 |
class Partitioner; |
| 33 |
} |
| 34 |
namespace grid { |
| 35 |
class Grid; |
| 36 |
} |
| 37 |
} // namespace detail |
| 38 |
} // namespace grid |
| 39 |
} // namespace atlas |
| 40 |
|
| 41 |
namespace atlas { |
| 42 |
namespace grid { |
| 43 |
|
| 44 |
class DistributionImpl : public util::Object { |
| 45 |
public: |
| 46 |
using Config = atlas::util::Config; |
| 47 |
virtual ~DistributionImpl() {} |
| 48 |
virtual int partition(const gidx_t gidx) const = 0; |
| 49 |
virtual bool functional() const = 0; |
| 50 |
virtual idx_t nb_partitions() const = 0; |
| 51 |
virtual gidx_t size() const = 0; |
| 52 |
|
| 53 |
virtual const std::vector<idx_t>& nb_pts() const = 0; |
| 54 |
|
| 55 |
virtual idx_t max_pts() const = 0; |
| 56 |
virtual idx_t min_pts() const = 0; |
| 57 |
|
| 58 |
virtual const std::string& type() const = 0; |
| 59 |
|
| 60 |
virtual void print(std::ostream&) const = 0; |
| 61 |
|
| 62 |
virtual size_t footprint() const = 0; |
| 63 |
|
| 64 |
virtual void hash(eckit::Hash&) const = 0; |
| 65 |
|
| 66 |
virtual void partition(gidx_t begin, gidx_t end, int partitions[]) const = 0; |
| 67 |
}; |
| 68 |
|
| 69 |
|
| 70 |
extern "C" { |
| 71 |
DistributionImpl* atlas__GridDistribution__new(idx_t size, int part[], int part0); |
| 72 |
DistributionImpl* atlas__GridDistribution__new__Grid_Config(const detail::grid::Grid* grid, |
| 73 |
const eckit::Parametrisation* config); |
| 74 |
DistributionImpl* atlas__GridDistribution__new__Grid_Partitioner(const detail::grid::Grid* grid, |
| 75 |
const detail::partitioner::Partitioner* partitioner); |
| 76 |
int atlas__GridDistribution__partition_int32(DistributionImpl* dist, int i); |
| 77 |
int atlas__GridDistribution__partition_int64(DistributionImpl* dist, long i); |
| 78 |
void atlas__GridDistribution__delete(DistributionImpl* This); |
| 79 |
void atlas__GridDistribution__nb_pts(DistributionImpl* This, idx_t nb_pts[]); |
| 80 |
idx_t atlas__atlas__GridDistribution__nb_partitions(DistributionImpl* This); |
| 81 |
} |
| 82 |
|
| 83 |
} // namespace grid |
| 84 |
} // namespace atlas |