Changes

Jump to: navigation, search

GPU621/False Sharing

129 bytes added, 23:38, 26 November 2021
Example
In workshop 2, we briefly encountered false sharing. However, we did not get a formal explanation in lecture, so this section will serve to provide more context to the problem.
We were asked to multi-thread a serial version of a simple algorithm that calculated PI by integrating 1/(1 + x^2). The serial version utilized a scalar sum variable to accumulate the calculations. For our naïve attempt, we identified a potential issue with using a scalar sum in a multi-threaded program. We have no direct control on the order a thread finishes their assigned work and leaving it up to chance resulted in varying resulted in a race condition. This is not good, but we still need a global variable, so the threads can return their values. To get around this we came up with the idea to change sum to an array. Now, each thread can index this store their calculations in the array indexed by their own individual thread id and store their calculationsids instead of competing against each other to update the scalar sum.
<pre>
}
</pre>
 
=== Results ===
83
edits

Navigation menu