This is a homework problem that I have
In a multicore system, you are running the code on the right on each core, and it suffers from false sharing. You can assume
t_id is set to a unique thread identifier (e.g. 0-15). How could you change the code to reduce false sharing?
for (int i=0; i<N; i++)
totals[t_id] += a[i];
What I'm having trouble with is seeing where the false sharing is occurring. It says state t_id is set to a unique thread identifier, so doesn't that mean there's only 1 thread that's accessing the data here?
We only briefly went over false sharing, but from what I've learned false sharing occurs when a cache miss occurs because the data was invalidated previously due to an "irrelevant" data being written/read from a different cache. But if the thread is the same, then doesn't that mean it's the same cache being used to write/read? How would false sharing occur here?