Lab 4: False Sharing
To identify and resolve cache sharing issues, and see their effect on performance.
For this lab, you will work with the program 04-sharing.c. This is a version of the PI estimate
program that works with four threads. The program splits the work into four
threads, but does not achieve the expected speedup because of caching
Your job for this lab is to fix this issue which will result in the program
running at least twice as fast as it does now.
- Start by compiling and running the program and measuring how long it takes
- Next think about the variables used in the loop which estimates Pi. Which
variable could be causing cache contention..
- Change the way that the estimate_pi function accesses its data such that it
works better with the cache system.
- Run the program again and measure how long it takes to execute. It should
be at least twice as fast.
When you are finished, your modified program to email@example.com.
Also include in the email a brief description of what was causing the
false sharing issue and how you fixed it.
Ian Finlayson | Licensed under a Attribution-NonCommercial 4.0 International License.