Almost all our computers are made of several processing cores. Thus it can be efficient to “parallelize” expensive processing in a multicore manner. That is, instead of using a single core to do all of the work, you divide the work among multiple cores. A standard way to approach this problem is to create threads.
A C thread object executes some functions, possibly on a thread created by the operating system, and goes away. If you wanted to increment a counter using a C thread, you could do it in this manner:
auto mythread=std :: thread ([] { counter ; } ) ; mythread.join () ;
It is obviously silly code that you should never use as is, it is a mere illustration. Creating a new thread is not free. Exactly how expensive it might be depends on several parameters. But can we get some rough idea?
For this purpose, I wrote a small benchmark where I just create a thread , increment a counter and let the thread die. It is the time elapsed while waiting for the thread to run its course. My program computes the mean and standard error of the time, as well as the minimum and maximum duration of the test. For simplicity, I am just going to report the means:
time per thread | Ampere server (Linux, ARM) , ns | Skylake server (Linux, Intel) 9, ns | Rome server (Linux, AMD) , ns |
---|
(Read More)

GIPHY App Key not set. Please check settings