While using OpenMP threads,
-
Each thread can declare its own set of private variables. Is it correct to assume,
that fetching data, which are private to each thread, has lower latency than fetching data visible
to all threads. In other words, are the thread local variables cached ? -
Say each thread, wants to use a thread private STL data container like
std::vector. In single threaded C++
code, data in thestd::vectoris stored on the heap. What about the multi-threaded case ?
Are the data of the thread-private std::vectors still stored on the heap ?
Unless you’re using a NUMA machine, memory is uniform.
Thread-local storage isn’t inherently “faster” than memory that is visible to all threads. However, memory that is only used by one thread is less likely to suffer from cache coherency effects – since it is only accessed by a single thread.
Not necessarily. And it definitely won’t be the case if it doesn’t fit in the CPU cache. It is also possible for shared data to be in the caches of multiple cores at the same time.
Yes, they will be in the heap regardless of the number of threads.