|Home > Converting existing code to OpenCL > Dividing data for OpenCL > Data division examples|
You can process one-, two-, or three-dimensional data with OpenCL.
An example of one-dimensional data is audio. Audio is represented as a series of samples. Changing the volume of the audio is a parallel task, because the operation is performed independently per sample.
In this case, the NDRange is the total number of samples in the audio. Each work-item can be one sample and a work-group is a collection of samples.
Audio can also be processed with vectors. If your audio samples are 16-bit, you can make a work-item represent eight samples and process eight of them at a time with vector instructions.
An image is a natural fit for OpenCL, because you can process a 1,600 by 1,200 pixel image by mapping it onto a two-dimensional NDRange of 1,600 by 1,200.The total number of work-items is the total number of pixels in the image, that is, 1,920,000.
The NDRange is divided into work-groups where each work-group is also a two-dimensional array. The number of work-groups must divide into the NDRange exactly.
If each work-item processes a single pixel, a work-group size of 8 by 16 has the size of 128. This work-group size fits exactly into the NDRange on both the x and y axis. To process the image, you require 15,000 work-groups of 128 work-items each.
You can vectorize this example by processing all the color channels in a single vector. If the channels are 8-bit values, you can process multiple pixels in a single vector. If each vector processes four pixels, this means each work-item processes four pixels and you require four times fewer work-items to process the entire image. This means that your NDRange can be reduced to 400 by 1,200 and you only require 3,750 work-groups to process the image.
You can use three-dimensional data to model the behavior of materials in the real world. For example, you can model the behavior of concrete for building by simulating the stresses in a three-dimensional data set.
You can use the data produced to determine the size and design of the structure you require to hold a specific load.
You can use this technique in games to model the physics of objects. When an object is broken, the physics simulation makes the process of breaking more realistic.