Version: 1.5

Posted: 2009-09-23

Build Requirements: Mac OS X v10.6, Xcode 3.2.

Runtime Requirements: Mac OS X v10.6

View Source Code:

Download Sample Code (“OpenCL_Parallel_Prefix_Sum_Example.zip”, 12.3K)



Description

This example shows how to perform an efficient parallel prefix sum (aka Scan) using OpenCL. Scan is a common data parallel primitive which can be used for variety of different operations -- this example uses local memory for storing partial sums and avoids memory bank conflicts on architectures which serialize memory operations that are serviced on the same memory bank by offsetting the loads and stores based on the size of the local group and the number of memory banks (see appropriate macro definition). As a result, this example requires that the local group size > 1.

Document Revision History

Date Notes
2009-09-23Bug fixes and tracking api changes.
2009-09-11Updated the sample code to get the kernel work group info by calling clGetKernelWorkGroupInfo to figure out what size should be used to execute the kernel, rather than using a hard coded value.
2009-05-13Updated to new API. Fixed a bug.
2009-01-29OpenCL Parallel Prefix Sum (aka Scan) Example