True sharing occurs when two different processors access the same variable.
unsigned int sum;
{
// parallel section
for (int i = 0; i < N; i++)
sum += a[i]; // sum is shared between all threads
}
Fix
atomic
- Thread Local Storage
Nov 04, 20241 min read
True sharing occurs when two different processors access the same variable.
unsigned int sum;
{
// parallel section
for (int i = 0; i < N; i++)
sum += a[i]; // sum is shared between all threads
}
atomic