MCPcopy Create free account
hub / github.com/Kitware/VTK / PartitionController

Method PartitionController

Parallel/Core/vtkMultiProcessController.cxx:277–328  ·  view source on GitHub ↗

------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

275
276//------------------------------------------------------------------------------
277vtkMultiProcessController* 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//------------------------------------------------------------------------------
331unsigned long vtkMultiProcessController::AddRMICallback(

Callers

nothing calls this directly

Calls 11

GetNumberOfProcessesMethod · 0.95
CreateSubControllerMethod · 0.95
RemoveAllProcessIdsMethod · 0.80
AddProcessIdMethod · 0.80
AllGatherMethod · 0.45
dataMethod · 0.45
assignMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
insertMethod · 0.45
InitializeMethod · 0.45

Tested by

no test coverage detected