Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Buffer object and image buffer object in OpenCL

Tags:

opencl

What is the difference between Buffer object and image buffer object in opencl? It is evident that image buffer is faster but to what extent? Where they must be used?

like image 661
Megharaj Avatar asked Mar 28 '12 08:03

Megharaj


1 Answers

An OpenCL Buffer is a 1D or 2D or 3D array in global memory. Its an abstract object that can be addressed thru a pointer. Buffers are Read-Only or Write_only or Read-Write. An Image buffer represents GPU Texture memory. It represents an array of pixels that can be access via functions specifying pixel x,y,z coordinates. There is no pointer access to Image Pixels on the GPU.

The hardware treats these two type of buffers differently. A OpenCL Buffer is either in Host RAM or GPU RAM and transferred between the two. A OpenCL Image Buffer has analogous characteristics of a OpenCL Buffer. But the differences are Image Buffer are either Read-only or Write-only. For Read-only Image buffers, the GPU can cache copies of the image pixels in every compute unit (= 32 or 64 ALU ). Typical the cache size is 8K (bytes or pixels?). Also, since image pixels cannot be accessed via a pointer on the GPU. Their mapping from x,y,z coordinates to physical address can be mapped in several ways. One way is to a Z-ordering. This clusters pixels in two dimensions so that neighboring pixels in x,y directions are store linearly. This helps speed access neighboring pixels in image filters.

OpenCL Buffers are used for general arrays and especially for arrays that are read-write, or double precision. OpenCL Image Buffers are used for image processing or other signal processing algos where the input image/signal can treated as read-only.

like image 88
Tim Child Avatar answered Oct 11 '22 21:10

Tim Child