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

Function main

Examples/ParallelProcessing/Generic/Cxx/TaskParallelismWithPorts.cxx:37–72  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

35}
36
37int main(int argc, char* argv[])
38{
39
40 // Note that this will create a vtkMPIController if MPI
41 // is configured, vtkThreadedController otherwise.
42 vtkMultiProcessController* controller = vtkMultiProcessController::New();
43 controller->Initialize(&argc, &argv);
44
45 // When using MPI, the number of processes is determined
46 // by the external program which launches this application.
47 // However, when using threads, we need to set it ourselves.
48 if (controller->IsA("vtkThreadedController"))
49 {
50 // Set the number of processes to 2 for this example.
51 controller->SetNumberOfProcesses(2);
52 }
53 int numProcs = controller->GetNumberOfProcesses();
54
55 if (numProcs != 2)
56 {
57 std::cerr << "This example requires two processes." << endl;
58 controller->Finalize();
59 controller->Delete();
60 return 1;
61 }
62
63 // Execute the function named "process" on both processes
64 controller->SetSingleMethod(process, 0);
65 controller->SingleMethodExecute();
66
67 // Clean-up and exit
68 controller->Finalize();
69 controller->Delete();
70
71 return 0;
72}

Callers

nothing calls this directly

Calls 9

IsAMethod · 0.80
GetNumberOfProcessesMethod · 0.80
DeleteMethod · 0.65
NewFunction · 0.50
InitializeMethod · 0.45
SetNumberOfProcessesMethod · 0.45
FinalizeMethod · 0.45
SetSingleMethodMethod · 0.45
SingleMethodExecuteMethod · 0.45

Tested by

no test coverage detected