thread_local

C++11 is the first C++ standard that deals with concurrency. The basic building block for concurrency is a thread; therefore, most of the rules are explicitly about threads. This changed dramatically with C++17.

Until now I've used two strategies for the summation of a std::vector. First I did the whole math in one thread (Single Threaded: Summation of a vector); second multiple threads shared the same variable for the result (Multithreaded: Summation of a vector). In particular the second strategy was extremely naive. In this post I will apply my knowledge of both posts. My goal is it that the thread will perform their summation as independent form each other as possible and therefore reduce the synchronization overhead.