------------------------------------------------------------------------------
| 275 | |
| 276 | //------------------------------------------------------------------------------ |
| 277 | vtkMultiProcessController* vtkMultiProcessController::PartitionController( |
| 278 | int localColor, int localKey) |
| 279 | { |
| 280 | vtkMultiProcessController* subController = nullptr; |
| 281 | |
| 282 | int numProc = this->GetNumberOfProcesses(); |
| 283 | |
| 284 | std::vector<int> allColors(numProc); |
| 285 | this->AllGather(&localColor, allColors.data(), 1); |
| 286 | |
| 287 | std::vector<int> allKeys(numProc); |
| 288 | this->AllGather(&localKey, allKeys.data(), 1); |
| 289 | |
| 290 | std::vector<bool> inPartition; |
| 291 | inPartition.assign(numProc, false); |
| 292 | |
| 293 | for (int i = 0; i < numProc; i++) |
| 294 | { |
| 295 | if (inPartition[i]) |
| 296 | continue; |
| 297 | int targetColor = allColors[i]; |
| 298 | std::list<int> partitionIds; // Make sorted list, then put in group. |
| 299 | for (int j = i; j < numProc; j++) |
| 300 | { |
| 301 | if (allColors[j] != targetColor) |
| 302 | continue; |
| 303 | inPartition[j] = true; |
| 304 | std::list<int>::iterator iter = partitionIds.begin(); |
| 305 | while ((iter != partitionIds.end()) && (allKeys[*iter] <= allKeys[j])) |
| 306 | { |
| 307 | ++iter; |
| 308 | } |
| 309 | partitionIds.insert(iter, j); |
| 310 | } |
| 311 | // Copy list into process group. |
| 312 | vtkNew<vtkProcessGroup> group; |
| 313 | group->Initialize(this); |
| 314 | group->RemoveAllProcessIds(); |
| 315 | for (std::list<int>::iterator iter = partitionIds.begin(); iter != partitionIds.end(); ++iter) |
| 316 | { |
| 317 | group->AddProcessId(*iter); |
| 318 | } |
| 319 | // Use group to create controller. |
| 320 | vtkMultiProcessController* sc = this->CreateSubController(group); |
| 321 | if (sc) |
| 322 | { |
| 323 | subController = sc; |
| 324 | } |
| 325 | } |
| 326 | |
| 327 | return subController; |
| 328 | } |
| 329 | |
| 330 | //------------------------------------------------------------------------------ |
| 331 | unsigned long vtkMultiProcessController::AddRMICallback( |
nothing calls this directly
no test coverage detected