Questions tagged [false-sharing]

False sharing is the condition, where in parallel programs, memory cache lines are shared by two or more threads and writes on one cache line would force other cores working on the same line to re-validate their cache. This is a concurrency anti-pattern.

Questions with this tag should be about a suspected or actual false sharing problem.

False sharing is the condition in which in parallel programs, in which memory cache lines which are shared by two or more threads. Writes on one cache line would force other cores working in the same line to re-validate their cache. This is a concurrency anti-pattern.

enter image description here

Note that in the diagram above, Thread 1 writes to A and never B, yet Thread 2 must re-validate its cache to continue computation.

Common ways to alleviate false sharing include storing a thread local result to update to a shared spaced once the computation is completed, and/or spacing contiguous memory blocks that are shared, so they are not on the same cache line.

More information:

Wikipedia

C++ Today Blog Article

93 questions
0
votes
1 answer

Effective way of signaling and keeping a pthread open?

I have some code that is trying to run some intense matrix processing, so I thought it would be faster if I multithreaded it. However, what my intention is is to keep the thread alive so that it can be used in the future for more processing. Here is…
G Boggs
  • 381
  • 1
  • 6
  • 19
0
votes
1 answer

How would you avoid False Sharing in a scenario like this?

In the code below I have parallelised using OpenMP's standard parallel for clause. #pragma omp parallel for private(i, j, k, d_equ) shared(cells, tmp_cells, params) for(i=0; i
Michael Aquilina
  • 5,352
  • 4
  • 33
  • 38
-1
votes
1 answer

False sharing and adding an element to a Queue

Given two threads a and b that read from a shared queue. If a modifies the queue and adds an element to it does it mean that when b comes along it will do a cache miss because the queue has been modified? As in, will altering something at the end of…
1 2 3 4 5 6
7