| 1 |
/* |
| 2 |
* (C) Crown Copyright 2021 Met Office |
| 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 |
*/ |
| 7 |
|
| 8 |
#pragma once |
| 9 |
|
| 10 |
#include <string> |
| 11 |
|
| 12 |
#include "atlas/redistribution/detail/RedistributionImpl.h" |
| 13 |
|
| 14 |
namespace atlas { |
| 15 |
namespace redistribution { |
| 16 |
namespace detail { |
| 17 |
|
| 18 |
class RedistributeGeneric : public RedistributionImpl { |
| 19 |
public: |
| 20 |
static std::string static_type() { return "RedistributeGeneric"; } |
| 21 |
|
| 22 |
std::string type() const override { return static_type(); } |
| 23 |
|
| 24 |
void do_setup() override; |
| 25 |
|
| 26 |
void execute(const Field& source, Field& target) const override; |
| 27 |
|
| 28 |
void execute(const FieldSet& source, FieldSet& target) const override; |
| 29 |
|
| 30 |
private: |
| 31 |
// Determine datatype. |
| 32 |
void do_execute(const Field& source, Field& target) const; |
| 33 |
// Determine rank. |
| 34 |
template <typename Value> |
| 35 |
void do_execute(const Field& source, Field& target) const; |
| 36 |
// Perform redistribution. |
| 37 |
template <typename Value, int Rank> |
| 38 |
void do_execute(const Field& source, Field& target) const; |
| 39 |
|
| 40 |
// Local indices to send to each PE |
| 41 |
std::vector<idx_t> sourceLocalIdx_{}; |
| 42 |
|
| 43 |
// Local indices to receive from each PE. |
| 44 |
std::vector<idx_t> targetLocalIdx_{}; |
| 45 |
|
| 46 |
// Partial sum of number of columns to send to each PE. |
| 47 |
std::vector<int> sourceDisps_{}; |
| 48 |
|
| 49 |
// Partial sum of number of columns to receive from each PE. |
| 50 |
std::vector<int> targetDisps_{}; |
| 51 |
|
| 52 |
std::string mpi_comm_; |
| 53 |
}; |
| 54 |
|
| 55 |
} // namespace detail |
| 56 |
} // namespace redistribution |
| 57 |
} // namespace atlas |