| 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 |
|
| 15 |
#include "atlas/grid/detail/distribution/DistributionFunction.h" |
| 16 |
|
| 17 |
namespace atlas { |
| 18 |
namespace grid { |
| 19 |
namespace detail { |
| 20 |
namespace distribution { |
| 21 |
|
| 22 |
template <typename Int> |
| 23 |
class BandsDistribution : public DistributionFunctionT<BandsDistribution<Int>> { |
| 24 |
private: |
| 25 |
Int blocksize_; |
| 26 |
Int nb_blocks_; |
| 27 |
Int nb_partitions_Int_; |
| 28 |
|
| 29 |
public: |
| 30 |
BandsDistribution(const Grid& grid, idx_t nb_partitions, const std::string& type, size_t blocksize = 1); |
| 31 |
|
| 32 |
ATLAS_ALWAYS_INLINE int function(gidx_t index) const { |
| 33 |
Int iblock = static_cast<Int>(index / blocksize_); |
| 34 |
return (iblock * nb_partitions_Int_) / nb_blocks_; |
| 35 |
} |
| 36 |
|
| 37 |
static bool detectOverflow(size_t gridsize, size_t nb_partitions, size_t blocksize); |
| 38 |
}; |
| 39 |
|
| 40 |
|
| 41 |
} // namespace distribution |
| 42 |
} // namespace detail |
| 43 |
} // namespace grid |
| 44 |
} // namespace atlas |