4.2 Development stages for OpenCL
There are several stages to develop an OpenCL application. First, you must determine what you want to parallelize. Then, you must write the kernels. Finally, write infrastructure for the kernels and execute them.
You must perform the following stages to develop and OpenCL application:
- Determine what you want to parallelize
The first step when deciding to use OpenCL is to look
at what your application does, and identify the parts of the application that can run in
parallel. This is often the hardest part of developing an OpenCL application.
Note It is only necessary to convert the parts of an application to OpenCL where
there is likely to be a benefit. Profile your application to find the most active parts
and consider these parts for conversion.
- Write kernels
OpenCL applications consist of a set of kernel
functions. You must write the kernels that perform the computations.
If possible, partition your kernels so that the least amount of data is
transferred between them. Loading large amounts of data is often the most expensive part
of an operation.
- Write infrastructure for kernels
- OpenCL applications require infrastructure code that sets up the data
and prepares the kernels for execution,
- Execute the kernels
- Enqueue the kernels for execution and read back the results.