Parallelizing SIR Epidemic Spread Simulation Using Pthreads, OpenMP, and MPI
This paper evaluates the performance of Pthreads, OpenMP, and MPI in parallelizing a computationally intensive SIR epidemic simulation on a 2D grid, demonstrating that MPI achieves superior speedup and near-linear scaling for large grids compared to the moderate and limited scaling observed in OpenMP and Pthreads due to synchronization and memory contention overheads.
Original paper licensed under CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). This is an AI-generated explanation of the paper below. It is not written or endorsed by the authors. For technical accuracy, refer to the original paper. Read full disclaimer
Imagine a vast, invisible city where millions of tiny citizens live in a grid, each occupying a single square. In this city, a sickness spreads not through air or water, but by touching a neighbor. If a healthy person touches someone who is sick, they might catch the illness. If they are sick, they might eventually recover and become immune. Scientists use computer models to simulate this kind of spread, helping public health officials understand how a disease might move through a real population. The challenge is that these simulations are incredibly heavy work. To get a clear picture of a national outbreak, the computer must update the status of every single person in the grid, day after day, for hundreds of days. Doing this one step at a time on a standard computer can take far too long to be useful in an emergency.
This is where the work of researcher Amna Atiq comes in. She tackled the problem of how to make these simulations run faster by using the power of parallel computing. Instead of asking one processor to do all the heavy lifting, she explored ways to split the work among many processors at once, much like a large team of workers dividing a massive mural into sections so everyone can paint their part simultaneously. Her study focused on a specific type of model known as the SIR model, which tracks three groups: those who are susceptible to the disease, those who are infected, and those who have recovered. The goal was to see which method of splitting the work was the most efficient for a computer to handle.
Atiq tested three different approaches to organizing this team of workers. The first method, known as Pthreads, divides the grid into horizontal strips, assigning each strip to a different thread of execution within a single computer. The second method, called OpenMP, uses a simpler set of instructions to automatically divide the rows of the grid among available processors. The third approach, MPI, is designed for distributed systems where multiple computers or processors communicate by sending messages to one another, passing the edges of their assigned grid sections back and forth to ensure the infection spreads correctly across the whole map.
The results of the simulation revealed clear differences in how well each method performed. When the researchers ran the simulation on a grid representing one thousand by one thousand people over one hundred time steps, the standard single-threaded approach took about 1.58 seconds to complete. Using the Pthreads method on a four-core machine, the time dropped, but the speedup was limited. The workers spent too much time waiting for each other to finish their sections before they could swap their work, and they occasionally interfered with each other's memory space, slowing things down. The OpenMP method performed slightly better, finishing the task in under 0.7 seconds, but it too hit a wall when more processors were added, largely due to the time spent synchronizing the workers at the end of each day.
The most successful approach was the MPI method. By treating the grid as a collection of separate pieces that communicated only at their boundaries, this method scaled remarkably well. When the researchers increased the number of processors to eight, the simulation ran more than six times faster than the original single-threaded version. This happened because the time spent sending messages between processors was very small compared to the time spent calculating the health status of the people within each section. While the other methods struggled with the overhead of coordinating many workers on a single machine, the message-passing approach kept the workers focused on their own tasks, only pausing briefly to share the necessary information about the edges of their territories.
The study also highlighted the trade-offs involved in choosing a method. The message-passing approach required the most complex code and careful planning to ensure the pieces of the grid were sent and received correctly without getting stuck. The automatic division method was the easiest to write but offered the least improvement in speed. The thread-based method sat in the middle but suffered from technical issues related to how the computer's memory is organized. Ultimately, the research showed that for large-scale epidemic simulations, splitting the work across multiple processors using message passing provides the most significant speed advantage, allowing scientists to run complex models in a fraction of the time required by older methods. This efficiency is crucial for preparing for future outbreaks, where every second of simulation time can translate into better preparation and response strategies.
Drowning in papers in your field?
Get daily digests of the most novel papers matching your research keywords — with technical summaries, in your language.