By accumulating into partial sum locally, we are utilizing the associative property as well as the commutative property of sum to reduce the amount of lock we need. (Credit to one of the classmates) The accumulation to "diff" by different threads interleave and therefore reflects the commutative property.
By accumulating into partial sum locally, we are utilizing the associative property as well as the commutative property of sum to reduce the amount of lock we need. (Credit to one of the classmates) The accumulation to "diff" by different threads interleave and therefore reflects the commutative property.