Difference between revisions of "DPS921/Group 8"

From CDOT Wiki
Jump to: navigation, search
(Padding)
(Synchronization)
Line 27: Line 27:
  
 
== Synchronization ==
 
== Synchronization ==
 +
The other way to eliminating false sharing is to implement a mutual exclusion construct. This the better method than using padding as there is no wasting of memory and cache lines are not rendered inaccessible due to being invalidated. Programming a mutual exclusion implementation is done by using the omp pragma critical. The critical section restricts statements to a single thread to process at a time, making variables local to a single thread.
  
 
=Conclusion =
 
=Conclusion =

Revision as of 01:25, 26 November 2018

Group 8

Our Project: Analyzing False Sharing - Case Studies

Group Members

  1. Aditya Rahman
  2. Zhijian Zhou
  3. eMail All

False Sharing in Parallel Programming

Introduction

Location of the problem - Local cache

Signs of false sharing

Solutions

Padding

One way to eliminating false sharing is to add in padding to the data. The idea of padding in general is for memory alignment, by utilizing padding we can eliminate cache line invalidation interfering with read and write of elements.

How padding works: Let's say we have an int element num[i] = 10; in memory this would be stored as 40 bytes ( 10 * 4 byte) and a single standard cache line is 64 byte which means 24 byte needs to be padded otherwise another element will occupy that region which will result in 2 or more thread accessing same cache line causing false sharing.

Cacheline1.jpeg

Cacheline2.jpeg

Synchronization

The other way to eliminating false sharing is to implement a mutual exclusion construct. This the better method than using padding as there is no wasting of memory and cache lines are not rendered inaccessible due to being invalidated. Programming a mutual exclusion implementation is done by using the omp pragma critical. The critical section restricts statements to a single thread to process at a time, making variables local to a single thread.

Conclusion