![]() |
Blaze 3.9
|
Sometimes it may be necessary to enforce the serial execution of specific operations. For this purpose, the Blaze library offers three possible options: the serialization of a single expression via the serial()
function, the serialization of a block of expressions via the BLAZE_SERIAL_SECTION
, and the general deactivation of the parallel execution.
The first option is the serialization of a specific operation via the serial()
function:
serial()
enforces the serial evaluation of the enclosed expression. It can be used on any kind of dense or sparse vector or matrix expression.
The second option is the temporary and local enforcement of a serial execution via the BLAZE_SERIAL_SECTION:
Within the scope of the BLAZE_SERIAL_SECTION
, all operations are guaranteed to run in serial. Outside the scope of the serial section, all operations are run in parallel (if beneficial for the performance).
Note that the BLAZE_SERIAL_SECTION
must only be used within a single thread of execution. The use of the serial section within several concurrent threads will result undefined behavior!
The third option is the general deactivation of the parallel execution (even in case OpenMP is enabled on the command line). This can be achieved via the BLAZE_USE_SHARED_MEMORY_PARALLELIZATION
switch in the ./blaze/config/SMP.h
configuration file:
In case the BLAZE_USE_SHARED_MEMORY_PARALLELIZATION
switch is set to 0, the shared memory parallelization is deactivated altogether.
Previous: OpenMP Parallelization Next: Serialization