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