OpenCL (Open Computing Language)
- is a parallelism framework for writing programs that execute across heterogeneous platforms consisting of one host CPU and any number of compute devices. These devices include GPUs, CPUs with SIMD instructions, FPGAs, Movidius Myriad 2, Adapteva epiphany and DSPs.
A compute device is broken down to several compute units, which themselves are broken down to multiple PEs (processing elements). A single function execution can run on any number of PEs in parallel. How a compute device is subdivided into compute units and PEs is up to the vendor.
It defines an API for programs running on the host to launch functions on compute devices and manage device memory. This API is defined for C and C++, as well as third-parties such as #Python, #Java, #Perl, #DotNET, etc. A more recent, higher-level model is SYCL; which is purely based on C++11. Programs in OpenCL are compiled at run-time therefore its applications are portable between various host devices.
A four-level memory hierarchy is defined for the compute device:
• global: shared by all PEs, high access latency
OpenCL C
- is the programming language used to write compute kernels. Though based on C99, it is adapted to fit the device model.
A memory buffer resides in a specific level and its pointer is annotated with a region qualifier:
• There is no
• There are no function pointers, bit fields or variable-length arrays
• Recursion is forbidden
• stdlib is replaced by a custom set of standard functions, geared toward math programming
• Scalar types such as
Features:
• Vector types available in fixed-lengths of 2, 3, 4, 8 and 16; and for various base types e.g.
• Operations for vector types
• Synchronization facilities
• Functions to work with work-items and work-groups
• More specialized types incl. 2D and 3D image types
#OpenCL #OpenCL_C
- is a parallelism framework for writing programs that execute across heterogeneous platforms consisting of one host CPU and any number of compute devices. These devices include GPUs, CPUs with SIMD instructions, FPGAs, Movidius Myriad 2, Adapteva epiphany and DSPs.
A compute device is broken down to several compute units, which themselves are broken down to multiple PEs (processing elements). A single function execution can run on any number of PEs in parallel. How a compute device is subdivided into compute units and PEs is up to the vendor.
It defines an API for programs running on the host to launch functions on compute devices and manage device memory. This API is defined for C and C++, as well as third-parties such as #Python, #Java, #Perl, #DotNET, etc. A more recent, higher-level model is SYCL; which is purely based on C++11. Programs in OpenCL are compiled at run-time therefore its applications are portable between various host devices.
A four-level memory hierarchy is defined for the compute device:
• global: shared by all PEs, high access latency
__global
• read-only: smaller, low latency, writable only by the host __constant
• local: shared by a group of PEs __local
• per-element private memory: device registers; __private
Not every device needs to implement each level of this hierarchy in hardware. Consistency between the various levels in the hierarchy is relaxed, and only enforced by explicit synchronization constructs, notably barriers. The host provides handles on device memory buffers and functions to transfer data back and forth.OpenCL C
- is the programming language used to write compute kernels. Though based on C99, it is adapted to fit the device model.
A memory buffer resides in a specific level and its pointer is annotated with a region qualifier:
__global, __local, __constant, and __private
Comparison with #C:• There is no
main; functions are marked __kernel to signal that they are entry points, and are to be called from programs running on the host• There are no function pointers, bit fields or variable-length arrays
• Recursion is forbidden
• stdlib is replaced by a custom set of standard functions, geared toward math programming
• Scalar types such as
float and double behave similarly to those of CFeatures:
• Vector types available in fixed-lengths of 2, 3, 4, 8 and 16; and for various base types e.g.
float4 (4-vector of single-precision floats)• Operations for vector types
• Synchronization facilities
• Functions to work with work-items and work-groups
• More specialized types incl. 2D and 3D image types
#OpenCL #OpenCL_C