Reputation: 53
I am writing code and I need to initialize variables and execute a series of tasks sequentially and only once. Following that, I am currently using pthreading to run parallel processes before returning to sequential code to sort the data and perform a binary search. The parallel processes are simply a many reads from multiple (roughly 35) sockets simultaneously. I have been asked to implement the same setup using MPI, and my current understanding is if I use MPI every single process will execute the entire program and the parallal processing is not confined to the lines where MPI_Init_thread and MPI_Finalize are placed. I my understanding correct? Or is there a way to execute sequential code before and after parallel code while using MPI?
Upvotes: 2
Views: 1735
Reputation: 771
If you want to execute sequential code you can do
if (myrank == 0){
//code
}
and the main thread (with id = 0) will execute the code alone so you ll have no parralelism in that spot.
Upvotes: 3