26#include <unordered_map>
47typedef std::vector<std::unordered_map<int,int>>
Partition;
55typedef std::vector<std::vector<int>>
Remotes;
61 std::vector<int> count(
nspmd,0);
62 partition.reserve(
nspmd);
63 for(
int i = 0 ; i < *size ; i++)
66 assert( cep[i] <
nspmd);
67 partition[cep[i]][i]=count[cep[i]];
77void cpp_count_candidates(
int *nbCand,
int *sizeM,
int *cepM,
int *localIdM,
int *candM,
int *sizeS,
int *cepS,
int *localIdS,
int *candS,
int *
nspmd,
int * secondaryRemoteCount,
int * localIdx)
112 const int nspmd2 = (*nspmd)*(*nspmd);
113 std::vector<Candidates> candidates(nspmd2, std::vector<std::pair<int,int>>());
114 Remotes secondaryRemotes(nspmd2, std::vector<int>());
116 for(
int i = 0 ; i < *nbCand ; i++)
119 const int currentM = candM[i] - 1;
120 const int currentS = candS[i] - 1;
121 assert(currentM < *sizeM);
122 assert(currentM >= 0 );
123 assert(currentS < *sizeS);
124 assert(currentS >= 0 );
125 const int domainM = cepM[currentM];
126 const int domainS = cepS[currentS];
127 const int oneD = domainM * (*nspmd) + domainS;
137 assert(domainM >= 0);
138 assert(domainM < *
nspmd);
140 assert(domainS < *
nspmd);
141 if(domainS != domainM)
144 candidates[oneD].push_back(std::make_pair(i,localIdS[currentS]));
148 candM[i] = localIdM[currentM];
149 candS[i] = localIdS[currentS];
150 localIdx[i] = localIdS[currentS];
154 for(
int domainM = 0 ; domainM < *
nspmd ; domainM++)
157 for(
int domainS = 0 ; domainS < *
nspmd ; domainS++)
160 const int oneD = domainM * (*nspmd) + domainS;
161 secondaryRemoteCount[oneD] = 0;
162 secondaryRemotes[oneD] = {} ;
163 if(domainS != domainM)
167 std::map<int,VectOfCandPtr> secondaryToCand;
170 std::set<int> secondarySet;
175 for(
auto & c : candidates[oneD])
177 auto it = secondarySet.insert(c.second);
178 secondaryToCand[c.second].push_back(&(c));
181 secondaryRemotes[oneD].assign(secondarySet.begin(),secondarySet.end());
185 secondaryRemoteCount[oneD] = secondaryRemotes[oneD].size();
186 int idxInFi = offset;
190 for(
auto & sc : secondaryToCand)
193 for(
auto & ptr : sc.second)
196 (*ptr).second = -( idxInFi);
198 candS[(*ptr).first] = -(idxInFi);
204 secondaryRemoteCount[oneD] = 0;
206 offset+= secondaryRemoteCount[oneD];
222void _FCALL CPP_COUNT_CANDIDATES(
int *nbCand,
int *sizeM,
int *cepM,
int *localIdM,
int *candM,
int *sizeS,
int *cepS,
int *localIdS,
int *candS,
int *
nspmd,
int * secondaryRemoteCount,
int * localIdx)
224 cpp_count_candidates(nbCand, sizeM, cepM, localIdM, candM, sizeS, cepS, localIdS, candS,
nspmd, secondaryRemoteCount, localIdx);
226void cpp_count_candidates__(
int *nbCand,
int *sizeM,
int *cepM,
int *localIdM,
int *candM,
int *sizeS,
int *cepS,
int *localIdS,
int *candS,
int *
nspmd,
int * secondaryRemoteCount,
int * localIdx)
228 cpp_count_candidates(nbCand, sizeM, cepM, localIdM, candM, sizeS, cepS, localIdS, candS,
nspmd, secondaryRemoteCount, localIdx);
230void cpp_count_candidates_(
int *nbCand,
int *sizeM,
int *cepM,
int *localIdM,
int *candM,
int *sizeS,
int *cepS,
int *localIdS,
int *candS,
int *
nspmd,
int * secondaryRemoteCount,
int * localIdx)
232 cpp_count_candidates(nbCand, sizeM, cepM, localIdM, candM, sizeS, cepS, localIdS, candS,
nspmd, secondaryRemoteCount, localIdx);