Compute devicesđź”—
By using compute devices, calculations from the CPU can be transferred to a compute device which leads to a significant speedup of some operators.
Using compute devices in HALCON is quite easy.
They can simply be activated and deactivated.
The use of compute devices is based on OpenCL, which means that all OpenCL compatible graphics cards (for example, NVIDIA, AMD and Intel cards) are supported.
To find out whether operators support compute devices, please refer to the “Execution Information” paragraph in the operator reference.
This information can also be queried with the operator get_operator_info.
How to query supporting operators
get_operator_name ('', Operators)
GPUOperators := []
SupportedDevices := []
for I := 0 to |Operators|-1 by 1
get_operator_info (Operators[I], 'compute_device', Information)
if (Information != 'none')
GPUOperators := [GPUOperators, Operators[I]]
SupportedDevices := [SupportedDevices, Information]
endif
endfor
Compute devices are especially useful for filter and transformation operations, as well as for color processing, but they are also available for more complex operators like subpixel precise edge extraction. The usage of compute devices is very transparent. As soon as a compute device has been opened and activated, the operators take over and guide the memory transfer and the synchronization.
However, not all applications will benefit from the use of compute devices. This chapter provides an introduction into using compute devices and will also assist you with the decision whether compute devices may be an option to speed up your application or not.
Using compute devices for an application basically comprises four obligatory steps:
graph TD
A[Query available compute devices] --> B[Open compute device]
B --> C[Initialize compute device]
C --> D[Activate compute device]
D --> E[Perform calculations on compute device]
E --> F[Deactivate compute device]