[1918] | 1 | #ifndef __GRID_REMOTE_CONNECTOR_HPP__ |
---|
| 2 | #define __GRID_REMOTE_CONNECTOR_HPP__ |
---|
| 3 | |
---|
| 4 | #include "xios_spl.hpp" |
---|
| 5 | #include "array_new.hpp" |
---|
| 6 | #include "mpi.hpp" |
---|
| 7 | #include "local_view.hpp" |
---|
| 8 | #include "distributed_view.hpp" |
---|
| 9 | #include "context_client.hpp" |
---|
| 10 | |
---|
| 11 | |
---|
| 12 | namespace xios |
---|
| 13 | { |
---|
| 14 | |
---|
| 15 | class CGridRemoteConnector |
---|
| 16 | { |
---|
| 17 | |
---|
| 18 | public: |
---|
| 19 | |
---|
[2267] | 20 | CGridRemoteConnector(vector<shared_ptr<CLocalView>>& srcView, vector<shared_ptr<CDistributedView>>& dstView, MPI_Comm localComm, int remoteSize) ; |
---|
| 21 | CGridRemoteConnector(vector<shared_ptr<CLocalView>>& srcView, vector<shared_ptr<CLocalView>>& dstView, MPI_Comm localComm, int remoteSize) ; |
---|
[2179] | 22 | void computeViewDistribution(void) ; |
---|
[2291] | 23 | void computeConnector(bool eliminateRedundant=true) ; |
---|
[2397] | 24 | void computeConnectorMethods(bool reverse=false) ; |
---|
[2291] | 25 | void computeConnectorRedundant(void) ; |
---|
[2267] | 26 | void computeGenericMethod(vector<shared_ptr<CLocalView>>& srcView, vector<shared_ptr<CDistributedView>>& dstView, vector<int>& indElements) ; |
---|
[2179] | 27 | void computeSrcDstNonDistributed(int i, map<int,bool>& ranks) ; |
---|
| 28 | void computeDstNonDistributed(int i, map<int,bool>& ranks) ; |
---|
| 29 | void computeSrcNonDistributed(int i) ; |
---|
[2397] | 30 | void computeSrcNonDistributedReverse(int i) ; |
---|
| 31 | void computeRedondantRanks(bool reverse=false) ; |
---|
[1918] | 32 | std::map<int, CArray<size_t,1>>& getDistributedGlobalIndex(int pos) { return elements_[pos] ;} |
---|
[2236] | 33 | const vector<bool>& getIsSrcViewDistributed(void) { return isSrcViewDistributed_ ;} |
---|
| 34 | const vector<bool>& getIsDstViewDistributed(void) { return isDstViewDistributed_ ;} |
---|
| 35 | const set<int>& getRankToRemove(void) {return rankToRemove_;} |
---|
| 36 | |
---|
| 37 | protected: |
---|
[2179] | 38 | |
---|
| 39 | /** |
---|
| 40 | * Source views composing the source grid. The vector store an internal copy of pointer elements composing the grid. |
---|
| 41 | * It is feed at construction time |
---|
| 42 | */ |
---|
[2267] | 43 | vector<shared_ptr<CLocalView>> srcView_ ; |
---|
[2179] | 44 | |
---|
| 45 | /** |
---|
| 46 | * Destination views composing the source grid. The vector store an internal copy of pointer elements composing the grid |
---|
| 47 | * It is feed at construction time |
---|
| 48 | */ |
---|
[2267] | 49 | vector<shared_ptr<CDistributedView>> dstView_ ; |
---|
[2179] | 50 | |
---|
| 51 | /** |
---|
| 52 | * The list of global indices to send to each rank of the remote view (servers). The vector store the information for each element, and the map |
---|
| 53 | * specify a list of global indices to send to each rank of the remote view. |
---|
| 54 | * size of element_[] -> number of elements composing the grids (source/destination) |
---|
| 55 | * element[i][rank] == CArray<size_t,1> -> list of global indices to send to the remote process of rank \b rank for the view \b i |
---|
| 56 | * The is computed when calling computeConnector internal methods |
---|
| 57 | * map can be returned trough the public accessor : getDistributedGlobalIndex(int) |
---|
| 58 | */ |
---|
| 59 | vector<map<int, CArray<size_t,1>>> elements_ ; |
---|
| 60 | |
---|
| 61 | /** |
---|
| 62 | /* internal copy of the local communicator (client workflow). Feed at construction time. |
---|
| 63 | */ |
---|
[1918] | 64 | MPI_Comm localComm_ ; |
---|
[2179] | 65 | |
---|
| 66 | /** |
---|
| 67 | /* size of the remote communicator (== nb of servers). Feed at consctruction time |
---|
| 68 | */ |
---|
[1938] | 69 | int remoteSize_ ; |
---|
[1918] | 70 | |
---|
[2179] | 71 | /** |
---|
| 72 | /* for each view composing the source grid, the vector store the information about the distribution of the element, i.e. |
---|
| 73 | * if each ranks of the local view has exactly the same global indices than each other. This is computed when calling |
---|
| 74 | * \b computeViewDistribution method. |
---|
| 75 | */ |
---|
| 76 | vector<bool> isSrcViewDistributed_ ; |
---|
| 77 | |
---|
| 78 | /** |
---|
| 79 | /* for each view composing the destination grid, the vector store the information about the distribution of the element, i.e. |
---|
| 80 | * if each ranks of the remote view has exactly the same global indices than each other. This is computed when calling |
---|
| 81 | * \b computeViewDistribution method. |
---|
| 82 | */ |
---|
| 83 | vector<bool> isDstViewDistributed_ ; |
---|
[2236] | 84 | |
---|
| 85 | /** |
---|
| 86 | /* Redondant ranks of the \b elements_ are stored there by calling computeRedondantRanks(), to be removed latter or to be retrieve from elsewhere. |
---|
| 87 | */ |
---|
| 88 | set<int> rankToRemove_ ; |
---|
[2179] | 89 | |
---|
| 90 | |
---|
[1918] | 91 | } ; |
---|
| 92 | |
---|
| 93 | } |
---|
| 94 | |
---|
| 95 | #endif |
---|