Home CPSC 425

Lab 4: False Sharing

 

Objective

To identify and resolve cache sharing issues, and see their effect on performance.


 

Task

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 issues.

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.


 

Details

  1. Start by compiling and running the program and measuring how long it takes to execute.
  2. Next think about the variables used in the loop which estimates Pi. Which variable could be causing cache contention.
  3. Change the way that the estimate_pi function accesses its data such that it works better with the cache system.
  4. Run the program again and measure how long it takes to execute. It should be at least twice as fast.

 

Submitting

When you are finished, submit your modified program to Canvas. As a comment, include a brief description of what was causing the false sharing issue and how you fixed it.

Copyright © 2024 Ian Finlayson | Licensed under a Attribution-NonCommercial 4.0 International License.