Customizing the parallelization mechanismsπ
With the help of HALCONβs system parameters, you can customize the behavior of the parallelization mechanisms.
System parameters can be queried with get_system and set with the operator set_system.
In particular, set_system allows you to switch off parts of the features of HALCON.
Querying the number of processors or coresπ
To query the number of processors (or cores), call
get_system('processor_num', Information)
Disabling automatic parallelization or reentrancyπ
A reason to switch off the automatic parallelization mechanism could be if your multithreaded program performs its own scheduling and you do not want HALCON to interfere via automatic parallelization.
Note
You do not need to switch off automatic parallelization when using HALCON on a single-processor or single-core computer. HALCON does so automatically if it detects only one processor or core.
To switch off the automatic parallelization mechanism, call
set_system('parallelize_operators','false')
To switch off reentrancy, call
set_system('reentrant','false')
Note
Switching off reentrancy also switches off automatic parallelization, as it requires reentrancy.
To switch on automatic parallelization or reentrancy again, call set_system with 'true' as the second parameter.
When switching off the automatic parallelization, consider switching off the use of thread pools.
For more information, see the parameter thread_pool of set_system.
Warning
Do not switch on reentrancy if this is already the case.
Otherwise, this will reset the parallelization system, which includes switching on the automatic operator parallelization.
This will decrease the performance in case of manual parallelization (multithreading).
Further optionsπ
- You can customize the automatic parallelization mechanisms in more detail.
For more information, see the parameter
parallelize_operatorsofset_system. - You can influence the number of threads used for automatic parallelization with the parameters
thread_numandtsp_thread_numofset_system. Reducing the number of threads is useful if you also perform a manual parallelization in your program. - If you switch off automatic parallelization permanently, you should also switch off the thread pool to save resources of the operating system.