Classes | |
class | MultithreadInfo |
class | Threads::Thread< RT > |
Namespaces | |
namespace | Threads |
Variables | |
MultithreadInfo | multithread_info |
In a similar way, it is often also profitable to use multiple threads on a single-CPU system if a significant amount of input or output tasks has to be performed. In such cases, the program usually has to wait for disks or network storages to provide the requested data, or to flush buffers. If this is done on a separate thread, other threads of the program can continue to do other, more interesting things at the same time, using the CPU downtime.
Support for this model of computations, i.e. using multiple threads on a shared-memory machine (SMP machine) is provided mainly through the Threads namespace that offers functions to create new threads as well as synchronisation primitives. The MultithreadInfo class allows to query certain properties of the system, such as the number of CPUs. The use of these classes is explained in the step-9, step-13 and step-14 tutorial programs.
On the other hand, programs running on distributed memory machines (i.e. clusters) need a different programming model built on top of MPI and PETSc that is described in the step-17 and later example programs.
Global variable of type MultithreadInfo
which you may ask for the number of CPUs in your system, as well as for the default number of threads that multithreaded functions shall use.