Atomics

Multithreaded: Summation with Minimal Synchronization

Until now, I've used two strategies to summate 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 that the thread will perform their summation as independently from each other as possible and therefore reduce the synchronization overhead. 

Read more
Views: 23940

Single Threaded: Summation of a Vector

What is the fastest way to add the elements of a std::vector? This a question that I will pursue in the following posts. I use the single-threaded addition as the reference number. In further posts, I discuss atomics, locks, and thread-local data.

Read more
Views: 28969

Thread-Safe Initialization of a Singleton

There are a lot of issues with the singleton pattern. I'm aware of that. But the singleton pattern is an ideal use case for a variable, which can only be initialized in a thread-safe way. From that point on, you can use it without synchronization. So in this post, I discuss different ways to initialize a singleton in a multithreading environment. You get the performance numbers and can reason about your use cases for the thread-safe initialization of a variable.

Read more
Views: 365637

Ongoing Optimization: Relaxed Semantic with CppMem

With the relaxed semantics, we have no synchronizations and ordering constraints on atomic operations.

Read more
Views: 12901

Ongoing Optimization: A Data Race with CppMem

But we can improve and further improve the acquire-release semantics of the last post. Why should x be atomic? There is no reason. That was my first but incorrect assumption. See why?

Read more
Views: 12771

Ongoing Optimization: Acquire-Release Semantic with CppMem

With the acquire-release semantics, we break the sequential consistency. In the acquire-release semantics, synchronization occurs between atomic operations on the same atomic and not between threads.

Read more
Views: 14438

Ongoing Optimization: Sequential Consistency with CppMem

With atomic data types, you can tailor your program to your needs and optimize it. But now we are in the domain of multithreading experts.

Read more
Views: 14991

CppMem - An Overview

CppMem is an interactive tool for exploring the behavior of small code snippets of the C++ memory model. No, it should have to be in the toolbox of each programmer who deals seriously with the memory model.

Read more
Views: 28852

Relaxed Semantic

The relaxed semantics is the end of the scale. The relaxed semantic is the weakest of all memory models and guarantees that the operations on atomic variables are atomic.

Read more
Views: 29211

Acquire-Release Fences

Acquire and release fences guarantee similar synchronization and ordering constraints as atomics with acquire-release semantics. Similar because the differences are in the details.

Read more
Views: 45640

Stay Informed about my Mentoring

 

Mentoring

English Books

Course: Modern C++ Concurrency in Practice

Course: C++ Standard Library including C++14 & C++17

Course: Embedded Programming with Modern C++

Course: Generic Programming (Templates)

Course: C++ Fundamentals for Professionals

Course: The All-in-One Guide to C++20

Course: Master Software Design Patterns and Architecture in C++

Subscribe to the newsletter (+ pdf bundle)

All tags

Blog archive

Source Code

Visitors

Today 4608

Yesterday 4550

Week 4608

Month 26282

All 12104491

Currently are 152 guests and no members online

Kubik-Rubik Joomla! Extensions

Latest comments