Thread Local Summation: Using an Atomic Variable with Relaxed Semantic

This lesson explains the solution for calculating the sum of a vector problem using an atomic variable with relaxed semantic in C++.

Using an Atomic Variable with Relaxed Semantic

We can do better. I will use relaxed semantic now instead of the default memory model. That’s well defined because the only guarantee we need is that all summations take place and are atomic. With relaxed semantic the summations can even take place out of order.

Get hands-on with 1400+ tech skills courses.